From 59dedd5cf8ab8d4b1cae3faed952982749e6f59a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Jan 2022 08:40:34 +0200 Subject: Consider implied targets when resolving dynamic dependencies --- libbuild2/dyndep.cxx | 19 ++++++++++++------- libbuild2/target.hxx | 9 +++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx index 92e8903..0865ccb 100644 --- a/libbuild2/dyndep.cxx +++ b/libbuild2/dyndep.cxx @@ -540,25 +540,30 @@ namespace build2 if (const target* x = t.ctx.targets.find (tt, d, out, n, e, trace)) { - // What would be the harm in reusing an implied target if there is - // no real one? Probably none (since it can't be updated) except - // that it will be racy: sometimes we will reuse the implied, - // sometimes we will insert a new one. And we don't like racy. + // What would be the harm in reusing a dynamically-inserted target + // if there is no buildfile-mentioned one? Probably none (since it + // can't be updated) except that it will be racy: sometimes we + // will reuse the dynamic, sometimes we will insert a new one. And + // we don't like racy. // - if (x->decl == target_decl::real) + // Note that we can't only check for real targets and must include + // implied ones because pre-entered members of a target group + // (e.g., cli.cxx) are implied. + // + if (x->decl >= target_decl::implied) { r = x; break; } else { - // Cache the implied target corresponding to tts[0] since that's + // Cache the dynamic target corresponding to tts[0] since that's // what we will be inserting (see below). // if (insert && i == 0) f = x; - l6 ([&]{trace << "implied target with target type " << tt.name;}); + l6 ([&]{trace << "dynamic target with target type " << tt.name;}); } } else diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 4ce871b..d584023 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -137,6 +137,15 @@ namespace build2 real // Real dependency declaration. }; + inline bool + operator< (target_decl l, target_decl r) + { + return static_cast (l) < static_cast (r); + } + + inline bool + operator>= (target_decl l, target_decl r) { return !(l < r); } + class LIBBUILD2_SYMEXPORT target { public: -- cgit v1.1