From c414abe13450e2b4e204f6368ba83c8916de1ebd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2018 08:23:06 +0200 Subject: Minor code reuse improvement --- build2/config/operation.cxx | 41 ++--------------------------------------- build2/file.cxx | 2 +- build2/file.hxx | 9 +++++---- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index ddbfc79..1e1ec94 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -419,43 +419,6 @@ namespace build2 // disfigure // - static void - bootstrap_project (scope& root) - { - if (auto l = root.vars[var_subprojects]) - { - const dir_path& out_root (root.out_path ()); - const dir_path& src_root (root.src_path ()); - - for (auto p: cast (l)) - { - const dir_path& pd (p.second); - - // Create and bootstrap subproject's root scope. - // - dir_path out_nroot (out_root / pd); - - // The same logic for src_root as in create_bootstrap_inner(). - // - scope& nroot (create_root (root, out_nroot, dir_path ())->second); - - if (!bootstrapped (nroot)) - { - bootstrap_out (nroot); - - value& val (nroot.assign (var_src_root)); - - if (!val) - val = is_src_root (out_nroot) ? out_nroot : (src_root / pd); - - setup_root (nroot); - bootstrap_src (nroot); - } - - bootstrap_project (nroot); - } - } - } static operation_id disfigure_operation_pre (const values&, operation_id o) @@ -479,9 +442,9 @@ namespace build2 // Since we don't load buildfiles during disfigure but still want to // disfigure all the subprojects (see disfigure_project() below), we - // bootstrap all known subprojects. + // bootstrap all the known subprojects. // - bootstrap_project (root); + create_bootstrap_inner (root); } static void diff --git a/build2/file.cxx b/build2/file.cxx index 5ffa59a..b0d202c 100644 --- a/build2/file.cxx +++ b/build2/file.cxx @@ -829,7 +829,7 @@ namespace build2 { dir_path out_root (root.out_path () / p.second); - if (!out_base.sub (out_root)) + if (!out_base.empty () && !out_base.sub (out_root)) continue; // The same logic to src_root as in create_bootstrap_outer(). diff --git a/build2/file.hxx b/build2/file.hxx index f334d8c..a720d50 100644 --- a/build2/file.hxx +++ b/build2/file.hxx @@ -141,12 +141,13 @@ namespace build2 void create_bootstrap_outer (scope& root); - // Create and bootstrap inner root scopes between root and base, - // if any. Return the innermost created root scope or root if - // none were created. Loading is done by load_root_pre() below. + // Create and bootstrap inner root scopes between root and base, if any. If + // out_base is empty, then bootstrap all the way in. Return the innermost + // created root scope or root if none were created. Note: loading is done by + // load_root_pre() below. // scope& - create_bootstrap_inner (scope& root, const dir_path& out_base); + create_bootstrap_inner (scope& root, const dir_path& out_base = dir_path ()); // Load project's root[-pre].build unless already loaded. Also // make sure all outer root scopes are loaded prior to loading -- cgit v1.1