aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-08-16 10:30:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-08-16 10:30:35 +0200
commitd91e48ea57b83f7018a25d3f54bba96cf889d66d (patch)
treeaa6376de69751ae0488febc8fb4faed041699687 /libbuild2/file.cxx
parent50bf3956c88ee6341d0023a421d502d604e3da4f (diff)
Add ability to initialize bootstrapped modules after loading root.build
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r--libbuild2/file.cxx28
1 files changed, 23 insertions, 5 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 171d136..252f885 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -1446,17 +1446,25 @@ namespace build2
if (scope* rs = root.parent_scope ()->root_scope ())
load_root (*rs);
- // Finish off initializing bootstrapped modules.
+ // Finish off initializing bootstrapped modules (before mode).
//
- for (auto& s: root.root_extra->modules)
+ // Note that init() can load additional modules invalidating iterators.
+ //
+ size_t boot_mods (root.root_extra->modules.size ());
+
+ for (size_t i (0); i != boot_mods; ++i)
{
- if (s.boot && s.first)
+ module_state& s (root.root_extra->modules[i]);
+
+ if (s.boot_init && *s.boot_init == module_boot_init::before_first)
init_module (root, root, s.name, s.loc);
}
- for (auto& s: root.root_extra->modules)
+ for (size_t i (0); i != boot_mods; ++i)
{
- if (s.boot && !s.first)
+ module_state& s (root.root_extra->modules[i]);
+
+ if (s.boot_init && *s.boot_init == module_boot_init::before)
init_module (root, root, s.name, s.loc);
}
@@ -1482,6 +1490,16 @@ namespace build2
if (fe) {source_once (p, root, root, f, root);}
if (he) {p.reset (); source_hooks (p, root, hd, false /* pre */);}
+ // Finish off initializing bootstrapped modules (after mode).
+ //
+ for (size_t i (0); i != boot_mods; ++i)
+ {
+ module_state& s (root.root_extra->modules[i]);
+
+ if (s.boot_init && *s.boot_init == module_boot_init::after)
+ init_module (root, root, s.name, s.loc);
+ }
+
// Print the project configuration report, similar to how we do it in
// build system modules.
//