From dafd592cf44c184f9d24e2216bbed5c23e4b23c2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 7 Jun 2022 18:06:57 +0200 Subject: Refactor the way task names are looked up. --- src/task.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/task.cc') 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 #include -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>& 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>& 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; } -- cgit v1.2.3