summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-11-14 18:06:58 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2021-11-20 19:05:09 +0100
commit0159b72dbf048b0aa7d7b9ae85715205cb801e50 (patch)
tree74c1f613cc768c962a621c377ac1d59e40280a67 /src/configure.cc
parent3c29644d3bc8c4daad68ab92003a9e754f39de2a (diff)
Evaluate externals in configure step end read from config map during compilation.
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc101
1 files changed, 96 insertions, 5 deletions
diff --git a/src/configure.cc b/src/configure.cc
index 13409ef..98f68d7 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -325,6 +325,17 @@ int regenerateCache(const Settings& default_settings,
std::string build_ar = locate(build_arch, ar_prog);
std::string build_ld = locate(build_arch, ld_prog);
+ // TODO: Centralize
+ // Resolv externals
+ ExternalConfigurations externalConfigs;
+ for(std::size_t i = 0; i < numExternalConfigFiles; ++i)
+ {
+ auto newExternalConfigs = externalConfigFiles[i].cb();
+ externalConfigs.insert(externalConfigs.end(),
+ newExternalConfigs.begin(),
+ newExternalConfigs.end());
+ }
+
std::cout << "Writing results to: " << configurationFile.string() << "\n";
{
std::ofstream istr(configurationFile);
@@ -368,9 +379,75 @@ int regenerateCache(const Settings& default_settings,
}
istr << " },\n";
+ istr << " .externals = {\n";
+
+ for(const auto& externalConfig : externalConfigs)
+ {
+ if(!externalConfig.cflags.empty())
+ {
+ istr << " { \"" << externalConfig.name << "-cflags\",\n";
+ istr << " {\n";
+ for(const auto& cflag : externalConfig.cflags)
+ {
+ istr << " \"" << cflag << "\",\n";
+ }
+ istr << " },\n";
+ istr << " },\n";
+ }
+
+ if(!externalConfig.cxxflags.empty())
+ {
+ istr << " { \"" << externalConfig.name << "-cxxflags\",\n";
+ istr << " {\n";
+ for(const auto& cxxflag : externalConfig.cxxflags)
+ {
+ istr << " \"" << cxxflag << "\",\n";
+ }
+ istr << " },\n";
+ istr << " },\n";
+ }
+
+ if(!externalConfig.ldflags.empty())
+ {
+ istr << " { \"" << externalConfig.name << "-ldflags\",\n";
+ istr << " {\n";
+ for(const auto& ldflag : externalConfig.ldflags)
+ {
+ istr << " \"" << ldflag << "\",\n";
+ }
+ istr << " },\n";
+ istr << " },\n";
+ }
+
+ if(!externalConfig.libs.empty())
+ {
+ istr << " { \"" << externalConfig.name << "-libs\",\n";
+ istr << " {\n";
+ for(const auto& lib : externalConfig.libs)
+ {
+ istr << " \"" << lib << "\",\n";
+ }
+ istr << " },\n";
+ istr << " },\n";
+ }
+
+ if(!externalConfig.asmflags.empty())
+ {
+ istr << " { \"" << externalConfig.name << "-asmflags\",\n";
+ istr << " {\n";
+ for(const auto& asmflag : externalConfig.asmflags)
+ {
+ istr << " \"" << asmflag << "\",\n";
+ }
+ istr << " },\n";
+ istr << " },\n";
+ }
+ }
+
+ istr << " },\n";
istr << " };\n";
istr << " return cfg;\n";
- istr << "}\n";
+ istr << "}\n\n";
}
{
@@ -424,13 +501,26 @@ int configure(const Settings& global_settings, int argc, char* argv[])
return ret;
}
- recompileCheck(settings, 1, argv, false);
+ recompileCheck(settings, argc, argv, false);
return 0;
}
int reconfigure(const Settings& settings, int argc, char* argv[])
{
+ bool no_rerun{false};
+
+ std::vector<std::string> args;
+ for(int i = 2; i < argc; ++i) // skip executable name and 'reconfigure' arg
+ {
+ if(i == 2 && std::string(argv[i]) == "--no-rerun")
+ {
+ no_rerun = true;
+ continue;
+ }
+ args.push_back(argv[i]);
+ }
+
const auto& cfg = configuration();
std::cout << "Re-running configure:\n";
@@ -451,10 +541,11 @@ int reconfigure(const Settings& settings, int argc, char* argv[])
return ret;
}
- std::vector<std::string> args;
- for(int i = 2; i < argc; ++i) // skip command and the first 'reconfigure' arg
+ recompileCheck(settings, 1, argv, false);
+
+ if(no_rerun)
{
- args.push_back(argv[i]);
+ return 0; // this was originally invoked by configure, don't loop
}
return execute(argv[0], args);