summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-01-11 16:35:57 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-11 17:09:12 +0100
commitf31661d392c1332ceb0edcbc9fd35f4cb49bb50d (patch)
tree6034e11da079476e0ab4b0b3c6bfefaee187d5e9 /src/configure.cc
parent0b0cb4afa08210b572a9be6cadcb6397935b99d1 (diff)
Support using custom build-dir during bootstrap.
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc30
1 files changed, 26 insertions, 4 deletions
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<std::string> includedir;
std::optional<std::string> libdir;
+std::optional<std::string> builddir;
std::map<std::string, std::string> 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<class> inline constexpr bool always_false_v = false;
-int regenerateCache(const Settings& default_settings,
+int regenerateCache(Settings& settings,
const std::vector<std::string>& args,
const std::map<std::string, std::string>& 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<std::string> args;