summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
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;
}