From 9ce886d010dee58e5d3e547df84da487fd1c4220 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Jul 2020 08:40:42 +0200 Subject: Skip sources of executables in cc::install_rule Failed that, they may pull headers via an ad hoc group. --- libbuild2/cc/install-rule.cxx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/install-rule.cxx b/libbuild2/cc/install-rule.cxx index 17cf4ab..dc10543 100644 --- a/libbuild2/cc/install-rule.cxx +++ b/libbuild2/cc/install-rule.cxx @@ -82,15 +82,26 @@ namespace build2 // Note that if they come from a group, then we assume the entire // group is not to be installed. // + // We also skip sources since they may "pull" a header if they are a + // member of an ad hoc group. + // + auto header_source = [this] (const auto& p) + { + return (x_header (p) || + p.is_a (x_src) || + (x_mod != nullptr && p.is_a (*x_mod))); + }; + if (t.is_a ()) { - if (x_header (p)) + if (header_source (p)) pt = nullptr; else if (p.type.see_through) { for (i.enter_group (); i.group (); ) { - if (x_header (*++i)) + ++i; // Note that we have to iterate until the end of the group. + if (pt != nullptr && header_source (*i)) pt = nullptr; } } @@ -300,15 +311,23 @@ namespace build2 if (pt == nullptr) return pt; + auto header_source = [this] (const auto& p) + { + return (x_header (p) || + p.is_a (x_src) || + (x_mod != nullptr && p.is_a (*x_mod))); + }; + if (t.is_a ()) { - if (x_header (p)) + if (header_source (p)) pt = nullptr; else if (p.type.see_through) { for (i.enter_group (); i.group (); ) { - if (x_header (*++i)) + ++i; + if (pt != nullptr && header_source (*i)) pt = nullptr; } } -- cgit v1.1