aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scope.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/scope.cxx
parent0798dc8be4509c057e2ba62e611f53e6f873ea67 (diff)
Diagnose incorrect output directory specification
Diffstat (limited to 'libbuild2/scope.cxx')
-rw-r--r--libbuild2/scope.cxx33
1 files changed, 26 insertions, 7 deletions
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx
index 5811bd1..0d952f0 100644
--- a/libbuild2/scope.cxx
+++ b/libbuild2/scope.cxx
@@ -806,26 +806,45 @@ namespace build2
fail (loc) << "expected directory after '@'";
}
- dir_path& d (n.dir);
+ dir_path& dir (n.dir);
const dir_path& sd (src_path ());
const dir_path& od (out_path ());
- if (d.empty ())
- d = src ? sd : od; // Already dormalized.
+ if (dir.empty ())
+ dir = src ? sd : od; // Already dormalized.
else
{
- if (d.relative ())
- d = (src ? sd : od) / d;
+ if (dir.relative ())
+ dir = (src ? sd : od) / dir;
- d.normalize ();
+ dir.normalize ();
}
dir_path out;
- if (src && sd != od) // If in source build, then out must be empty.
+ if (src)
{
out = o.dir.relative () ? od / o.dir : move (o.dir);
out.normalize ();
+
+ // Make sure out and src are parallel.
+ //
+ // See similar code for prerequisites in parser::parse_dependency().
+ //
+ if (out.sub (root_->out_path ()) &&
+ dir.sub (root_->src_path ()) &&
+ out.leaf (root_->out_path ()) == dir.leaf (root_->src_path ()))
+ ;
+ else
+ // @@ TMP change warn to fail after 0.16.0 release.
+ //
+ warn (loc) << "target output directory " << out
+ << " must be parallel to source directory " << dir;
+
+ // If in source build, then out must be empty.
+ //
+ if (sd == od)
+ out.clear ();
}
o.dir = move (out); // Result.