diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-08-22 14:16:56 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-08-22 14:16:56 +0200 |
commit | 151b9cf30d11a014503b0a060a6bb7875c509adf (patch) | |
tree | 2fdf884b232bc8886a8e3f0f3027b21897b1be66 /libbuild2/cc | |
parent | 18e079b37794dc97b6c51045476bf43296b56dd3 (diff) |
Consider *_inc{} target types as headers for rule match purposes
Diffstat (limited to 'libbuild2/cc')
-rw-r--r-- | libbuild2/cc/common.hxx | 17 | ||||
-rw-r--r-- | libbuild2/cc/compile-rule.cxx | 8 | ||||
-rw-r--r-- | libbuild2/cc/link-rule.cxx | 7 | ||||
-rw-r--r-- | libbuild2/cc/module.cxx | 6 | ||||
-rw-r--r-- | libbuild2/cc/pkgconfig.cxx | 4 |
5 files changed, 24 insertions, 18 deletions
diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx index eefcc0d..d7caeb9 100644 --- a/libbuild2/cc/common.hxx +++ b/libbuild2/cc/common.hxx @@ -223,6 +223,7 @@ namespace build2 // const target_type& x_src; // Source target type (c{}, cxx{}). const target_type* x_mod; // Module target type (mxx{}), if any. + const target_type& x_inc; // Includable base target type (e.g., c_inc{}). const target_type* x_obj; // Objective-X target type (m{}, mm{}). const target_type* x_asp; // Assembler with CPP target type (S{}). @@ -250,7 +251,7 @@ namespace build2 // (excluding h{} except for C). Keep them in the most likely to appear // order with the "real header" first and terminated with NULL. // - const target_type* const* x_hdr; + const target_type* const* x_hdrs; // Check if an object (target, prerequisite, etc) is a header. // @@ -258,7 +259,7 @@ namespace build2 bool x_header (const T& t, bool c_hdr = true) const { - for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) + for (const target_type* const* ht (x_hdrs); *ht != nullptr; ++ht) if (t.is_a (**ht)) return true; @@ -269,7 +270,7 @@ namespace build2 // extensions to target types. Keep them in the most likely to appear // order and terminate with NULL. // - const target_type* const* x_inc; + const target_type* const* x_incs; // Aggregate-like constructor with from-base support. // @@ -297,8 +298,9 @@ namespace build2 size_t sle, size_t she, const target_type& src, const target_type* mod, - const target_type* const* hdr, - const target_type* const* inc) + const target_type& inc, + const target_type* const* hdrs, + const target_type* const* incs) : config_data (cd), x_compile (compile), x_link (link), @@ -318,8 +320,9 @@ namespace build2 sys_lib_dirs_mode (slm), sys_hdr_dirs_mode (shm), sys_mod_dirs_mode (smm), sys_lib_dirs_extra (sle), sys_hdr_dirs_extra (she), - x_src (src), x_mod (mod), x_obj (nullptr), x_asp (nullptr), - x_hdr (hdr), x_inc (inc) {} + x_src (src), x_mod (mod), x_inc (inc), + x_obj (nullptr), x_asp (nullptr), + x_hdrs (hdrs), x_incs (incs) {} }; class LIBBUILD2_CC_SYMEXPORT common: public data diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index fa46332..35d77f8 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -483,8 +483,8 @@ namespace build2 // For a header unit we check the "real header" plus the C header. // - if (ut == unit_type::module_header ? p.is_a (**x_hdr) || p.is_a<h> () : - ut == unit_type::module_intf ? p.is_a (*x_mod) : + if (ut == unit_type::module_header ? p.is_a (**x_hdrs) || p.is_a<h> () : + ut == unit_type::module_intf ? p.is_a (*x_mod) : p.is_a (x_src) || (x_asp != nullptr && p.is_a (*x_asp)) || (x_obj != nullptr && p.is_a (*x_obj))) @@ -3091,7 +3091,7 @@ namespace build2 // single "version" of a header. Seems reasonable. // // Note also that while it would have been nice to have a unified cc - // cache, the map_extension() call is passed x_inc which is module- + // cache, the map_extension() call is passed x_incs which is module- // specific. In other words, we may end up mapping the same header to // two different targets depending on whether it is included from, say, // C or C++ translation unit. We could have used a unified cache for @@ -3155,7 +3155,7 @@ namespace build2 fp, cache, norm, [this] (const scope& bs, const string& n, const string& e) { - return map_extension (bs, n, e, x_inc); + return map_extension (bs, n, e, x_incs); }, h::static_type, [this, &d] (action a, const scope& bs, const target& t) diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index e47a40d..58359aa 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -436,9 +436,12 @@ namespace build2 r.seen_lib = true; } // Some other c-common header/source (say C++ in a C rule) other than - // a C header (we assume everyone can hanle that). + // a C header (we assume everyone can hanle that) or some other + // #include'able target. // - else if (p.is_a<cc> () && !(x_header (p, true /* c_hdr */))) + else if (p.is_a<cc> () && + !(x_header (p, true /* c_hdr */)) && + !p.is_a (x_inc) && !p.is_a<c_inc> ()) { r.seen_cc = true; break; diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index f33ddf4..3e756c4 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -994,14 +994,14 @@ namespace build2 install_path (rs, tt, dir_path ("include")); }; - // Note: module (x_mod) is in x_hdr. + // Note: module (x_mod) is in x_hdrs. // - for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) + for (const target_type* const* ht (x_hdrs); *ht != nullptr; ++ht) insert_hdr (**ht); // Also register the C header for C-derived languages. // - if (*x_hdr != &h::static_type) + if (*x_hdrs != &h::static_type) insert_hdr (h::static_type); rs.insert_target_type<pc> (); diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx index 362e867..f04876b 100644 --- a/libbuild2/cc/pkgconfig.cxx +++ b/libbuild2/cc/pkgconfig.cxx @@ -1331,7 +1331,7 @@ namespace build2 // We treat headers outside of any project as C headers (see // enter_header() for details). // - parse_headers (ipc, h::static_type /* **x_hdr */, x, prs); + parse_headers (ipc, h::static_type /* **x_hdrs */, x, prs); parse_headers (ipc, h::static_type, "c", prs); } @@ -2266,7 +2266,7 @@ namespace build2 move (pp), symexport}); } - else if (pt->is_a (**x_hdr) || pt->is_a<h> ()) + else if (pt->is_a (**this->x_hdrs) || pt->is_a<h> ()) { if (cast_false<bool> ((*pt)[c_importable])) { |