aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/search.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-20 10:21:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-20 10:21:21 +0200
commitd74b2a50c421bd4a0fd8753848d3796029fcff43 (patch)
tree77fd540dd35920a56d1ee5fc4cdf3496f413e879 /libbuild2/search.cxx
parent0798dc8be4509c057e2ba62e611f53e6f873ea67 (diff)
Diagnose incorrect output directory specification
Diffstat (limited to 'libbuild2/search.cxx')
-rw-r--r--libbuild2/search.cxx46
1 files changed, 36 insertions, 10 deletions
diff --git a/libbuild2/search.cxx b/libbuild2/search.cxx
index 19385b0..c2f7de4 100644
--- a/libbuild2/search.cxx
+++ b/libbuild2/search.cxx
@@ -58,8 +58,11 @@ namespace build2
else
{
o = pk.scope->out_path ();
- o /= *tk.out;
- o.normalize ();
+ if (!tk.out->current ())
+ {
+ o /= *tk.out;
+ o.normalize ();
+ }
}
// Drop out if it is the same as src (in-src build).
@@ -169,11 +172,7 @@ namespace build2
// will be from the src tree.
//
// In the other two cases we use the prerequisite's out (in case it is
- // relative, we need to complete it, which is @@ OUT TODO). Note that we
- // blindly trust the user's value which can be used for some interesting
- // tricks, for example:
- //
- // ../cxx{foo}@./
+ // relative, we need to complete it).
//
dir_path out;
@@ -183,7 +182,24 @@ namespace build2
out = out_src (d, *s->root_scope ());
}
else
- out = *tk.out;
+ {
+ if (tk.out->absolute ())
+ out = *tk.out; // Already normalized.
+ else
+ {
+ out = pk.scope->out_path ();
+ if (!tk.out->current ())
+ {
+ out /= *tk.out;
+ out.normalize ();
+ }
+ }
+
+ // Drop out if it is the same as src (in-src build).
+ //
+ if (out == d)
+ out.clear ();
+ }
// Find or insert. Note that we are using our updated extension.
//
@@ -235,8 +251,13 @@ namespace build2
//
// More often insert than find, so skip find in insert().
//
- // @@ OUT: same story as in search_existing_target() re out.
+ // @@ OUT: same story as in search_existing_target() re out. Maybe not:
+ // if out is present, then it means the target is in src and we
+ // shouldn't be creating new targets in src, should we? Feels
+ // like this should not even be called in out is not empty.
//
+ //assert (tk.out->empty ()); @@ TMP
+
auto r (ctx.targets.insert (*tk.type,
move (d),
*tk.out,
@@ -279,8 +300,13 @@ namespace build2
//
// More often insert than find, so skip find in insert_locked().
//
- // @@ OUT: same story as in search_existing_target() re out.
+ // @@ OUT: same story as in search_existing_target() re out. Maybe not:
+ // if out is present, then it means the target is in src and we
+ // shouldn't be creating new targets in src, should we? Feels
+ // like this should not even be called in out is not empty.
//
+ //assert (tk.out->empty ()); @@ TMP
+
auto r (ctx.targets.insert_locked (*tk.type,
move (d),
*tk.out,