From c106259517d7693ea8e24564bc890fe575d5edcd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Jan 2015 14:11:14 +0200 Subject: Implement rule chaining for cxx::link --- build/prerequisite.cxx | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'build/prerequisite.cxx') diff --git a/build/prerequisite.cxx b/build/prerequisite.cxx index 370f5d0..f5461ef 100644 --- a/build/prerequisite.cxx +++ b/build/prerequisite.cxx @@ -9,6 +9,7 @@ #include #include // target_type #include +#include using namespace std; @@ -72,4 +73,45 @@ namespace build x.directory == y.directory && x.ext != nullptr && y.ext != nullptr && x.ext < y.ext); } + + // prerequisite_set + // + auto prerequisite_set:: + insert (const target_type& tt, + path dir, + std::string name, + const std::string* ext, + scope& s, + tracer& tr) -> pair + { + //@@ OPT: would be nice to somehow first check if this prerequisite is + // already in the set before allocating a new instance. + + // Find or insert. + // + auto r (emplace (tt, move (dir), move (name), ext, s)); + prerequisite& p (const_cast (*r.first)); + + // Update extension if the existing prerequisite has it unspecified. + // + if (p.ext != ext) + { + trace (4, [&]{ + tracer::record r (tr); + r << "assuming prerequisite " << p << " is the same as the " + << "one with "; + if (ext == nullptr) + r << "unspecified extension"; + else if (ext->empty ()) + r << "no extension"; + else + r << "extension " << *ext; + }); + + if (ext != nullptr) + p.ext = ext; + } + + return pair (p, r.second); + } } -- cgit v1.1