summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/configure.cc b/src/configure.cc
index f91f0d9..deeb6a6 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -15,6 +15,7 @@
#include "tasks.h"
#include "rebuild.h"
#include "externals.h"
+#include "tools.h"
std::filesystem::path configurationFile("configuration.cc");
std::filesystem::path configHeaderFile("config.h");
@@ -22,10 +23,16 @@ std::filesystem::path configHeaderFile("config.h");
std::map<std::string, std::string> external_includedir;
std::map<std::string, std::string> external_libdir;
-const ctor::configuration default_configuration{};
const ctor::configuration& __attribute__((weak)) ctor::get_configuration()
{
- return default_configuration;
+ static ctor::configuration cfg;
+ static bool initialised{false};
+ if(!initialised)
+ {
+ cfg.host_toolchain = getToolChain(cfg.get(ctor::cfg::host_cxx, "g++"));
+ initialised = true;
+ }
+ return cfg;
}
namespace ctor {
@@ -164,6 +171,28 @@ public:
}
};
+namespace {
+std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain)
+{
+ switch(toolchain)
+ {
+ case ctor::toolchain::any:
+ stream << "ctor::toolchain::any";
+ break;
+ case ctor::toolchain::none:
+ stream << "ctor::toolchain::none";
+ break;
+ case ctor::toolchain::gcc:
+ stream << "ctor::toolchain::gcc";
+ break;
+ case ctor::toolchain::clang:
+ stream << "ctor::toolchain::clang";
+ break;
+ }
+ return stream;
+}
+}
+
// helper constant for the visitor
template<class> inline constexpr bool always_false_v = false;
@@ -395,6 +424,12 @@ int regenerateCache(ctor::settings& settings,
std::string build_ar = locate(build_arch, ar_prog);
std::string build_ld = locate(build_arch, ld_prog);
+ if(!host_cxx.empty())
+ {
+ // This is needed for bootstrapping (when running configure for the first time)
+ ctor::conf_values[ctor::cfg::host_cxx] = host_cxx;
+ }
+
// Store current values for execution in this execution context.
if(!ctor_includedir.empty())
{
@@ -419,6 +454,8 @@ int regenerateCache(ctor::settings& settings,
istr << "{\n";
istr << " static ctor::configuration cfg =\n";
istr << " {\n";
+ istr << " .host_toolchain = " << getToolChain(host_cxx) << ",\n";
+ istr << " .build_toolchain = " << getToolChain(build_cxx) << ",\n";
istr << " .args = {";
for(const auto& arg : args)
{