aboutsummaryrefslogtreecommitdiff
path: root/build2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-23 20:07:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-23 20:07:26 +0200
commit4402d5fc6002769210bf06c97f6a3cc97f6e30ee (patch)
treeb1cf3e59a6f1a21a56d5a9878cb65e9bef619653 /build2/algorithm.cxx
parent8f9ace8452b04bb8de2dec3af96ce241400e3e96 (diff)
Add perform_clean_group(), use instead of ad hoc implementation in cli rule
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r--build2/algorithm.cxx28
1 files changed, 26 insertions, 2 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx
index 174c395..14c1960 100644
--- a/build2/algorithm.cxx
+++ b/build2/algorithm.cxx
@@ -1425,12 +1425,36 @@ namespace build2
target_state
perform_clean (action a, const target& t)
{
- return clean_extra (a, dynamic_cast<const file&> (t), {nullptr});
+ return clean_extra (a, t.as<file> (), {nullptr});
}
target_state
perform_clean_depdb (action a, const target& t)
{
- return clean_extra (a, dynamic_cast<const file&> (t), {".d"});
+ return clean_extra (a, t.as<file> (), {".d"});
+ }
+
+ target_state
+ perform_clean_group (action a, const target& xg)
+ {
+ const mtime_target& g (xg.as<mtime_target> ());
+ const group_view& gv (g.group_members (a));
+
+ // Similar logic to clean_extra() above.
+ //
+ target_state r (target_state::unchanged);
+ for (size_t i (0); i != gv.count; ++i)
+ {
+ if (const target* m = gv.members[i])
+ {
+ if (rmfile (m->as<file> ().path (), *m))
+ r |= target_state::changed;
+ }
+ }
+
+ g.mtime (timestamp_nonexistent);
+
+ r |= reverse_execute_prerequisites (a, g);
+ return r;
}
}