summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-11-14 18:06:58 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2021-11-20 19:05:09 +0100
commit0159b72dbf048b0aa7d7b9ae85715205cb801e50 (patch)
tree74c1f613cc768c962a621c377ac1d59e40280a67 /src/rebuild.cc
parent3c29644d3bc8c4daad68ab92003a9e754f39de2a (diff)
Evaluate externals in configure step end read from config map during compilation.
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc43
1 files changed, 39 insertions, 4 deletions
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<BuildConfigurationEntry, 1024> configFiles;
std::size_t numConfigFiles{0};
-int reg(std::vector<BuildConfiguration> (*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<ExternalConfigurationEntry, 1024> externalConfigFiles;
std::size_t numExternalConfigFiles{0};
-int reg(std::vector<ExternalConfiguration> (*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<Source>& 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<std::string> 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;
}