From d3b4636ca3f4c3ad98c8096326c5b1460d05691d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Oct 2023 12:33:34 +0200 Subject: Add inject_fsdir_direct(), fsdir_rule::perform_clean_direct() functions --- libbuild2/rule.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libbuild2/rule.cxx') diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index 0d6ec8c..13dd467 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -366,6 +366,8 @@ namespace build2 // Don't fail if we couldn't remove the directory because it is not empty // (or is current working directory). In this case rmdir() will issue a // warning when appropriate. + + // The same code as in perform_clean_direct() below. // target_state ts (rmdir (t.dir, t, t.ctx.current_diag_noise ? 1 : 2) ? target_state::changed @@ -377,6 +379,23 @@ namespace build2 return ts; } + void fsdir_rule:: + perform_clean_direct (action a, const target& t) + { + // The same code as in perform_clean() above. + // + rmdir (t.dir, t, t.ctx.current_diag_noise ? 1 : 2); + + // Then clean the parent directory. If present, it is always first. + // + const target* p (t.prerequisite_targets[a].empty () + ? nullptr + : t.prerequisite_targets[a][0]); + + if (p != nullptr && p->is_a ()) + perform_clean_direct (a, *p); + } + const fsdir_rule fsdir_rule::instance; // noop_rule -- cgit v1.1