diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-27 15:25:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:41 +0200 |
commit | f93038fbee1631b95922b0742e0fd00fa8dae02e (patch) | |
tree | 6fe67cbde528ee8ded490085b9a8d5adc0ce5aca /build2/algorithm.cxx | |
parent | 267d34d2800d9cc3ed2865cbecf8d32f8f1ab6ec (diff) |
Add notion of phase, enforce
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r-- | build2/algorithm.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
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<string> 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<string> 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<const rule*, match_result> match_impl (slock& ml, action a, target& t, bool apply, const rule* skip) { |