summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcppbuild.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/libcppbuild.cc b/libcppbuild.cc
index 8d5231f..441ba00 100644
--- a/libcppbuild.cc
+++ b/libcppbuild.cc
@@ -88,20 +88,29 @@ std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTas
return nullptr;
}
-struct Config
+namespace
+{
+struct BuildConfigurationEntry
{
const char* file;
std::vector<BuildConfiguration> (*cb)();
};
-std::array<Config, 100> configFiles;
+std::array<BuildConfigurationEntry, 1024> configFiles;
int numConfigFiles{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<BuildConfiguration> (*cb)())
+int reg(const char* location, std::vector<BuildConfiguration> (*cb)())
{
// NOTE: std::cout cannot be used here
+ if(numConfigFiles >= configFiles.size())
+ {
+ fprintf(stderr, "Max %d build configurations currently supported.\n",
+ (int)configFiles.size());
+ exit(1);
+ }
+
configFiles[numConfigFiles].file = location;
configFiles[numConfigFiles].cb = cb;
++numConfigFiles;