From ab6917b035a8431a13d85396ed15b75dabe44b36 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Apr 2020 15:11:51 +0200 Subject: Don't switch projects when switching scopes during bootstrap --- libbuild2/file.hxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'libbuild2/file.hxx') diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx index 2ca72b1..b44efb6 100644 --- a/libbuild2/file.hxx +++ b/libbuild2/file.hxx @@ -67,6 +67,15 @@ namespace build2 LIBBUILD2_SYMEXPORT pair find_out_root (const dir_path&, optional& altn); + // Project's loading stage during which the parsing is performed. + // + enum class load_stage + { + boot, // Loading bootstrap.build (or bootstrap pre/post hooks). + root, // Loading root.build (or root pre/post hooks). + rest // Loading the rest (ordinary buildfiles, command line, etc). + }; + // If buildfile is '-', then read from STDIN. // LIBBUILD2_SYMEXPORT void @@ -82,7 +91,7 @@ namespace build2 // stdin that requires parse_variable()). // LIBBUILD2_SYMEXPORT void - source (scope& root, scope& base, lexer&); + source (scope& root, scope& base, lexer&, load_stage = load_stage::rest); // As above but first check if this buildfile has already been sourced for // the base scope. Return false if the file has already been sourced. @@ -115,13 +124,14 @@ namespace build2 const dir_path& out_base, const dir_path& src_base); - // Return a scope for the specified directory (first). Note that switching - // to this scope might also involve switch to a new root scope (second) if - // the new scope is in another project. If the new scope is not in any - // project, then NULL is returned in second. + // Return a scope for the specified directory (first). If project is true + // then switching to this scope might also involve switch to a new root + // scope (second) if the new scope is in another project. If project is + // false or the new scope is not in any project, then NULL is returned in + // second. // LIBBUILD2_SYMEXPORT pair - switch_scope (scope& root, const dir_path&); + switch_scope (scope& root, const dir_path&, bool project = true); // Bootstrap and optionally load an ad hoc (sub)project (i.e., the kind that // is not discovered and loaded automatically by bootstrap/load functions -- cgit v1.1