summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/rebuild.cc b/src/rebuild.cc
index c1f2a4a..3492955 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -55,9 +55,48 @@ int unreg(const char* location)
}
}
+ for(std::size_t i = 0; i < numExternalConfigFiles;)
+ {
+ if(std::string(location) == externalConfigFiles[i].file)
+ {
+ ++found;
+ for(std::size_t j = i; j < numExternalConfigFiles; ++j)
+ {
+ externalConfigFiles[j] = externalConfigFiles[j + 1];
+ }
+ --numExternalConfigFiles;
+ }
+ else
+ {
+ ++i;
+ }
+ }
+
return found;
}
+std::array<ExternalConfigurationEntry, 1024> externalConfigFiles;
+std::size_t numExternalConfigFiles{0};
+
+// TODO: Use c++20 when ready, somehing like this:
+//int reg(const std::source_location location = std::source_location::current())
+int reg(const char* location, std::vector<ExternalConfiguration> (*cb)())
+{
+ // NOTE: std::cout cannot be used here
+ if(numExternalConfigFiles >= externalConfigFiles.size())
+ {
+ fprintf(stderr, "Max %d external configurations currently supported.\n",
+ (int)externalConfigFiles.size());
+ exit(1);
+ }
+
+ externalConfigFiles[numExternalConfigFiles].file = location;
+ externalConfigFiles[numExternalConfigFiles].cb = cb;
+ ++numExternalConfigFiles;
+
+ return 0;
+}
+
namespace
{
bool contains(const std::vector<Source>& sources, const std::string& file)
@@ -130,6 +169,21 @@ void recompileCheck(const Settings& global_settings, int argc, char* argv[],
}
}
+ for(std::size_t i = 0; i < numExternalConfigFiles; ++i)
+ {
+ std::string location = externalConfigFiles[i].file;
+ if(global_settings.verbose > 1)
+ {
+ std::cout << " - " << location << "\n";
+ }
+
+ // Ensure that files containing multiple configurations are only added once.
+ if(!contains(config.sources, location))
+ {
+ config.sources.push_back(location);
+ }
+ }
+
auto tasks = taskFactory({config}, settings, {});
for(auto task : tasks)