From 4c1b2f072bcc41c00990331245e479a55b0990ff Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Feb 2022 11:15:36 +0200 Subject: Factor reusable code to contex::enter_project_overrides() --- build2/b.cxx | 57 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'build2') diff --git a/build2/b.cxx b/build2/b.cxx index bb09675..c094523 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -1580,62 +1580,7 @@ main (int argc, char* argv[]) // boundaries (specifically, amalgamation) are only known after // bootstrap. // - // The mildly tricky part here is to distinguish the situation where - // we are bootstrapping the same project multiple times. The first - // override that we set cannot already exist (because the override - // variable names are unique) so if it is already set, then it can - // only mean this project is already bootstrapped. - // - // This is further complicated by the project vs amalgamation logic - // (we may have already done the amalgamation but not the project). - // So we split it into two passes. - // - { - auto& sm (ctx.scopes.rw ()); - - for (const variable_override& o: ctx.var_overrides) - { - if (o.ovr.visibility != variable_visibility::global) - continue; - - // If we have a directory, enter the scope, similar to how we do - // it in the context ctor. - // - scope& s ( - o.dir - ? *sm.insert_out ((out_base / *o.dir).normalize ())->second.front () - : *rs.weak_scope ()); - - auto p (s.vars.insert (o.ovr)); - - if (!p.second) - break; - - value& v (p.first); - v = o.val; - } - - for (const variable_override& o: ctx.var_overrides) - { - // Ours is either project (%foo) or scope (/foo). - // - if (o.ovr.visibility == variable_visibility::global) - continue; - - scope& s ( - o.dir - ? *sm.insert_out ((out_base / *o.dir).normalize ())->second.front () - : rs); - - auto p (s.vars.insert (o.ovr)); - - if (!p.second) - break; - - value& v (p.first); - v = o.val; - } - } + ctx.enter_project_overrides (rs, out_base, ctx.var_overrides); ts.root_scope = &rs; ts.out_base = move (out_base); -- cgit v1.1