aboutsummaryrefslogtreecommitdiff
path: root/build/cxx/rule.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build/cxx/rule.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 (