From cd75e06a87aa74aa6968113107afa53d401d20bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Mar 2015 14:48:36 +0200 Subject: Configure/disfigure src_root saving/removing support; fsdir{} injection We can now build out-of-tree. --- build/cxx/rule.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'build/cxx') diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx index 649067e..f53dd3b 100644 --- a/build/cxx/rule.cxx +++ b/build/cxx/rule.cxx @@ -74,15 +74,20 @@ namespace build // switch (a.operation ()) { + case default_id: case update_id: search_and_match (a, t); break; case clean_id: search_and_match (a, t, t.dir); break; default: assert (false); } + // Inject dependency on the output directory. + // + inject_parent_fsdir (a, t); + // Inject additional prerequisites. For now we only do it for - // update. + // update and default. // - if (a.operation () == update_id) + if (a.operation () == update_id || a.operation () == default_id) { auto& sp (*static_cast (v)); auto& st (dynamic_cast (*sp.target)); @@ -95,7 +100,7 @@ namespace build { case perform_update_id: return &perform_update; case perform_clean_id: return &perform_clean_file; - default: return noop_recipe; + default: return default_recipe; // Forward to prerequisites. } } @@ -366,7 +371,7 @@ namespace build if (!seen_obj) seen_obj = true; } - else + else if (p.type.id != typeid (fsdir)) { level3 ([&]{trace << "unexpected prerequisite type " << p.type;}); return nullptr; @@ -547,11 +552,15 @@ namespace build pr = op; } + // Inject dependency on the output directory. + // + inject_parent_fsdir (a, t); + switch (a) { case perform_update_id: return &perform_update; case perform_clean_id: return &perform_clean_file; - default: return noop_recipe; + default: return default_recipe; // Forward to prerequisites. } } @@ -580,9 +589,11 @@ namespace build for (const prerequisite& p: t.prerequisites) { - const obj& o (dynamic_cast (*p.target)); - ro.push_back (relative_work (o.path ())); - args.push_back (ro.back ().string ().c_str ()); + if (const obj* o = dynamic_cast (p.target)) + { + ro.push_back (relative_work (o->path ())); + args.push_back (ro.back ().string ().c_str ()); + } } args.push_back (nullptr); -- cgit v1.1