From f93038fbee1631b95922b0742e0fd00fa8dae02e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Jan 2017 15:25:26 +0200 Subject: Add notion of phase, enforce --- build2/algorithm.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'build2/algorithm.cxx') diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 6c812f3..1e7a1b8 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -22,6 +22,8 @@ namespace build2 target& search (const prerequisite_key& pk) { + assert (phase == run_phase::search_match); + // If this is a project-qualified prerequisite, then this is import's // business. // @@ -37,6 +39,8 @@ namespace build2 target& search (name n, scope& s) { + assert (phase == run_phase::search_match); + optional ext; const target_type* tt (s.find_target_type (n, ext)); @@ -52,6 +56,36 @@ namespace build2 return search (*tt, n.dir, dir_path (), n.value, ext, &s, n.proj); } + target* + search_existing (const name& cn, scope& s, const dir_path& out) + { + assert (phase == run_phase::search_match || phase == run_phase::execute); + + // We don't handle this for now. + // + if (cn.qualified ()) + return nullptr; + + name n (cn); + optional ext; + const target_type* tt (s.find_target_type (n, ext)); + + // For now we treat an unknown target type as an unknown target. Seems + // logical. + // + if (tt == nullptr) + return nullptr; + + if (!n.dir.empty ()) + n.dir.normalize (false, true); // Current dir collapses to an empty one. + + // @@ OUT: for now we assume the prerequisite's out is undetermined. + // Would need to pass a pair of names. + // + return search_existing_target ( + prerequisite_key {n.proj, {tt, &n.dir, &out, &n.value, ext}, &s}); + } + pair match_impl (slock& ml, action a, target& t, bool apply, const rule* skip) { -- cgit v1.1