diff options
Diffstat (limited to 'src/build.cc')
-rw-r--r-- | src/build.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/build.cc b/src/build.cc index 2412b84..8adbc54 100644 --- a/src/build.cc +++ b/src/build.cc @@ -15,7 +15,8 @@ using namespace std::chrono_literals; int build(const Settings& settings, const std::string& name, const std::list<std::shared_ptr<Task>>& tasks, - const std::list<std::shared_ptr<Task>>& all_tasks) + const std::list<std::shared_ptr<Task>>& all_tasks, + bool dryrun) { if(settings.verbose > 1) { @@ -31,6 +32,12 @@ int build(const Settings& settings, } } + // Dry-run returns number of dirty tasks but otherwise does nothing. + if(dryrun) + { + return dirtyTasks.size(); + } + if(dirtyTasks.empty()) { if(settings.verbose > -1) @@ -148,12 +155,19 @@ std::set<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task) int build(const Settings& settings, const std::string& name, - const std::list<std::shared_ptr<Task>>& all_tasks) + const std::list<std::shared_ptr<Task>>& all_tasks, + bool dryrun) { bool task_found{false}; for(auto task : all_tasks) { - if(task->name() == name || task->target() == name) + if(task->target() == name || // match exact target output (ex. build/foo.o) + + (!task->derived() && // if non-derived task: + ( task->buildConfig().target == name || // match name + task->buildConfig().name == name ) // or target + ) + ) { task_found = true; @@ -163,7 +177,8 @@ int build(const Settings& settings, { ts.push_back(task); } - auto ret = build(settings, name, ts, all_tasks); + + auto ret = build(settings, name, ts, all_tasks, dryrun); if(ret != 0) { return ret; @@ -185,7 +200,8 @@ int build(const Settings& settings, int build(const Settings& settings, const std::string& name, const std::vector<Target>& targets, - const std::list<std::shared_ptr<Task>>& all_tasks) + const std::list<std::shared_ptr<Task>>& all_tasks, + bool dryrun) { bool task_found{false}; std::list<std::shared_ptr<Task>> ts; @@ -194,8 +210,8 @@ int build(const Settings& settings, { for(auto task : all_tasks) { - if(task->name() == target.config.target || - task->target() == target.config.target) + if(!task->derived() && // only consider non-derived tasks + task->buildConfig().target == target.config.target) { task_found = true; @@ -214,5 +230,5 @@ int build(const Settings& settings, return 1; } - return build(settings, name, ts, all_tasks); + return build(settings, name, ts, all_tasks, dryrun); } |