diff options
-rw-r--r-- | build2/algorithm.cxx | 28 | ||||
-rw-r--r-- | build2/algorithm.hxx | 6 | ||||
-rw-r--r-- | build2/cli/rule.cxx | 31 | ||||
-rw-r--r-- | build2/cli/rule.hxx | 3 |
4 files changed, 33 insertions, 35 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; } } diff --git a/build2/algorithm.hxx b/build2/algorithm.hxx index 76e9d76..e8b9823 100644 --- a/build2/algorithm.hxx +++ b/build2/algorithm.hxx @@ -467,6 +467,12 @@ namespace build2 target_state perform_clean_depdb (action, const target&); + // As above but clean the target group. The group should be an mtime_target + // and members should be files. + // + target_state + perform_clean_group (action, const target&); + // Helper for custom perform(clean) implementations that cleans extra files // and directories (recursively) specified as a list of either absolute // paths or "path derivation directives". The directive string can be NULL, diff --git a/build2/cli/rule.cxx b/build2/cli/rule.cxx index 9e925b3..83774a3 100644 --- a/build2/cli/rule.cxx +++ b/build2/cli/rule.cxx @@ -174,7 +174,7 @@ namespace build2 switch (a) { case perform_update_id: return &perform_update; - case perform_clean_id: return &perform_clean; + case perform_clean_id: return &perform_clean_group; // Standard impl. default: return noop_recipe; // Configure update. } } @@ -304,34 +304,5 @@ namespace build2 return target_state::changed; } - - target_state compile:: - perform_clean (action a, const target& xt) - { - const cli_cxx& t (xt.as<cli_cxx> ()); - - // The reverse order of update: first delete the files, then clean - // prerequisites. Also update timestamp in case there are operations - // after us that could use the information. - // - // @@ Can't we use clean_extra() for this? - // - bool r (false); - - if (t.i != nullptr) - r = rmfile (t.i->path (), *t.i) || r; - r = rmfile (t.c->path (), *t.c) || r; - r = rmfile (t.h->path (), *t.h) || r; - - t.mtime (timestamp_nonexistent); - - target_state ts (r ? target_state::changed : target_state::unchanged); - - // Clean prerequisites. - // - ts |= reverse_execute_prerequisites (a, t); - - return ts; - } } } diff --git a/build2/cli/rule.hxx b/build2/cli/rule.hxx index 6798a6b..9af1da4 100644 --- a/build2/cli/rule.hxx +++ b/build2/cli/rule.hxx @@ -29,9 +29,6 @@ namespace build2 static target_state perform_update (action, const target&); - - static target_state - perform_clean (action, const target&); }; } } |