aboutsummaryrefslogtreecommitdiff
path: root/build2/search.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-11-22 11:31:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-11-22 11:31:35 +0200
commit6cb9d0e810c3336106b6c1f3c8a80cdec6fbdcf0 (patch)
treeeb2475162e91e81fded9645df54d6e199c6c3fc5 /build2/search.cxx
parent1a2ea6db0d5de8c5cabb4fedc845ce9e72cccff0 (diff)
Fix dist bug where missing source file would be silently ignored
Diffstat (limited to 'build2/search.cxx')
-rw-r--r--build2/search.cxx33
1 files changed, 24 insertions, 9 deletions
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;