aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/dyndep.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-04-02 08:03:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-04-02 08:03:55 +0200
commit87a7253a3bd82b59063172f3799b0a5587e7b2a5 (patch)
treee99ea1139bea536f02865fc9fcd06486676c0f73 /libbuild2/dyndep.cxx
parentcede94e8190ead8d2bc311e82348119d9abbfc3d (diff)
Detect and diagnose attempt to create new target in src directory
GitHub issue #277.
Diffstat (limited to 'libbuild2/dyndep.cxx')
-rw-r--r--libbuild2/dyndep.cxx10
1 files changed, 7 insertions, 3 deletions
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
}