From 5974cab56148a18628bfb423189e016ade2d40f9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 31 Aug 2015 13:45:57 +0200 Subject: Rework scoping logic Now the src directory is entered into the scope map and points to the same scope as out. This means that targets that are in src, not out (e.g., source files) will "see" rules, variables, etc. This becomes important when we try, for example, to install a source file (say, a header) from src: we need the rule as well as the install.* variables. --- build/config/module.cxx | 6 +++++- build/config/operation.cxx | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'build/config') diff --git a/build/config/module.cxx b/build/config/module.cxx index 5ecf2d3..74bcec4 100644 --- a/build/config/module.cxx +++ b/build/config/module.cxx @@ -42,7 +42,7 @@ namespace build return; } - const dir_path& out_root (r.path ()); + const dir_path& out_root (r.out_path ()); level4 ([&]{trace << "for " << out_root;}); // Register meta-operations. @@ -52,7 +52,11 @@ namespace build // Register alias and fallback rule for the configure meta-operation. // + global_scope->rules.insert ( + configure_id, 0, "file", file_rule::instance); + r.rules.insert (configure_id, 0, "alias", alias_rule::instance); + r.rules.insert (configure_id, 0, "", fallback_rule::instance); r.rules.insert (configure_id, 0, "", fallback_rule::instance); // Load config.build if one exists. diff --git a/build/config/operation.cxx b/build/config/operation.cxx index b1c6239..424fd46 100644 --- a/build/config/operation.cxx +++ b/build/config/operation.cxx @@ -65,7 +65,7 @@ namespace build static void save_config (scope& root) { - const dir_path& out_root (root.path ()); + const dir_path& out_root (root.out_path ()); path f (out_root / config_file); text << (verb ? "config::save_config " : "save ") << f; @@ -134,7 +134,7 @@ namespace build { tracer trace ("configure_project"); - const dir_path& out_root (root.path ()); + const dir_path& out_root (root.out_path ()); const dir_path& src_root (root.src_path ()); // Make sure the directories exist. @@ -179,7 +179,7 @@ namespace build // @@ Strictly speaking we need to check whether the config // module was loaded for this subproject. // - if (nroot.path () != out_nroot) // This subproject was not loaded. + if (nroot.out_path () != out_nroot) // This subproject not loaded. continue; configure_project (a, nroot); @@ -273,7 +273,7 @@ namespace build action_targets& ts) { tracer trace ("disfigure_search"); - level5 ([&]{trace << "collecting " << root.path ();}); + level5 ([&]{trace << "collecting " << root.out_path ();}); ts.push_back (&root); } @@ -287,7 +287,7 @@ namespace build bool m (false); // Keep track of whether we actually did anything. - const dir_path& out_root (root.path ()); + const dir_path& out_root (root.out_path ()); const dir_path& src_root (root.src_path ()); // Disfigure subprojects. Since we don't load buildfiles during @@ -313,7 +313,7 @@ namespace build if (!val) val = is_src_root (out_nroot) ? out_nroot : (src_root / pd); - nroot.src_path_ = &as (val); + setup_root (nroot); bootstrap_src (nroot); @@ -398,7 +398,7 @@ namespace build // target& t ( targets.insert ( - dir::static_type, root.path (), "", nullptr, trace).first); + dir::static_type, root.out_path (), "", nullptr, trace).first); if (!quiet) info << diag_done (a, t); -- cgit v1.1