From 0159b72dbf048b0aa7d7b9ae85715205cb801e50 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 14 Nov 2021 18:06:58 +0100 Subject: Evaluate externals in configure step end read from config map during compilation. --- src/rebuild.cc | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'src/rebuild.cc') diff --git a/src/rebuild.cc b/src/rebuild.cc index fc95b16..ff61695 100644 --- a/src/rebuild.cc +++ b/src/rebuild.cc @@ -13,11 +13,12 @@ #include "libctor.h" #include "tasks.h" #include "build.h" +#include "execute.h" std::array configFiles; std::size_t numConfigFiles{0}; -int reg(std::vector (*cb)(), +int reg(BuildConfigurations (*cb)(), const std::source_location location) { // NOTE: std::cout cannot be used here @@ -96,7 +97,7 @@ int unreg(const char* location) std::array externalConfigFiles; std::size_t numExternalConfigFiles{0}; -int reg(std::vector (*cb)(), +int reg(ExternalConfigurations (*cb)(), const std::source_location location) { // NOTE: std::cout cannot be used here @@ -130,7 +131,7 @@ bool contains(const std::vector& sources, const std::string& file) } } -void recompileCheck(const Settings& global_settings, int argc, char* argv[], +bool recompileCheck(const Settings& global_settings, int argc, char* argv[], bool relaunch_allowed) { using namespace std::string_literals; @@ -207,7 +208,19 @@ void recompileCheck(const Settings& global_settings, int argc, char* argv[], { if(task->registerDepTasks(tasks)) { - return; + return false; + } + } + + // Find out if reconfigure is needed + bool reconfigure{false}; + for(auto task : tasks) + { + if(task->dirty() && + task->source() != "" && // only look at source files + task->source() != "configuration.cc") // don't reconfigure if only configuration.cc is changed. + { + reconfigure |= true; } } @@ -217,4 +230,26 @@ void recompileCheck(const Settings& global_settings, int argc, char* argv[], std::cout << "Rebuilding config.\n"; build(settings, "ctor", tasks); // run for real } + + if(reconfigure) + { + std::vector args; + args.push_back("reconfigure"); + if(!relaunch_allowed) + { + args.push_back("--no-rerun"); + } + for(int i = 1; i < argc; ++i) + { + args.push_back(argv[i]); + } + auto ret = execute(argv[0], args); + //if(ret != 0) + { + exit(ret); + } + + } + + return dirty_tasks; } -- cgit v1.2.3