From 6cb9d0e810c3336106b6c1f3c8a80cdec6fbdcf0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 Nov 2017 11:31:35 +0200 Subject: Fix dist bug where missing source file would be silently ignored --- build2/search.cxx | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'build2/search.cxx') diff --git a/build2/search.cxx b/build2/search.cxx index 892141a..a7d40c6 100644 --- a/build2/search.cxx +++ b/build2/search.cxx @@ -86,7 +86,15 @@ namespace build2 tracer trace ("search_existing_file"); const target_key& ctk (cpk.tk); - assert (ctk.dir->relative ()); + const scope* s (cpk.scope); + + if (ctk.dir->absolute ()) + { + // Bail out if not inside project's src_root. + // + if (s == nullptr || !ctk.dir->sub (s->root_scope ()->src_path ())) + return nullptr; + } // Figure out the extension. Pretty similar logic to file::derive_path(). // @@ -95,7 +103,7 @@ namespace build2 if (!ext) { if (auto f = ctk.type->extension) - ext = f (ctk, *cpk.scope, true); + ext = f (ctk, *s, true); if (!ext) { @@ -118,14 +126,21 @@ namespace build2 // Check if there is a file. // - const dir_path& s (pk.scope->src_path ()); + path f; - path f (s); - if (!tk.dir->empty ()) + if (tk.dir->absolute ()) + f = *tk.dir; // Already normalized. + else { - f /= *tk.dir; - f.normalize (); + f = s->src_path (); + + if (!tk.dir->empty ()) + { + f /= *tk.dir; + f.normalize (); + } } + f /= *tk.name; if (!ext->empty ()) @@ -163,8 +178,8 @@ namespace build2 if (tk.out->empty ()) { - if (pk.scope->out_path () != s) - out = out_src (d, *pk.scope->root_scope ()); + if (s->out_path () != s->src_path ()) + out = out_src (d, *s->root_scope ()); } else out = *tk.out; -- cgit v1.1