From 55ab1f564286c6f3e986bf68ebb271132a749c6f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 15 Dec 2022 11:05:31 +0100 Subject: Add clang support. --- src/bootstrap.cc | 7 +++++++ src/configure.cc | 23 +++++++++++++++++++++++ src/rebuild.h | 2 -- src/task.h | 1 + src/tasks.h | 4 ++-- src/unittest.h | 2 +- 6 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bootstrap.cc b/src/bootstrap.cc index 9079092..c58c399 100644 --- a/src/bootstrap.cc +++ b/src/bootstrap.cc @@ -3,6 +3,7 @@ // See accompanying file LICENSE for details. #include #include +#include #define BOOTSTRAP @@ -35,6 +36,12 @@ bool hasConfiguration(const std::string& key) const std::string& getConfiguration(const std::string& key, const std::string& defaultValue) { + if(key == cfg::host_cxx && std::getenv("CXX")) + { + static std::string s = std::getenv("CXX"); + return s; + } + return defaultValue; } diff --git a/src/configure.cc b/src/configure.cc index 86538ab..50a7c32 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -32,6 +32,7 @@ namespace ctor { std::optional includedir; std::optional libdir; +std::map conf_values; } bool hasConfiguration(const std::string& key) @@ -46,6 +47,11 @@ bool hasConfiguration(const std::string& key) return true; } + if(ctor::conf_values.find(key) != ctor::conf_values.end()) + { + return true; + } + const auto& c = configuration(); return c.tools.find(key) != c.tools.end(); } @@ -63,6 +69,11 @@ const std::string& getConfiguration(const std::string& key, return *ctor::libdir; } + if(ctor::conf_values.find(key) != ctor::conf_values.end()) + { + return ctor::conf_values[key]; + } + const auto& c = configuration(); if(hasConfiguration(key)) { @@ -376,6 +387,18 @@ int regenerateCache(const Settings& default_settings, std::string build_ar = locate(build_arch, ar_prog); std::string build_ld = locate(build_arch, ld_prog); + // Store current values for execution in this execution context. + if(!ctor_includedir.empty()) + { + ctor::conf_values[cfg::ctor_includedir] = ctor_includedir; + } + if(!ctor_libdir.empty()) + { + ctor::conf_values[cfg::ctor_libdir] = ctor_libdir; + } + ctor::conf_values[cfg::host_cxx] = host_cxx; + ctor::conf_values[cfg::build_cxx] = build_cxx; + std::cout << "Writing results to: " << configurationFile.string() << "\n"; { std::ofstream istr(configurationFile); diff --git a/src/rebuild.h b/src/rebuild.h index afa2307..284aeb2 100644 --- a/src/rebuild.h +++ b/src/rebuild.h @@ -8,8 +8,6 @@ #include "ctor.h" -class Settings; - struct BuildConfigurationEntry { const char* file; diff --git a/src/task.h b/src/task.h index e192555..4efbfff 100644 --- a/src/task.h +++ b/src/task.h @@ -28,6 +28,7 @@ class Task public: Task(const BuildConfiguration& config, const Settings& settings, const std::string& sourceDir); + virtual ~Task() = default; int registerDepTasks(const std::set>& tasks); virtual int registerDepTasksInner(const std::set>& tasks) { return 0; } diff --git a/src/tasks.h b/src/tasks.h index c547432..403a954 100644 --- a/src/tasks.h +++ b/src/tasks.h @@ -10,8 +10,8 @@ #include "task.h" -class BuildConfiguration; -class Settings; +struct BuildConfiguration; +struct Settings; struct Target { diff --git a/src/unittest.h b/src/unittest.h index 8dee33c..5118689 100644 --- a/src/unittest.h +++ b/src/unittest.h @@ -7,7 +7,7 @@ #include class Task; -class Settings; +struct Settings; int runUnitTests(std::set>& tasks, const Settings& settings); -- cgit v1.2.3