aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.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/parser.cxx
parent0798dc8be4509c057e2ba62e611f53e6f873ea67 (diff)
Diagnose incorrect output directory specification
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index a13dc41..d167200 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -2491,7 +2491,7 @@ namespace build2
// Current dir collapses to an empty one.
//
if (!n.dir.empty ())
- n.dir.normalize (false, true);
+ n.dir.normalize (false /* actual */, true);
// @@ OUT: for now we assume the prerequisite's out is undetermined. The
// only way to specify an src prerequisite will be with the explicit
@@ -2514,6 +2514,29 @@ namespace build2
fail (ploc) << "expected directory after '@'";
o.dir.normalize (); // Note: don't collapse current to empty.
+
+ // Make sure out and src are parallel.
+ //
+ // See similar code for targets in scope::find_target_type().
+ //
+ // For now we require that both are either relative or absolute.
+ //
+ if (n.dir.empty () && o.dir.current ())
+ ;
+ else if (o.dir.relative () &&
+ n.dir.relative () &&
+ o.dir == n.dir)
+ ;
+ else if (o.dir.absolute () &&
+ n.dir.absolute () &&
+ o.dir.sub (root_->out_path ()) &&
+ n.dir.sub (root_->src_path ()) &&
+ o.dir.leaf (root_->out_path ()) ==
+ n.dir.leaf (root_->src_path ()))
+ ;
+ else
+ fail (ploc) << "prerequisite output directory " << o.dir
+ << " must be parallel to source directory " << n.dir;
}
prerequisite p (move (n.proj),