From a414fa7b0ff469013598ca9ef2999ca6293ee7c1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Sep 2020 10:48:45 +0200 Subject: Add post-boot module function --- libbuild2/module.cxx | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'libbuild2/module.cxx') 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; } } -- cgit v1.1