From a9f355062690eba4942f789ca3420c9c319ce901 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 6 May 2021 14:19:45 +0200 Subject: See through utility libraries when looking for module interfaces --- libbuild2/cc/pkgconfig.cxx | 100 +++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 44 deletions(-) (limited to 'libbuild2/cc/pkgconfig.cxx') diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx index a70e9a2..fd88b59 100644 --- a/libbuild2/cc/pkgconfig.cxx +++ b/libbuild2/cc/pkgconfig.cxx @@ -1715,66 +1715,78 @@ namespace build2 vector x_hdrs; vector c_hdrs; + // We need to (recursively) see through libu*{}. See similar logic + // in search_modules(). + // // Note that the prerequisite targets are in the member, not the // group (for now we don't support different sets of modules/headers // for static/shared library; see load above for details). // - for (const target* pt: l.prerequisite_targets[a]) + auto collect = [a, this, + &mods, + &x_hdrs, &c_hdrs] (const target& l, + const auto& collect) -> void { - if (pt == nullptr) - continue; - - // @@ UTL: we need to (recursively) see through libu*{} (and - // also in search_modules()). - // - if (modules && pt->is_a ()) + for (const target* pt: l.prerequisite_targets[a]) { - // What we have is a binary module interface. What we need is - // a module interface source it was built from. We assume it's - // the first mxx{} target that we see. - // - const target* mt (nullptr); - for (const target* t: pt->prerequisite_targets[a]) + if (pt == nullptr) + continue; + + if (modules && pt->is_a ()) { - if ((mt = t->is_a (*x_mod))) - break; - } + // What we have is a binary module interface. What we need is + // a module interface source it was built from. We assume it's + // the first mxx{} target that we see. + // + const target* mt (nullptr); + for (const target* t: pt->prerequisite_targets[a]) + { + if ((mt = t->is_a (*x_mod))) + break; + } - // Can/should there be a bmi{} without mxx{}? Can't think of a - // reason. - // - assert (mt != nullptr); + // Can/should there be a bmi{} without mxx{}? Can't think of a + // reason. + // + assert (mt != nullptr); - path p (install::resolve_file (mt->as ())); + path p (install::resolve_file (mt->as ())); - if (p.empty ()) // Not installed. - continue; + if (p.empty ()) // Not installed. + continue; - string pp; - if (const string* v = cast_null ((*mt)[x_preprocessed])) - pp = *v; - - mods.push_back ( - module { - cast (pt->state[a].vars[c_module_name]), - move (p), - move (pp), - symexport - }); - } - else if (pt->is_a (**x_hdr) || pt->is_a ()) - { - if (cast_false ((*pt)[c_importable])) + string pp; + if (const string* v = cast_null ((*mt)[x_preprocessed])) + pp = *v; + + mods.push_back ( + module { + cast (pt->state[a].vars[c_module_name]), + move (p), + move (pp), + symexport}); + } + else if (pt->is_a (**x_hdr) || pt->is_a ()) { - path p (install::resolve_file (pt->as ())); + if (cast_false ((*pt)[c_importable])) + { + path p (install::resolve_file (pt->as ())); - if (p.empty ()) // Not installed. - continue; + if (p.empty ()) // Not installed. + continue; - (pt->is_a () ? c_hdrs : x_hdrs).push_back (move (p)); + (pt->is_a () ? c_hdrs : x_hdrs).push_back (move (p)); + } } + // Note that in prerequisite targets we will have the libux{} + // members, not the group. + // + else if (pt->is_a ()) + collect (*pt, collect); } - } + }; + + collect (l, collect); if (size_t n = mods.size ()) { -- cgit v1.1