summaryrefslogtreecommitdiff
path: root/src/task.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/task.cc')
-rw-r--r--src/task.cc38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/task.cc b/src/task.cc
index 817ee3a..ef7731b 100644
--- a/src/task.cc
+++ b/src/task.cc
@@ -3,19 +3,20 @@
// See accompanying file LICENSE for details.
#include "task.h"
-#include <unistd.h>
#include <iostream>
+#include <algorithm>
+#include <utility>
-Task::Task(const ctor::build_configuration& config, const ctor::settings& settings,
- const std::string& sourceDir)
- : config(config)
+Task::Task(const ctor::build_configuration& config_, const ctor::settings& settings_,
+ std::string sourceDir_)
+ : config(config_)
, output_system(config.system)
- , settings(settings)
- , sourceDir(sourceDir)
+ , settings(settings_)
+ , sourceDir(std::move(sourceDir_))
{
}
-int Task::registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks)
+int Task::registerDepTasks(const std::vector<std::shared_ptr<Task>>& tasks)
{
for(const auto& depStr : depends())
{
@@ -24,7 +25,10 @@ int Task::registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks)
{
if(*task == depStr)
{
- dependsTasks.insert(task);
+ if(std::find(dependsTasks.begin(), dependsTasks.end(), task) == dependsTasks.end())
+ {
+ dependsTasks.push_back(task);
+ }
found = true;
}
}
@@ -41,11 +45,14 @@ int Task::registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks)
bool Task::operator==(const std::string& depStr)
{
+ std::filesystem::path generated_output = sourceDir;
+ generated_output /= target();
return
- name() == depStr ||
- target() == depStr ||
- sourceDir + "/" + target() == depStr ||
- targetFile().string() == depStr
+ (!derived() && name() == depStr) || // compare to name
+ (!derived() && config.target == depStr) || // compare to stated target (ex. foo.a)
+ target() == depStr || // compare to derived (derived to foo.lib on msvc)
+ generated_output == depStr || // not sure what this is for?!
+ targetFile().string() == depStr // compare to target output file
;
}
@@ -140,6 +147,7 @@ std::string Task::compiler() const
case ctor::output_system::build:
return c.get(ctor::cfg::build_cc, "/usr/bin/gcc");
}
+ break;
case ctor::language::cpp:
switch(outputSystem())
{
@@ -148,14 +156,18 @@ std::string Task::compiler() const
case ctor::output_system::build:
return c.get(ctor::cfg::build_cxx, "/usr/bin/g++");
}
+ break;
default:
std::cerr << "Unknown CC target type\n";
exit(1);
break;
}
+
+ std::cerr << "Unhandled compiler!\n";
+ exit(1);
}
-std::set<std::shared_ptr<Task>> Task::getDependsTasks()
+std::vector<std::shared_ptr<Task>> Task::getDependsTasks()
{
return dependsTasks;
}