From c4fcbad1cb603756dc4dac65392feb86be1a722d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 29 Jan 2020 09:19:06 +0200 Subject: Rename module_base to module, redo module boot/init argument passing --- libbuild2/c/init.cxx | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'libbuild2/c/init.cxx') diff --git a/libbuild2/c/init.cxx b/libbuild2/c/init.cxx index a220169..5939d4c 100644 --- a/libbuild2/c/init.cxx +++ b/libbuild2/c/init.cxx @@ -131,10 +131,9 @@ namespace build2 guess_init (scope& rs, scope& bs, const location& loc, - unique_ptr& mod, bool, bool, - const variable_map& hints) + module_init_extra& extra) { tracer trace ("c::guess_init"); l5 ([&]{trace << "for " << bs;}); @@ -258,10 +257,9 @@ namespace build2 // vp.insert_alias (d.c_runtime, "c.runtime"); - assert (mod == nullptr); - config_module* m (new config_module (move (d))); - mod.reset (m); - m->guess (rs, loc, hints); + auto& m (extra.set_module (new config_module (move (d)))); + m.guess (rs, loc, extra.hints); + return true; } @@ -269,10 +267,9 @@ namespace build2 config_init (scope& rs, scope& bs, const location& loc, - unique_ptr&, bool, bool, - const variable_map& hints) + module_init_extra& extra) { tracer trace ("c::config_init"); l5 ([&]{trace << "for " << bs;}); @@ -282,11 +279,11 @@ namespace build2 if (&rs != &bs) fail (loc) << "c.config module must be loaded in project root"; - // Load c.guess. + // Load c.guess and share its module instance as ours. // - auto& cm (load_module (rs, rs, "c.guess", loc, hints)); + extra.module = load_module (rs, rs, "c.guess", loc, extra.hints); + extra.module_as ().init (rs, loc, extra.hints); - cm.init (rs, loc, hints); return true; } @@ -307,10 +304,9 @@ namespace build2 init (scope& rs, scope& bs, const location& loc, - unique_ptr& mod, bool, bool, - const variable_map& hints) + module_init_extra& extra) { tracer trace ("c::init"); l5 ([&]{trace << "for " << bs;}); @@ -322,11 +318,8 @@ namespace build2 // Load c.config. // - // @@ TODO: move guess to config and use return value? - // - load_module (rs, rs, "c.config", loc, hints); - - config_module& cm (*rs.find_module ("c.guess")); + auto& cm ( + load_module (rs, rs, "c.config", loc, extra.hints)); cc::data d { cm, @@ -363,10 +356,9 @@ namespace build2 inc }; - assert (mod == nullptr); - module* m; - mod.reset (m = new module (move (d))); - m->init (rs, loc, hints); + auto& m (extra.set_module (new module (move (d)))); + m.init (rs, loc, extra.hints); + return true; } -- cgit v1.1