From eb000f6aa31f48b36ad2fcd09d14559f43106ca2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Nov 2021 08:16:29 +0200 Subject: Incorporate derived target types into generated header logic --- libbuild2/cc/compile-rule.cxx | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 62391f3..6258ce8 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -1551,12 +1551,12 @@ namespace build2 // Reverse-lookup target type(s) from extension. // small_vector compile_rule:: - map_extension (const scope& s, const string& n, const string& e) const + map_extension (const scope& bs, const string& n, const string& e) const { // We will just have to try all of the possible ones, in the "most // likely to match" order. // - auto test = [&s, &n, &e] (const target_type& tt) -> bool + auto test = [&bs, &n, &e] (const target_type& tt) -> bool { // Call the extension derivation function. Here we know that it will // only use the target type and name from the target key so we can @@ -1566,7 +1566,7 @@ namespace build2 // This is like prerequisite search. // - optional de (tt.default_extension (tk, s, nullptr, true)); + optional de (tt.default_extension (tk, bs, nullptr, true)); return de && *de == e; }; @@ -1577,6 +1577,28 @@ namespace build2 if (test (**p)) r.push_back (*p); + // Next try target types derived from any of the C-source types. + // + const target_type_map& ttm (bs.root_scope ()->root_extra->target_types); + + for (auto i (ttm.type_begin ()), e (ttm.type_end ()); i != e; ++i) + { + const target_type& dt (i->second); + + for (const target_type* const* p (x_inc); *p != nullptr; ++p) + { + const target_type& bt (**p); + + if (dt.is_a (bt)) + { + if (dt != bt && test (dt)) + r.push_back (&dt); + + break; + } + } + } + return r; } -- cgit v1.1