summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-12-28 13:49:53 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-12 15:15:53 +0100
commitcc4e14d243f4e7e1ad487d8865c5ffc8423e473d (patch)
tree10473afd8cf2f6bd6385e1d50b0e2699069fb3eb /src/configure.cc
parent430801b1307b4c820885f161d0b003011c892d77 (diff)
Add detected toolchain to configuration.cc
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)
{