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/cxx/rule.cxx | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'build/cxx') diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx index 1d2a2c4..c6ceb1a 100644 --- a/build/cxx/rule.cxx +++ b/build/cxx/rule.cxx @@ -211,19 +211,40 @@ namespace build // @@ TODO: // - // Split the name into its directory part and the name part. - // Here we assume the name part is a valid filesystem name. + // Split the name into its directory part, the name part, and + // extension. Here we can assume the name part is a valid + // filesystem name. // path d (file.directory ()); string n (file.leaf ().base ().string ()); + const char* es (file.extension ()); + const string* e (&extension_pool.find (es != nullptr ? es : "")); // Find or insert. // auto r (ds.prerequisites.emplace ( - hxx::static_type, move (n), move (d), ds)); + hxx::static_type, move (d), move (n), e, ds)); auto& p (const_cast (*r.first)); + // Update extension if the existing prerequisite has it + // unspecified. + // + if (p.ext != e) + { + trace (4, [&]{ + tracer::record r (tr); + r << "assuming prerequisite " << p << " is the same as the " + << "one with "; + if (e->empty ()) + r << "no extension"; + else + r << "extension " << *e; + }); + + p.ext = e; + } + // Resolve to target so that we can assign its path. // path_target& t ( -- cgit v1.1