aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/search.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-12-11 07:07:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-12-11 07:07:36 +0200
commit3074c5e1409ad49c0793db6384ecbc6ac4ed33a9 (patch)
tree256d707b43c3139fc7591d7ebd2a6c85456bc90b /libbuild2/search.cxx
parentb971493841a601041cac1f680e3828e8d223e6f2 (diff)
Add search_locked() versions of search() functions
Diffstat (limited to 'libbuild2/search.cxx')
-rw-r--r--libbuild2/search.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/libbuild2/search.cxx b/libbuild2/search.cxx
index 2b10e0b..b341c85 100644
--- a/libbuild2/search.cxx
+++ b/libbuild2/search.cxx
@@ -243,4 +243,44 @@ namespace build2
<< " for prerequisite " << pk;});
return t;
}
+
+ pair<target&, ulock>
+ create_new_target_locked (context& ctx, const prerequisite_key& pk)
+ {
+ tracer trace ("create_new_target_locked");
+
+ const target_key& tk (pk.tk);
+
+ // We default to the target in this directory scope.
+ //
+ dir_path d;
+ if (tk.dir->absolute ())
+ d = *tk.dir; // Already normalized.
+ else
+ {
+ d = pk.scope->out_path ();
+
+ if (!tk.dir->empty ())
+ {
+ d /= *tk.dir;
+ d.normalize ();
+ }
+ }
+
+ // Find or insert.
+ //
+ // @@ OUT: same story as in search_existing_target() re out.
+ //
+ auto r (ctx.targets.insert_locked (*tk.type,
+ move (d),
+ *tk.out,
+ *tk.name,
+ tk.ext,
+ target_decl::prereq_new,
+ trace));
+
+ l5 ([&]{trace << (r.second ? "new" : "existing") << " target " << r.first
+ << " for prerequisite " << pk;});
+ return r;
+ }
}