aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-10-23 10:25:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-10-26 13:29:24 +0200
commitc9e9432018b57b7f532480415059ff62d7f96a40 (patch)
treedef2115528d809b510f276b393b1587c68e40572
parenta0ebf29806f7ce066f7815f79c08ae4cb73be865 (diff)
WIP: add rematch_*() functions
-rw-r--r--libbuild2/algorithm.hxx24
-rw-r--r--libbuild2/algorithm.ixx28
2 files changed, 51 insertions, 1 deletions
diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx
index e01fbb8..829c5be 100644
--- a/libbuild2/algorithm.hxx
+++ b/libbuild2/algorithm.hxx
@@ -363,7 +363,9 @@ namespace build2
// to be unchanged after match. If it is unmatch::safe, then unmatch the
// target if it is safe (this includes unchanged or if we know that someone
// else will execute this target). Return true in first half of the pair if
- // unmatch succeeded. Always throw if failed.
+ // unmatch succeeded. Always throw if failed. Note that unmatching doesn't
+ // play well with options -- if unmatch succeeds, the options that have been
+ // passed to match will not be cleared.
//
enum class unmatch {none, unchanged, safe};
@@ -483,6 +485,26 @@ namespace build2
unmatch,
uint64_t options = match_extra::all_options);
+ // Re-match with new options a target that has already been matched with one
+ // of the match_*() functions. Note that natually you cannot rematch a
+ // target that you have unmatched.
+ //
+ target_state
+ rematch_sync (action, const target&,
+ uint64_t options,
+ bool fail = true);
+
+ target_state
+ rematch_async (action, const target&,
+ uint64_t options,
+ size_t start_count, atomic_count& task_count,
+ bool fail = true);
+
+ target_state
+ rematch_complete (action, const target&,
+ uint64_t options,
+ bool fail = true);
+
// The standard prerequisite search and match implementations. They call
// search() (unless a custom is provided) and then match() (unless custom
// returned NULL) for each prerequisite in a loop omitting out of project
diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx
index 813c685..f9992c9 100644
--- a/libbuild2/algorithm.ixx
+++ b/libbuild2/algorithm.ixx
@@ -675,6 +675,34 @@ namespace build2
return match_sync (a.inner_action (), t, um, options);
}
+ // Note: rematch is basically normal match but without the counts increment,
+ // so we just delegate to match_direct_*().
+ //
+ inline target_state
+ rematch_sync (action a, const target& t,
+ uint64_t options,
+ bool fail)
+ {
+ return match_direct_sync (a, t, fail, options);
+ }
+
+ inline target_state
+ rematch_async (action a, const target& t,
+ uint64_t options,
+ size_t start_count, atomic_count& task_count,
+ bool fail)
+ {
+ return match_async (a, t, start_count, task_count, fail, options);
+ }
+
+ inline target_state
+ rematch_complete (action a, const target& t,
+ uint64_t options,
+ bool fail)
+ {
+ return match_direct_complete (a, t, fail, options);
+ }
+
LIBBUILD2_SYMEXPORT void
resolve_group_impl (target_lock&&);