From ba8e7dccf1257fbec9c7a2eac8729fcec684a9ea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 12 Feb 2024 05:48:25 +0200 Subject: Extend class prerequisite constructors --- libbuild2/prerequisite.cxx | 4 ++-- libbuild2/prerequisite.hxx | 20 ++++++++++++++++++-- libbuild2/target.cxx | 3 +-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libbuild2/prerequisite.cxx b/libbuild2/prerequisite.cxx index 7e14c76..bb77c9e 100644 --- a/libbuild2/prerequisite.cxx +++ b/libbuild2/prerequisite.cxx @@ -54,13 +54,13 @@ namespace build2 } prerequisite:: - prerequisite (const target_type& t) + prerequisite (const target_type& t, bool locked) : proj (nullopt), type (t.type ()), dir (t.dir), out (t.out), // @@ If it's empty, then we treat as undetermined? name (t.name), - ext (to_ext (t.ext ())), + ext (to_ext (locked ? t.ext_locked () : t.ext ())), scope (t.base_scope ()), target (&t), vars (*this, false /* shared */) diff --git a/libbuild2/prerequisite.hxx b/libbuild2/prerequisite.hxx index 2f63056..9b9cccf 100644 --- a/libbuild2/prerequisite.hxx +++ b/libbuild2/prerequisite.hxx @@ -97,10 +97,26 @@ namespace build2 scope (s), vars (*this, false /* shared */) {} - // Make a prerequisite from a target. + prerequisite (const target_type_type& t, + dir_path d, + dir_path o, + string n, + optional e, + const scope_type& s) + : type (t), + dir (move (d)), + out (move (o)), + name (move (n)), + ext (move (e)), + scope (s), + vars (*this, false /* shared */) {} + + // Make a prerequisite from a target. If the second argument is true, + // assume the targets mutex is locked (see ext_locked()/key_locked() + // for background). // explicit - prerequisite (const target_type&); + prerequisite (const target_type&, bool locked = false); // Note that the returned key "tracks" the prerequisite; that is, any // updates to the prerequisite's members will be reflected in the key. diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx index 5a352a8..2e25dd3 100644 --- a/libbuild2/target.cxx +++ b/libbuild2/target.cxx @@ -1424,8 +1424,7 @@ namespace build2 if (e.type () == entry_type::directory) { r.push_back ( - prerequisite (nullopt, - dir::static_type, + prerequisite (dir::static_type, dir_path (e.path ().representation ()), // Relative. dir_path (), // In the out tree. string (), -- cgit v1.1