aboutsummaryrefslogtreecommitdiff
path: root/build/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-14 11:39:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-14 11:39:21 +0200
commitce8a94e6a76097ef7eeb34df4257991a20599712 (patch)
tree5e83b9d083f486a6efe889102f7c2a815e6a06c6 /build/cxx
parentab4421747146aa7995f0cfb1a639c9121c82c915 (diff)
Track file extension in target, prerequisite
Diffstat (limited to 'build/cxx')
-rw-r--r--build/cxx/rule.cxx27
1 files changed, 24 insertions, 3 deletions
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<prerequisite&> (*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 (