summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/rebuild.cc b/src/rebuild.cc
index a03f5e3..fc95b16 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -6,6 +6,7 @@
#include <iostream>
#include <filesystem>
#include <algorithm>
+#include <source_location>
#include "configure.h"
#include "settings.h"
@@ -16,9 +17,8 @@
std::array<BuildConfigurationEntry, 1024> configFiles;
std::size_t 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(std::vector<BuildConfiguration> (*cb)(),
+ const std::source_location location)
{
// NOTE: std::cout cannot be used here
if(numConfigFiles >= configFiles.size())
@@ -28,13 +28,31 @@ int reg(const char* location, std::vector<BuildConfiguration> (*cb)())
exit(1);
}
- configFiles[numConfigFiles].file = location;
+ configFiles[numConfigFiles].file = location.file_name();
configFiles[numConfigFiles].cb = cb;
++numConfigFiles;
return 0;
}
+int reg(const char* location)
+{
+ // 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 =
+ [](){ return std::vector<BuildConfiguration>{}; };
+ ++numConfigFiles;
+
+ return 0;
+}
+
int unreg(const char* location)
{
std::size_t found{0};
@@ -78,9 +96,8 @@ int unreg(const char* location)
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)())
+int reg(std::vector<ExternalConfiguration> (*cb)(),
+ const std::source_location location)
{
// NOTE: std::cout cannot be used here
if(numExternalConfigFiles >= externalConfigFiles.size())
@@ -90,7 +107,7 @@ int reg(const char* location, std::vector<ExternalConfiguration> (*cb)())
exit(1);
}
- externalConfigFiles[numExternalConfigFiles].file = location;
+ externalConfigFiles[numExternalConfigFiles].file = location.file_name();
externalConfigFiles[numExternalConfigFiles].cb = cb;
++numExternalConfigFiles;