summaryrefslogtreecommitdiff
path: root/src/task.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-06-07 18:06:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-06-09 22:20:31 +0200
commitdafd592cf44c184f9d24e2216bbed5c23e4b23c2 (patch)
treee94ab4c49ec4486e3a8e91c04cbba73a221d54c7 /src/task.cc
parent80db51ae3f7d5fbfb52eee4505f615ea4edba62d (diff)
Refactor the way task names are looked up.
Diffstat (limited to 'src/task.cc')
-rw-r--r--src/task.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/task.cc b/src/task.cc
index b8fce06..3ec48f5 100644
--- a/src/task.cc
+++ b/src/task.cc
@@ -6,9 +6,14 @@
#include <unistd.h>
#include <iostream>
-Task::Task(const BuildConfiguration& config)
+#include "settings.h"
+
+Task::Task(const BuildConfiguration& config, const Settings& settings,
+ const std::string& sourceDir)
: config(config)
, output_system(config.system)
+ , settings(settings)
+ , sourceDir(sourceDir)
{
}
@@ -19,7 +24,7 @@ int Task::registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks)
bool found{false};
for(const auto& task : tasks)
{
- if(task->target() == depStr)
+ if(*task == depStr)
{
dependsTasks.insert(task);
found = true;
@@ -36,13 +41,18 @@ int Task::registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks)
return 0;
}
+bool Task::operator==(const std::string& depStr)
+{
+ return
+ name() == depStr ||
+ target() == depStr ||
+ sourceDir + "/" + target() == depStr ||
+ targetFile().string() == depStr
+ ;
+}
+
std::string Task::name() const
{
- // If config name is not set, use target instead.
- if(config.name.empty())
- {
- return config.target;
- }
return config.name;
}