aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-09-24 10:48:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-09-24 10:59:45 +0200
commita414fa7b0ff469013598ca9ef2999ca6293ee7c1 (patch)
treed0b5b74d026f16a6eec64c4a84f82bb76162f48c /libbuild2/module.cxx
parent9eb84a8134c532029b9f74ced48696994d9c7fc5 (diff)
Add post-boot module function
Diffstat (limited to 'libbuild2/module.cxx')
-rw-r--r--libbuild2/module.cxx27
1 files changed, 24 insertions, 3 deletions
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index 14cf183..b2b4036 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -652,10 +652,11 @@ namespace build2
fail (loc) << "build system module " << mod << " should not be loaded "
<< "during bootstrap";
- lm.push_back (module_state {loc, mod, mf->init, nullptr, nullopt});
+ lm.push_back (
+ module_state {loc, mod, nullptr, mf->init, nullptr, nullopt});
i = lm.end () - 1;
- module_boot_extra e {nullptr, module_boot_init::before};
+ module_boot_extra e {nullptr, nullptr, module_boot_init::before};
// Note: boot() can load additional modules invalidating the iterator.
//
@@ -666,12 +667,31 @@ namespace build2
if (e.module != nullptr)
i->module = move (e.module);
+ i->boot_post = e.post;
i->boot_init = e.init;
}
rs.assign (rs.var_pool ().insert (mod + ".booted")) = (mf != nullptr);
}
+ void
+ boot_post_module (scope& rs, module_state& s)
+ {
+ module_boot_post_extra e {s.module, *s.boot_init};
+
+ // Note: boot_post() should be loading any additional modules.
+ //
+ s.boot_post (rs, s.loc, e);
+
+ if (e.module != s.module)
+ {
+ assert (s.module == nullptr);
+ s.module = move (e.module);
+ }
+
+ s.boot_init = e.init;
+ }
+
module_state*
init_module (scope& rs,
scope& bs,
@@ -697,7 +717,8 @@ namespace build2
fail (loc) << "build system module " << mod << " should be loaded "
<< "during bootstrap";
- lm.push_back (module_state {loc, mod, mf->init, nullptr, nullopt});
+ lm.push_back (
+ module_state {loc, mod, nullptr, mf->init, nullptr, nullopt});
i = lm.end () - 1;
}
}