From ce8a94e6a76097ef7eeb34df4257991a20599712 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Jan 2015 11:39:21 +0200 Subject: Track file extension in target, prerequisite --- build/algorithm.cxx | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'build/algorithm.cxx') diff --git a/build/algorithm.cxx b/build/algorithm.cxx index 419bfaf..1d7f215 100644 --- a/build/algorithm.cxx +++ b/build/algorithm.cxx @@ -45,13 +45,34 @@ namespace build // auto r ( targets.emplace ( - unique_ptr (p.type.factory (p.name, move (d))))); + unique_ptr (p.type.factory (move (d), p.name, p.ext)))); + + target& t (**r.first); trace (4, [&]{ - tr << (r.second ? "new" : "existing") << " target " << **r.first + tr << (r.second ? "new" : "existing") << " target " << t << " for prerequsite " << p;}); - return (p.target = r.first->get ()); + // Update extension if the existing target has it unspecified. + // + if (t.ext != p.ext) + { + trace (4, [&]{ + tracer::record r (tr); + r << "assuming target " << t << " is the same as the one with "; + if (p.ext == nullptr) + r << "unspecified extension"; + else if (p.ext->empty ()) + r << "no extension"; + else + r << "extension " << *p.ext; + }); + + if (p.ext != nullptr) + t.ext = p.ext; + } + + return (p.target = &t); } bool -- cgit v1.1