From 9fa4b867890dfaa3fa086affec23049826765dfe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Mar 2017 13:58:15 +0200 Subject: Fix clean logic --- build2/algorithm.cxx | 24 ++++++++++++++---------- build2/rule.cxx | 8 +++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 728fb14..d981af0 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -693,22 +693,26 @@ namespace build2 { tracer trace ("inject_fsdir"); - const scope& bs (t.base_scope ()); + // If t is a directory (name is empty), say foo/bar/, then t is bar and + // its parent directory is foo/. + // + const dir_path& d (parent && t.name.empty () ? t.dir.directory () : t.dir); + + const scope& bs (scopes.find (d)); const scope* rs (bs.root_scope ()); - // Handle the outside of any project case. Note that we also used to bail - // our of this is the root of the project. But that proved not to be such - // a great idea in case of subprojects (e.g., tests/). + // If root scope is NULL, then this can mean that we are out of any + // project or if the directory is in src_root. In both cases we don't + // inject anything. + // + // Note that we also used to bail out if this is the root of the + // project. But that proved not to be such a great idea in case of + // subprojects (e.g., tests/). // if (rs == nullptr) return nullptr; - // If t is a directory (name is empty), say foo/bar/, then t is bar and - // its parent directory is foo/. - // - const dir_path& d (parent && t.name.empty () ? t.dir.directory () : t.dir); - - // Handle the src = out. + // Handle the src_root = out_root. // if (d.sub (rs->src_path ())) return nullptr; diff --git a/build2/rule.cxx b/build2/rule.cxx index dd508d0..53f723b 100644 --- a/build2/rule.cxx +++ b/build2/rule.cxx @@ -153,12 +153,10 @@ namespace build2 recipe fsdir_rule:: apply (action a, target& t) const { - // Inject dependency on the parent directory. Note that we don't do it for - // clean since we shouldn't (and can't possibly, since it's our parent) be - // removing it. It also must be first (see perform_update_direct()). + // Inject dependency on the parent directory. Note that it must be first + // (see perform_update_direct()). // - if (a.operation () != clean_id) - inject_fsdir (a, t); + inject_fsdir (a, t); match_prerequisites (a, t); -- cgit v1.1