From 87a7253a3bd82b59063172f3799b0a5587e7b2a5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 2 Apr 2024 08:03:55 +0200 Subject: Detect and diagnose attempt to create new target in src directory GitHub issue #277. --- libbuild2/dyndep.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libbuild2/dyndep.cxx') diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx index 68260fb..dbeb47e 100644 --- a/libbuild2/dyndep.cxx +++ b/libbuild2/dyndep.cxx @@ -442,7 +442,7 @@ namespace build2 // which case return the target that would have been inserted. // // The directory is only moved from if insert is true. Note that it must - // be normalized. + // be absolute and normalized. // auto find = [&trace, what, &bs, &t, &map_extension, @@ -632,7 +632,7 @@ namespace build2 // // 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. + // example, it may defer the failure to the tool diagnostics. // #if 0 r = &search (t, *tts[0], d, out, n, &e, s); @@ -642,7 +642,11 @@ namespace build2 r = pk.tk.type->search (ctx, &t, pk); if (r == nullptr && pk.tk.out->empty ()) - r = &create_new_target (ctx, pk); + { + auto p (ctx.scopes.find (d, false)); + if (*p.first != nullptr || ++p.first == p.second) + r = &create_new_target (ctx, pk); + } #endif } -- cgit v1.1