From d0d4486702b045852dca36008746afeb8754ae85 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 1 Nov 2023 11:50:08 +0200 Subject: Tighten/optimize cleaning of fsdir{} during match --- libbuild2/algorithm.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libbuild2/algorithm.cxx') diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 4ec4db5..1f2d88b 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -3137,7 +3137,14 @@ namespace build2 // Let's keep this as close to update_during_match() semantically as // possible until we see a clear reason to deviate. - assert (a == perform_clean_id); + // We have a problem with fsdir{}: if the directory is not empty because + // there are other targets that depend on it and we execute it here and + // now, it will not remove the directory (because it's not yet empty) but + // will cause the target to be in the executed state, which means that + // when other targets try to execute it, it will be a noop and the + // directory will be left behind. + + assert (a == perform_clean_id && !t.is_a ()); target_state os (t.matched_state (a)); @@ -3194,6 +3201,8 @@ namespace build2 { const target& pt (*p.target); + assert (!pt.is_a ()); // See above. + target_state os (pt.matched_state (a)); if (os != target_state::unchanged) -- cgit v1.1