aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-02-14 11:16:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-02-14 11:16:53 +0200
commit14485a1ebe8daccf80498efbb0b88a6ab2021fa2 (patch)
tree369a448df6ebc24011b5027d4160ac1a10d67b23
parent4c1b2f072bcc41c00990331245e479a55b0990ff (diff)
Add ability to override amalgamation and subprojects in bootstrap_src()
-rw-r--r--libbuild2/file.cxx35
-rw-r--r--libbuild2/file.hxx9
2 files changed, 41 insertions, 3 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 4cf6d82..d91bf73 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -913,7 +913,9 @@ namespace build2
}
void
- bootstrap_src (scope& rs, optional<bool>& altn)
+ bootstrap_src (scope& rs, optional<bool>& altn,
+ optional<dir_path> aovr,
+ bool sovr)
{
tracer trace ("bootstrap_src");
@@ -943,6 +945,8 @@ namespace build2
rs.root_extra->project = nullptr;
rs.root_extra->amalgamation = nullptr;
rs.root_extra->subprojects = nullptr;
+
+ assert (!aovr || aovr->empty ());
}
// We assume that bootstrap out cannot load this file explicitly. It
// feels wrong to allow this since that makes the whole bootstrap
@@ -985,7 +989,13 @@ namespace build2
const project_name pn (cast<project_name> (move (*pv)));
rs.root_extra->project = &pn;
- if (av && (av->null || av->empty ()))
+ // @@ We will still have original values in the variables during
+ // bootstrap. Not sure what we can do about that. But it seems
+ // harmless.
+ //
+ if (aovr)
+ rs.root_extra->amalgamation = aovr->empty () ? nullptr : &*aovr;
+ else if (av && (av->null || av->empty ()))
rs.root_extra->amalgamation = nullptr;
{
@@ -1005,6 +1015,13 @@ namespace build2
fail << "variable " << *ctx.var_amalgamation << " expected as a "
<< "second line in " << bf;
}
+
+ // Replace the value if overridden.
+ //
+ // Note that root_extra::amalgamation will be re-pointed below.
+ //
+ if (aovr)
+ rs.vars.assign (ctx.var_amalgamation) = move (*aovr);
}
else
{
@@ -1071,6 +1088,12 @@ namespace build2
// no been configured. In this case falling through is what we want.
}
}
+ else if (v)
+ {
+ if (cast<dir_path> (v).absolute ())
+ fail << "absolute directory in variable " << *ctx.var_amalgamation
+ << " value";
+ }
// Do additional checks if the outer root could be our amalgamation.
//
@@ -1129,6 +1152,14 @@ namespace build2
auto rp (rs.vars.insert (*ctx.var_subprojects)); // Set NULL by default.
value& v (rp.first);
+ if (!sovr)
+ {
+ if (rp.second)
+ rp.second = false; // Keep NULL.
+ else
+ v = nullptr; // Make NULL.
+ }
+
if (rp.second)
{
// No subprojects set so we need to figure out if there are any.
diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx
index b47d8dc..5a25475 100644
--- a/libbuild2/file.hxx
+++ b/libbuild2/file.hxx
@@ -182,8 +182,15 @@ namespace build2
// Bootstrap the project's root scope, the src part.
//
+ // If amalgamation is present, then use the specified directory as the
+ // amalgamation instead of discovering or extracting it from bootstrap.build
+ // (use empty directory to disable amalgamation). If subprojects is false,
+ // then do not discover or extract subprojects.
+ //
LIBBUILD2_SYMEXPORT void
- bootstrap_src (scope& root, optional<bool>& altn);
+ bootstrap_src (scope& root, optional<bool>& altn,
+ optional<dir_path> amalgamation = nullopt,
+ bool subprojects = true);
// Return true if this scope has already been bootstrapped, that is, the
// following calls have already been made: