summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-06-20 13:15:03 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-06-20 13:29:08 +0200
commit41f947b80f1c03d5451988593d2d16ec69e9b653 (patch)
treed2a320f28a8b306d8ee6d1b679e9493f0370beb5
parent69528ba012ac2238f63464fb84e7623f3088603a (diff)
Print error if max build configurations are exceeded.
-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;