From 8f8ab1e8f6d85748547c0d0e9987eed4f3c3e17b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Apr 2015 15:08:05 +0200 Subject: Add support for target groups, use to handle obj/obja/objso object targets --- build/prerequisite | 55 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'build/prerequisite') diff --git a/build/prerequisite b/build/prerequisite index 77e04c2..b845f03 100644 --- a/build/prerequisite +++ b/build/prerequisite @@ -9,9 +9,12 @@ #include #include #include // move +#include #include +#include // reference_wrapper #include +#include #include // extension_pool #include @@ -19,7 +22,28 @@ namespace build { class scope; class target; - class target_type; + + // Light-weight (by being shallow-pointing) prerequsite key, similar + // to (and based on) target key. + // + class prerequisite_key + { + public: + typedef build::scope scope_type; + + target_key tk; + mutable scope_type* scope; + }; + + inline bool + operator< (const prerequisite_key& x, const prerequisite_key& y) + { + assert (x.scope == y.scope); + return x.tk < y.tk; + } + + std::ostream& + operator<< (std::ostream&, const prerequisite_key&); class prerequisite { @@ -34,7 +58,7 @@ namespace build const std::string* e, scope_type& s) : type (t), dir (std::move (d)), name (std::move (n)), ext (e), - scope (s), target (0) {} + scope (s), target (nullptr) {} public: const target_type_type& type; @@ -42,15 +66,32 @@ namespace build const std::string name; const std::string* ext; // NULL if unspecified. scope_type& scope; - target_type* target; // NULL if not yet resolved. + target_type* target; // NULL if not yet resolved. Note that this should + // always be the "primary target", not a member of + // a target group. + public: + // Prerequisite (target) type. + // + template + bool + is_a () const {return type.id == typeid (T);} }; - std::ostream& - operator<< (std::ostream&, const prerequisite&); + inline bool + operator< (const prerequisite& x, const prerequisite& y) + { + return prerequisite_key {&x.type, &x.dir, &x.name, &x.ext, &x.scope} < + prerequisite_key {&y.type, &y.dir, &y.name, &y.ext, &y.scope}; + } - bool - operator< (const prerequisite&, const prerequisite&); + inline std::ostream& + operator<< (std::ostream& os, const prerequisite& p) + { + return os << prerequisite_key {&p.type, &p.dir, &p.name, &p.ext, &p.scope}; + } + // Set of prerequisites in a scope. + // struct prerequisite_set: std::set { std::pair -- cgit v1.1