From 9ae92b4f1d5c24fa9d8d73e6f916b5d6aa01da67 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 19 Jun 2021 15:41:56 +0200 Subject: Fail on missing dependecies and trigger re-build if depends list changes in build configurations. --- libcppbuild.cc | 5 ++++- task.cc | 12 +++++++++++- task.h | 2 +- task_ar.cc | 13 ++++++++++++- task_ld.cc | 13 ++++++++++++- task_so.cc | 13 ++++++++++++- 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/libcppbuild.cc b/libcppbuild.cc index f575a52..9fcc4d4 100644 --- a/libcppbuild.cc +++ b/libcppbuild.cc @@ -248,7 +248,10 @@ int main(int argc, char* argv[]) for(auto task : tasks) { - task->registerDepTasks(tasks); + if(task->registerDepTasks(tasks)) + { + return 1; + } } std::list> dirtyTasks; diff --git a/task.cc b/task.cc index 10e9368..e5f11aa 100644 --- a/task.cc +++ b/task.cc @@ -8,18 +8,28 @@ Task::Task(const std::vector& depends) { } -void Task::registerDepTasks(const std::list>& tasks) +int Task::registerDepTasks(const std::list>& tasks) { for(auto const& depStr : dependsStr) { + bool found{false}; for(const auto& task : tasks) { if(task->target() == depStr) { dependsTasks.push_back(task); + found = true; } } + if(!found) + { + std::cerr << "Could not find dependency " << depStr << " needed by " << + target() << " target\n"; + return 1; + } } + + return 0; } bool Task::dirty() diff --git a/task.h b/task.h index 00b01d2..f7a4758 100644 --- a/task.h +++ b/task.h @@ -21,7 +21,7 @@ class Task public: Task(const std::vector& depends); - void registerDepTasks(const std::list>& tasks); + int registerDepTasks(const std::list>& tasks); bool dirty(); bool ready(); diff --git a/task_ar.cc b/task_ar.cc index c133875..58223ad 100644 --- a/task_ar.cc +++ b/task_ar.cc @@ -178,11 +178,22 @@ std::string TaskAR::flagsString() const std::string flagsStr; for(const auto& flag : config.ldflags) { - if(!flagsStr.empty()) + if(flag != config.ldflags[0]) { flagsStr += " "; } flagsStr += flag; } + flagsStr += "\n"; + + for(const auto& dep : config.depends) + { + if(dep != config.depends[0]) + { + flagsStr += " "; + } + flagsStr += dep; + } + return flagsStr; } diff --git a/task_ld.cc b/task_ld.cc index db0f955..874ec6d 100644 --- a/task_ld.cc +++ b/task_ld.cc @@ -192,11 +192,22 @@ std::string TaskLD::flagsString() const std::string flagsStr; for(const auto& flag : config.ldflags) { - if(!flagsStr.empty()) + if(flag != config.ldflags[0]) { flagsStr += " "; } flagsStr += flag; } + flagsStr += "\n"; + + for(const auto& dep : config.depends) + { + if(dep != config.depends[0]) + { + flagsStr += " "; + } + flagsStr += dep; + } + return flagsStr; } diff --git a/task_so.cc b/task_so.cc index afe5c32..c484a40 100644 --- a/task_so.cc +++ b/task_so.cc @@ -188,11 +188,22 @@ std::string TaskSO::flagsString() const std::string flagsStr; for(const auto& flag : config.ldflags) { - if(!flagsStr.empty()) + if(flag != config.ldflags[0]) { flagsStr += " "; } flagsStr += flag; } + flagsStr += "\n"; + + for(const auto& dep : config.depends) + { + if(dep != config.depends[0]) + { + flagsStr += " "; + } + flagsStr += dep; + } + return flagsStr; } -- cgit v1.2.3