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/target.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'build/target.cxx') diff --git a/build/target.cxx b/build/target.cxx index 61423db..b20f53b 100644 --- a/build/target.cxx +++ b/build/target.cxx @@ -4,9 +4,8 @@ #include -#include - #include +#include using namespace std; @@ -37,7 +36,50 @@ namespace build return os; } + // target_set + // + auto target_set:: + insert (const target_type& tt, + path dir, + std::string name, + const std::string* ext, + tracer& tr) -> pair + { + //@@ OPT: would be nice to somehow first check if this target is + // already in the set before allocating a new instance. + + // Find or insert. + // + auto r ( + emplace ( + unique_ptr (tt.factory (move (dir), move (name), ext)))); + + target& t (**r.first); + + // Update the extension if the existing target has it unspecified. + // + if (t.ext != ext) + { + trace (4, [&]{ + tracer::record r (tr); + r << "assuming target " << t << " 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) + t.ext = ext; + } + + return pair (t, r.second); + } + target_set targets; + target* default_target = nullptr; target_type_map target_types; -- cgit v1.1