From 14485a1ebe8daccf80498efbb0b88a6ab2021fa2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Feb 2022 11:16:53 +0200 Subject: Add ability to override amalgamation and subprojects in bootstrap_src() --- libbuild2/file.cxx | 35 +++++++++++++++++++++++++++++++++-- libbuild2/file.hxx | 9 ++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) (limited to 'libbuild2') 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& altn) + bootstrap_src (scope& rs, optional& altn, + optional 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 (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 (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& altn); + bootstrap_src (scope& root, optional& altn, + optional amalgamation = nullopt, + bool subprojects = true); // Return true if this scope has already been bootstrapped, that is, the // following calls have already been made: -- cgit v1.1