From b3bc26dc284cf73e97b88c9979d49368d07e686c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Mar 2021 16:03:29 +0200 Subject: Add support for propagating project environment --- libbuild2/file.cxx | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'libbuild2/file.cxx') diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx index 4f24dd9..e96142d 100644 --- a/libbuild2/file.cxx +++ b/libbuild2/file.cxx @@ -609,7 +609,8 @@ namespace build2 {}, /* operations */ {}, /* modules */ {}, /* override_cache */ - {}} /* target_types */); + {}, /* target_types */ + {}} /* environment */); // Enter built-in meta-operation and operation names. Loading of // modules (via the src bootstrap; see below) can result in @@ -1404,6 +1405,10 @@ namespace build2 optional altn; if (!bootstrapped (rs)) { + // Clear current project's environment. + // + auto_project_env penv (nullptr); + value& v (bootstrap_out (rs, altn)); if (!v) @@ -1494,9 +1499,16 @@ namespace build2 } }; - init_modules (module_boot_init::before_first); - init_modules (module_boot_init::before_second); - init_modules (module_boot_init::before); + { + init_modules (module_boot_init::before_first); + + // Project environment should now be in effect. + // + auto_project_env penv (root); + + init_modules (module_boot_init::before_second); + init_modules (module_boot_init::before); + } // Load hooks and root.build. // @@ -1521,7 +1533,10 @@ namespace build2 // Finish off initializing bootstrapped modules (after mode). // - init_modules (module_boot_init::after); + { + auto_project_env penv (root); + init_modules (module_boot_init::after); + } // Print the project configuration report, similar to how we do it in // build system modules. @@ -1638,6 +1653,10 @@ namespace build2 if (!bootstrapped (rs)) { + // Clear current project's environment. + // + auto_project_env penv (nullptr); + optional altn; bootstrap_out (rs, altn); setup_root (rs, forwarded); @@ -1743,6 +1762,10 @@ namespace build2 return nullopt; } + // Clear current project's environment for good measure. + // + auto_project_env penv (nullptr); + // Note: to ease handling (think patching third-party code) we will always // specify the --build2-metadata option in this single-argument form. // @@ -2339,6 +2362,10 @@ namespace build2 } } + // Clear current project's environment. + // + auto_project_env penv (nullptr); + for (const scope* proot (nullptr); ; proot = root) { bool top (proot == nullptr); -- cgit v1.1