diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-26 16:03:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-04-02 12:07:38 +0200 |
commit | b3bc26dc284cf73e97b88c9979d49368d07e686c (patch) | |
tree | 59ab65ede17e84b2fa463a4d27eaaa92fd0f8b85 /libbuild2/file.cxx | |
parent | 5f768f4f3e6e9e1b7310a0e8b09a97bf6d0115ea (diff) |
Add support for propagating project environment
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r-- | libbuild2/file.cxx | 37 |
1 files changed, 32 insertions, 5 deletions
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<bool> 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<bool> 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); |