From 1346f4cd0d20a5dc7e0471edbbb6ce00f2da5c18 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Jun 2021 08:34:38 +0200 Subject: Redo fallback reverse operation machinery in ad hoc recipes --- libbuild2/adhoc-rule-buildscript.cxx | 42 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'libbuild2/adhoc-rule-buildscript.cxx') diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index fe74fc6..c94b50f 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -104,43 +104,33 @@ namespace build2 os << ind << string (braces, '}'); } - bool adhoc_buildscript_rule:: - match (action a, target& t, const string&, match_extra&, - optional fb) const + optional adhoc_buildscript_rule:: + reverse_fallback (action a, const target_type& tt) const { - if (!fb) - ; - // If this is clean for a file target and we are supplying the update, - // then we will also supply the standard clean. - // - else if (a == perform_clean_id && - *fb == perform_update_id && - t.is_a ()) - ; - else - return false; - - // It's unfortunate we have to resort to this but we need to remember this - // in apply(). + // We can provide clean for a file target if we are providing update. // - t.data (fb.has_value ()); + if (a == perform_update_id && tt.is_a ()) + return perform_clean_id; - return true; + return nullopt; } recipe adhoc_buildscript_rule:: - apply (action a, target& t, match_extra& e) const + apply (action a, target& t, match_extra& me) const { - return apply (a, t, e, nullopt); + return apply (a, t, me, nullopt); } recipe adhoc_buildscript_rule:: - apply (action a, target& t, match_extra&, const optional& d) const + apply (action a, + target& t, + match_extra& me, + const optional& d) const { - // We don't support deadlines of any of these case (see below). + // We don't support deadlines for any of these cases (see below). // - if (d && (a.outer () || - t.data () || + if (d && (a.outer () || + me.fallback || (a == perform_update_id && t.is_a ()))) return empty_recipe; @@ -177,7 +167,7 @@ namespace build2 // See if we are providing the standard clean as a fallback. // - if (t.data ()) + if (me.fallback) return &perform_clean_depdb; if (a == perform_update_id && t.is_a ()) -- cgit v1.1