From 1bb564a690e2661094e9071d4003638390a5a6fe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Feb 2018 12:02:32 +0200 Subject: Fix test and install rules to handle see-through groups correctly --- build2/test/rule.cxx | 71 +++++++++++++++++++++++----------------------------- build2/test/rule.hxx | 25 ++++++++++-------- 2 files changed, 45 insertions(+), 51 deletions(-) (limited to 'build2/test') diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx index bc4060d..7c55445 100644 --- a/build2/test/rule.cxx +++ b/build2/test/rule.cxx @@ -56,11 +56,37 @@ namespace build2 // ---------------------------------------+-------------+--------- // test test (& pass) | pass | noop // + auto& pts (t.prerequisite_targets[a]); - // If we are passing-through, then match our prerequisites. + // Resolve group members. // - // Note that we may already have stuff in prerequisite_targets (see - // group_rule). + if (!see_through || t.type ().see_through) + { + // Remember that we are called twice: first during update for test + // (pre-operation) and then during test. During the former, we rely on + // the normall update rule to resolve the group members. During the + // latter, there will be no rule to do this but the group will already + // have been resolved by the pre-operation. + // + // If the rule could not resolve the group, then we ignore it. + // + group_view gv (a.outer () + ? resolve_group_members (a, t) + : t.group_members (a)); + + if (gv.members != nullptr) + { + for (size_t i (0); i != gv.count; ++i) + { + if (const target* m = gv.members[i]) + pts.push_back (m); + } + + match_members (a, t, pts); + } + } + + // If we are passing-through, then match our prerequisites. // if (t.is_a () && pass (t)) { @@ -74,7 +100,6 @@ namespace build2 match_prerequisites (a, t, t.root_scope ()); } - auto& pts (t.prerequisite_targets[a]); size_t pass_n (pts.size ()); // Number of pass-through prerequisites. // See if it's testable and if so, what kind. @@ -153,8 +178,8 @@ namespace build2 test = false; else { - // Look for test input/stdin/stdout prerequisites. The same - // group logic as in the testscript case above. + // Look for test input/stdin/stdout prerequisites. The same group + // reasoning as in the testscript case above. // for (prerequisite_member p: group_prerequisite_members (a, t, members_mode::maybe)) @@ -274,40 +299,6 @@ namespace build2 } } - recipe group_rule:: - apply (action a, target& t) const - { - // Resolve group members. - // - // Remember that we are called twice: first during update for test - // (pre-operation) and then during test. During the former, we rely on - // the normall update rule to resolve the group members. During the - // latter, there will be no rule to do this but the group will already - // have been resolved by the pre-operation. - // - // If the rule could not resolve the group, then we ignore it. - // - group_view gv (a.outer () - ? resolve_group_members (a, t) - : t.group_members (a)); - - if (gv.members != nullptr) - { - auto& pts (t.prerequisite_targets[a]); - for (size_t i (0); i != gv.count; ++i) - { - if (const target* m = gv.members[i]) - pts.push_back (m); - } - - match_members (a, t, pts); - } - - // Delegate to the base rule. - // - return rule::apply (a, t); - } - target_state rule:: perform_update (action a, const target& t) { diff --git a/build2/test/rule.hxx b/build2/test/rule.hxx index b331263..4f02390 100644 --- a/build2/test/rule.hxx +++ b/build2/test/rule.hxx @@ -20,9 +20,6 @@ namespace build2 class rule: public build2::rule, protected virtual common { public: - explicit - rule (common_data&& d): common (move (d)) {} - virtual bool match (action, target&, const string&) const override; @@ -37,26 +34,32 @@ namespace build2 target_state perform_script (action, const target&, size_t) const; + + rule (common_data&& d, bool see_through_only) + : common (move (d)), see_through (see_through_only) {} + + bool see_through; }; - class default_rule: public rule // For disambiguation in module. + class default_rule: public rule { public: explicit - default_rule (common_data&& d): common (move (d)), rule (move (d)) {} + default_rule (common_data&& d) + : common (move (d)), + rule (move (d), true /* see_through_only */) {} }; - // In addition to the above rule's semantics, this rule sees through to - // the group's members. + // To be used for non-see-through groups that should exhibit the see- + // through behavior for install (see lib{} in the bin module for an + // example). // class group_rule: public rule { public: explicit - group_rule (common_data&& d): common (move (d)), rule (move (d)) {} - - virtual recipe - apply (action, target&) const override; + group_rule (common_data&& d) + : common (move (d)), rule (move (d), false /* see_through_only */) {} }; } } -- cgit v1.1