From 99116592590c0face4ec37a2e0308e9c3a2f98dd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Jul 2015 18:53:19 +0200 Subject: Fix bugs in dependency extraction code --- build/cxx/compile.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'build') diff --git a/build/cxx/compile.cxx b/build/cxx/compile.cxx index 4095598..ae1ebe2 100644 --- a/build/cxx/compile.cxx +++ b/build/cxx/compile.cxx @@ -212,8 +212,16 @@ namespace build { tracer trace ("cxx::append_prefixes"); + // If this target does not belong to any project (e.g, an + // "imported as installed" library), then it can't possibly + // generate any headers for us. + // + scope* rs (t.base_scope ().root_scope ()); + if (rs == nullptr) + return; + const dir_path& out_base (t.dir); - const dir_path& out_root (t.root_scope ().path ()); + const dir_path& out_root (rs->path ()); if (auto val = t[var]) { @@ -558,9 +566,13 @@ namespace build { const dir_path& d (f.directory ()); i = pm.upper_bound (d); - --i; // Greatest less than. - if (!d.sub (i->first)) // We might still not be a sub. + // Get the greatest less than, if any. We might + // still not be a sub. Note also that we still + // have to check the last element is upper_bound() + // returned end(). + // + if (i == pm.begin () || !d.sub ((--i)->first)) i = pm.end (); } -- cgit v1.1