From 7bf162fcd98920644e4f61ac0181037eb62c807e Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 24 Oct 2021 18:45:17 +0200 Subject: Fix compilation of named targets and print notification when re-compiling config. --- src/build.cc | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/build.cc') 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>& tasks, - const std::list>& all_tasks) + const std::list>& 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> getDepTasks(std::shared_ptr task) int build(const Settings& settings, const std::string& name, - const std::list>& all_tasks) + const std::list>& 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& targets, - const std::list>& all_tasks) + const std::list>& all_tasks, + bool dryrun) { bool task_found{false}; std::list> 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); } -- cgit v1.2.3