From 6016250ee9d6753e4363e138f049845b8dd10d30 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Jun 2023 12:13:09 +0200 Subject: Don't fail in dyndep_rule::enter_file() if target is in src --- libbuild2/dyndep.cxx | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx index 1b2002a..7fe38d1 100644 --- a/libbuild2/dyndep.cxx +++ b/libbuild2/dyndep.cxx @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -430,6 +431,8 @@ namespace build2 // NOTE: see enter_header() caching logic if changing anyting here with // regards to the target and base scope usage. + assert (!insert || t.ctx.phase == run_phase::match); + // Find or maybe insert the target. // // If insert is false, then don't consider dynamically-created targets @@ -446,6 +449,8 @@ namespace build2 bool insert, bool dynamic = false) -> const file* { + context& ctx (t.ctx); + // Split the file into its name part and extension. Here we can assume // the name part is a valid filesystem name. // @@ -504,7 +509,7 @@ namespace build2 } else { - const scope& bs (**t.ctx.scopes.find (d).first); + const scope& bs (**ctx.scopes.find (d).first); if (const scope* rs = bs.root_scope ()) { if (map_extension != nullptr) @@ -558,7 +563,7 @@ namespace build2 { const target_type& tt (*tts[i]); - if (const target* x = t.ctx.targets.find (tt, d, out, n, e, trace)) + if (const target* x = ctx.targets.find (tt, d, out, n, e, trace)) { // What would be the harm in reusing a dynamically-inserted target // if there is no buildfile-mentioned one? Probably none (since it @@ -619,10 +624,25 @@ namespace build2 r = f; } - // @@ OPT: move d, out, n - // if (r == nullptr && insert) + { + // Like search(t, pk) but don't fail if the target is in src. + // + // While it may seem like there is not much difference, the caller may + // actually do more than just issue more specific diagnostics. For + // example, if may defer the failure to the tool diagnostics. + // +#if 0 r = &search (t, *tts[0], d, out, n, &e, s); +#else + prerequisite_key pk {nullopt, {tts[0], &d, &out, &n, move (e)}, s}; + + r = pk.tk.type->search (t, pk); + + if (r == nullptr && pk.tk.out->empty ()) + r = &create_new_target (ctx, pk); +#endif + } return static_cast (r); }; -- cgit v1.1