aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-12-03 13:47:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-12-03 16:48:07 +0200
commitb259a318223370881d5244cc38ff8a7be58e2a3e (patch)
treea65909217d5d91e31ebe891c0278546cb58ea36d /libbuild2/algorithm.cxx
parent68a27c5bca208337f5749fe1959ac21c062b77fb (diff)
Reimplement search_existing() functions via target_type::search
This allows us to automatically get the target type-specific behavior with regards to the out_only semantics (added in the previous commit) instead of passing it explicitly from each call site.
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx22
1 files changed, 13 insertions, 9 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 71bf134..8b7aa28 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -54,19 +54,21 @@ namespace build2
const target&
search (const target& t, const prerequisite_key& pk)
{
- assert (t.ctx.phase == run_phase::match);
+ context& ctx (t.ctx);
+
+ assert (ctx.phase == run_phase::match);
// If this is a project-qualified prerequisite, then this is import's
// business (phase 2).
//
if (pk.proj)
- return import2 (t.ctx, pk);
+ return import2 (ctx, pk);
- if (const target* pt = pk.tk.type->search (t, pk))
+ if (const target* pt = pk.tk.type->search (ctx, &t, pk))
return *pt;
if (pk.tk.out->empty ())
- return create_new_target (t.ctx, pk);
+ return create_new_target (ctx, pk);
// If this is triggered, then you are probably not passing scope to
// search() (which leads to search_existing_file() being skipped).
@@ -77,13 +79,15 @@ namespace build2
pair<target&, ulock>
search_locked (const target& t, const prerequisite_key& pk)
{
- assert (t.ctx.phase == run_phase::match && !pk.proj);
+ context& ctx (t.ctx);
+
+ assert (ctx.phase == run_phase::match && !pk.proj);
- if (const target* pt = pk.tk.type->search (t, pk))
+ if (const target* pt = pk.tk.type->search (ctx, &t, pk))
return {const_cast<target&> (*pt), ulock ()};
if (pk.tk.out->empty ())
- return create_new_target_locked (t.ctx, pk);
+ return create_new_target_locked (ctx, pk);
// If this is triggered, then you are probably not passing scope to
// search() (which leads to search_existing_file() being skipped).
@@ -96,7 +100,7 @@ namespace build2
{
return pk.proj
? import_existing (ctx, pk)
- : search_existing_target (ctx, pk, false /*out_only*/); // @@ TODO
+ : pk.tk.type->search (ctx, nullptr /* existing */, pk);
}
const target&
@@ -181,7 +185,7 @@ namespace build2
return q
? import_existing (s.ctx, pk)
- : search_existing_target (s.ctx, pk, false /*out_only*/); // @@ TODO
+ : tt->search (s.ctx, nullptr /* existing */, pk);
}
const target*