From cc4e14d243f4e7e1ad487d8865c5ffc8423e473d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 28 Dec 2022 13:49:53 +0100 Subject: Add detected toolchain to configuration.cc --- src/configure.cc | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'src/configure.cc') 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 external_includedir; std::map 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 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) { -- cgit v1.2.3