From 6ad4a629e0a790ad60352a94ea25359f38700b2f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Aug 2018 20:23:06 +0200 Subject: Don't insist on install rules for non-file targets This helps with (not) installing libu*{} groups. --- build2/bin/init.cxx | 4 ++-- build2/cc/compile-rule.cxx | 2 +- build2/cc/install-rule.cxx | 4 ++-- build2/cc/install-rule.hxx | 6 ++--- build2/cc/pkgconfig.cxx | 2 +- build2/cc/types.hxx | 2 +- build2/install/rule.cxx | 57 +++++++++++++++++++++++++++++++++------------- 7 files changed, 51 insertions(+), 26 deletions(-) diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index 6d99e26..9112773 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -94,7 +94,7 @@ namespace build2 // liba{foo}: libua{foo1 foo2} // liba{foo}: bin.whole = false # Affects test but not foo1 and foo2. // - // If unspecified, defaults to false for liba{} and to true for libux{}. + // If unspecified, defaults to false for liba{} and to true for libu*{}. // vp.insert ("bin.whole", false, variable_visibility::target); @@ -411,7 +411,7 @@ namespace build2 // t.insert (); - // Note: libu*{} are not installable. + // Note: libu*{} members are not installable. // if (install_loaded) { diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx index ebd12fd..7a50170 100644 --- a/build2/cc/compile-rule.cxx +++ b/build2/cc/compile-rule.cxx @@ -3596,7 +3596,7 @@ namespace build2 // available. // // @@ MOD: BMI compatibility check. - // @@ UTL: we need to (recursively) see through libux{} (and + // @@ UTL: we need to (recursively) see through libu*{} (and // also in pkgconfig_save()). // if (bt->is_a ()) diff --git a/build2/cc/install-rule.cxx b/build2/cc/install-rule.cxx index 9e6b93f..d687903 100644 --- a/build2/cc/install-rule.cxx +++ b/build2/cc/install-rule.cxx @@ -64,8 +64,8 @@ namespace build2 if ((st && pt->is_a ()) || (at && pt->is_a ())) return pt->in (t.weak_scope ()) ? pt : nullptr; - // See through libux{}. Note that we are always in the same project - // (and thus amalgamation). + // See through to libu*{} members. Note that we are always in the same + // project (and thus amalgamation). // if (pt->is_a ()) return pt; diff --git a/build2/cc/install-rule.hxx b/build2/cc/install-rule.hxx index 25d2d08..ecca702 100644 --- a/build2/cc/install-rule.hxx +++ b/build2/cc/install-rule.hxx @@ -53,9 +53,9 @@ namespace build2 // Installation rule for libu*{}. // - // While libu*{} themselves are not installable, we need to see through - // them in case they depend on stuff that we need to install (e.g., - // headers). Note that we use the alias_rule as a base. + // While libu*{} members themselves are not installable, we need to see + // through them in case they depend on stuff that we need to install + // (e.g., headers). Note that we use the alias_rule as a base. // class libux_install_rule: public install::alias_rule, virtual common { diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index d331f7e..4a8d995 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -1345,7 +1345,7 @@ namespace build2 for (const target* pt: l.prerequisite_targets[a]) { - // @@ UTL: we need to (recursively) see through libux{} (and + // @@ UTL: we need to (recursively) see through libu*{} (and // also in search_modules()). // if (pt != nullptr && pt->is_a ()) diff --git a/build2/cc/types.hxx b/build2/cc/types.hxx index d50c067..db12356 100644 --- a/build2/cc/types.hxx +++ b/build2/cc/types.hxx @@ -96,7 +96,7 @@ namespace build2 // using lflags = uintptr_t; // To match prerequisite_target::data. - const lflags lflag_whole = 0x00000001U; // Link whole liba{}/libux{}. + const lflags lflag_whole = 0x00000001U; // Link whole liba{}/libu*}. } } diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index 266f873..67f0e86 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -20,8 +20,8 @@ namespace build2 namespace install { // Lookup the install or install.* variable. Return NULL if not found or - // if the value is the special 'false' name (which means do not install). - // T is either scope or target. + // if the value is the special 'false' name (which means do not install; + // so the result can be used as bool). T is either scope or target. // template static const P* @@ -116,7 +116,7 @@ namespace build2 // install module (and therefore has no file_rule registered). The // typical example would be the 'tests' subproject. // - // Note: not the same as lookup() above. + // Note: not the same as lookup_install() above. // auto l ((*pt)["install"]); if (l && cast (l).string () == "false") @@ -125,8 +125,19 @@ namespace build2 continue; } - build2::match (a, *pt); - pts.push_back (prerequisite_target (pt, pi)); + // If this is not a file-based target (e.g., a target group such as + // libu{}) then ignore it if there is no rule to install. + // + if (pt->is_a ()) + build2::match (a, *pt); + else if (!try_match (a, *pt).first) + { + l5 ([&]{trace << "ignoring " << *pt << " (no rule)";}); + pt = nullptr; + } + + if (pt != nullptr) + pts.push_back (prerequisite_target (pt, pi)); } return default_recipe; @@ -223,9 +234,10 @@ namespace build2 continue; } - // See if we were explicitly instructed not to touch this target. + // See if we were explicitly instructed not to touch this target + // (the same semantics as in the prerequisites match). // - // Note: not the same as lookup() above. + // Note: not the same as lookup_install() above. // auto l ((*mt)["install"]); if (l && cast (l).string () == "false") @@ -286,7 +298,7 @@ namespace build2 // un/install) we delegate to the normal update and in the second // (un/install) -- perform the test. // - if (lookup_install (t, "install") == nullptr) + if (!lookup_install (t, "install")) return noop_recipe; // In both cases, the next step is to search, match, and collect all the @@ -334,9 +346,10 @@ namespace build2 continue; } - // See if we were explicitly instructed not to touch this target. + // See if we were explicitly instructed not to touch this target (the + // same semantics as in alias_rule). // - // Note: not the same as lookup() above. + // Note: not the same as lookup_install() above. // auto l ((*pt)["install"]); if (l && cast (l).string () == "false") @@ -345,12 +358,24 @@ namespace build2 continue; } - // If the matched rule returned noop_recipe, then the target state is - // set to unchanged as an optimization. Use this knowledge to optimize - // things on our side as well since this will help a lot when updating - // static installable content (headers, documentation, etc). - // - if (!build2::match (a, *pt, unmatch::unchanged)) + if (pt->is_a ()) + { + // If the matched rule returned noop_recipe, then the target state + // is set to unchanged as an optimization. Use this knowledge to + // optimize things on our side as well since this will help a lot + // when updating static installable content (headers, documentation, + // etc). + // + if (build2::match (a, *pt, unmatch::unchanged)) + pt = nullptr; + } + else if (!try_match (a, *pt).first) + { + l5 ([&]{trace << "ignoring " << *pt << " (no rule)";}); + pt = nullptr; + } + + if (pt != nullptr) pts.push_back (prerequisite_target (pt, pi)); } -- cgit v1.1