From f31661d392c1332ceb0edcbc9fd35f4cb49bb50d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 11 Jan 2023 16:35:57 +0100 Subject: Support using custom build-dir during bootstrap. --- src/configure.cc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/configure.cc') diff --git a/src/configure.cc b/src/configure.cc index 50a7c32..25403f7 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -32,6 +32,7 @@ namespace ctor { std::optional includedir; std::optional libdir; +std::optional builddir; std::map conf_values; } @@ -47,6 +48,11 @@ bool hasConfiguration(const std::string& key) return true; } + if(key == cfg::builddir && ctor::builddir) + { + return true; + } + if(ctor::conf_values.find(key) != ctor::conf_values.end()) { return true; @@ -69,6 +75,11 @@ const std::string& getConfiguration(const std::string& key, return *ctor::libdir; } + if(key == cfg::builddir && ctor::builddir) + { + return *ctor::builddir; + } + if(ctor::conf_values.find(key) != ctor::conf_values.end()) { return ctor::conf_values[key]; @@ -160,11 +171,10 @@ public: // helper constant for the visitor template inline constexpr bool always_false_v = false; -int regenerateCache(const Settings& default_settings, +int regenerateCache(Settings& settings, const std::vector& args, const std::map& env) { - Settings settings{default_settings}; Args vargs(args); dg::Options opt; @@ -180,12 +190,14 @@ int regenerateCache(const Settings& default_settings, std::string ld_prog = "ld"; std::string ctor_includedir; std::string ctor_libdir; + std::string builddir; opt.add("build-dir", required_argument, 'b', "Set output directory for build files (default: '" + settings.builddir + "').", [&]() { settings.builddir = optarg; + builddir = optarg; return 0; }); @@ -396,6 +408,10 @@ int regenerateCache(const Settings& default_settings, { ctor::conf_values[cfg::ctor_libdir] = ctor_libdir; } + if(!builddir.empty()) + { + ctor::conf_values[cfg::builddir] = builddir; + } ctor::conf_values[cfg::host_cxx] = host_cxx; ctor::conf_values[cfg::build_cxx] = build_cxx; @@ -421,7 +437,11 @@ int regenerateCache(const Settings& default_settings, istr << "},\n"; istr << " .tools = {\n"; - istr << " { \"" << cfg::builddir << "\", \"" << settings.builddir << "\" },\n"; + if(!builddir.empty()) + { + istr << " { \"" << cfg::builddir << "\", \"" << builddir << "\" },\n"; + ctor::builddir = builddir; + } istr << " { \"" << cfg::host_cc << "\", \"" << host_cc << "\" },\n"; istr << " { \"" << cfg::host_cxx << "\", \"" << host_cxx << "\" },\n"; istr << " { \"" << cfg::host_ar << "\", \"" << host_ar << "\" },\n"; @@ -567,8 +587,10 @@ int configure(const Settings& global_settings, int argc, char* argv[]) return 0; } -int reconfigure(const Settings& settings, int argc, char* argv[]) +int reconfigure(const Settings& global_settings, int argc, char* argv[]) { + Settings settings{global_settings}; + bool no_rerun{false}; std::vector args; -- cgit v1.2.3