aboutsummaryrefslogtreecommitdiff
path: root/build2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-08 17:07:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-08 17:07:27 +0200
commitc865883666028da1982b082a0754cc4a261afd27 (patch)
tree1ea2b0e188366f0b04f3eaacddbfd62ef32ab980 /build2/algorithm.cxx
parent86576cdd3c8d959ffe93f49b7744a99164f172ee (diff)
Add dependency on fsdir{} in alias rules
This makes sure that a directory with only dir{} target gets cleaned up.
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r--build2/algorithm.cxx30
1 files changed, 16 insertions, 14 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx
index 51d2725..59a7800 100644
--- a/build2/algorithm.cxx
+++ b/build2/algorithm.cxx
@@ -305,31 +305,33 @@ namespace build2
}
fsdir*
- inject_parent_fsdir (action a, target& t)
+ inject_fsdir (action a, target& t, bool parent)
{
- tracer trace ("inject_parent_fsdir");
+ tracer trace ("inject_fsdir");
- scope& s (t.base_scope ());
- scope* rs (s.root_scope ());
+ scope& bs (t.base_scope ());
+ scope* rs (bs.root_scope ());
- if (rs == nullptr) // Could be outside any project.
+ // Handle the outside of any project and at root scope cases.
+ //
+ if (rs == nullptr || &bs == rs)
return nullptr;
- const dir_path& out_root (rs->out_path ());
-
- // If t is a directory (name is empty), say foo/bar/, then
- // t is bar and its parent directory is foo/.
+ // 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 (t.name.empty () ? t.dir.directory () : t.dir);
+ const dir_path& d (parent && t.name.empty () ? t.dir.directory () : t.dir);
- if (!d.sub (out_root))
+ // Handle the src = out and (again) root scope cases.
+ //
+ if (d.sub (rs->src_path ()) || d == rs->out_path ())
return nullptr;
- l6 ([&]{trace << "for " << t;});
+ l6 ([&]{trace << d << " for " << t;});
- // Target in the out tree, so out directory is empty.
+ // Target is in the out tree, so out directory is empty.
//
- fsdir* r (&search<fsdir> (d, dir_path (), string (), nullptr, &s));
+ fsdir* r (&search<fsdir> (d, dir_path (), string (), nullptr, nullptr));
match (a, *r);
t.prerequisite_targets.emplace_back (r);
return r;