From d74b2a50c421bd4a0fd8753848d3796029fcff43 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Oct 2022 10:21:21 +0200 Subject: Diagnose incorrect output directory specification --- libbuild2/scope.cxx | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'libbuild2/scope.cxx') 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. -- cgit v1.1