diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 09:44:15 +0200 |
commit | 3cc5e3bd441fc9d18fece3d9e99fae75c78438e7 (patch) | |
tree | a9a08c453370847e0d352d47e19fbfcb7cc757ef /build2/cli/rule.cxx | |
parent | c0f72d47fc25981dcc1f55e12dfa0fdba7b70242 (diff) |
Implement support for excluded and ad hoc prerequisites
The inclusion/exclusion is controlled via the 'include' prerequisite-specific
variable. Valid values are:
false - exclude
true - include
adhoc - include but treat as an ad hoc input
For example:
lib{foo}: cxx{win32-utility}: include = ($cxx.targe.class == 'windows')
exe{bar}: libs{plugin}: include = adhoc
Diffstat (limited to 'build2/cli/rule.cxx')
-rw-r--r-- | build2/cli/rule.cxx | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/build2/cli/rule.cxx b/build2/cli/rule.cxx index f621f02..45b8185 100644 --- a/build2/cli/rule.cxx +++ b/build2/cli/rule.cxx @@ -44,41 +44,48 @@ namespace build2 } bool compile_rule:: - match (action a, target& xt, const string&) const + match (action a, target& t, const string&) const { tracer trace ("cli::compile_rule::match"); - if (cli_cxx* pt = xt.is_a<cli_cxx> ()) + // Find the .cli source file. + // + auto find = [&trace, a, &t] (auto&& r) -> optional<prerequisite_member> { - // The cli.cxx{} group. - // - cli_cxx& t (*pt); - - // See if we have a .cli source file. - // - bool r (false); - for (prerequisite_member p: group_prerequisite_members (a, t)) + for (prerequisite_member p: r) { + // If excluded or ad hoc, then don't factor it into our tests. + // + if (include (a, t, p) != include_type::normal) + continue; + if (p.is_a<cli> ()) { // Check that the stem match. // - if (!match_stem (t.name, p.name ())) - { - l4 ([&]{trace << ".cli file stem '" << p.name () << "' " - << "doesn't match target " << t;}); - return false; - } - - r = true; - break; + if (match_stem (t.name, p.name ())) + return p; + + l4 ([&]{trace << ".cli file stem '" << p.name () << "' " + << "doesn't match target " << t;}); } } - if (!r) + return nullopt; + }; + + if (cli_cxx* pt = t.is_a<cli_cxx> ()) + { + // The cli.cxx{} group. + // + cli_cxx& t (*pt); + + // See if we have a .cli source file. + // + if (!find (group_prerequisite_members (a, t))) { l4 ([&]{trace << "no .cli source file for target " << t;}); - return r; + return false; } // Figure out the member list. @@ -95,13 +102,12 @@ namespace build2 ? nullptr : &search<cxx::ixx> (t, t.dir, t.out, t.name); - return r; + return true; } else { // One of the ?xx{} members. // - target& t (xt); // Check if there is a corresponding cli.cxx{} group. // @@ -113,24 +119,13 @@ namespace build2 // if (g == nullptr || !g->has_prerequisites ()) { - for (prerequisite_member p: prerequisite_members (a, t)) + if (optional<prerequisite_member> p = find ( + prerequisite_members (a, t))) { - if (p.is_a<cli> ()) - { - // Check that the stems match. - // - if (match_stem (t.name, p.name ())) - { - if (g == nullptr) - g = &targets.insert<cli_cxx> (t.dir, t.out, t.name, trace); - - g->prerequisites (prerequisites {p.as_prerequisite ()}); - } - else - l4 ([&]{trace << ".cli file stem '" << p.name () << "' " - << "doesn't match target " << t;}); - break; - } + if (g == nullptr) + g = &targets.insert<cli_cxx> (t.dir, t.out, t.name, trace); + + g->prerequisites (prerequisites {p->as_prerequisite ()}); } } @@ -175,7 +170,7 @@ namespace build2 { case perform_update_id: return &perform_update; case perform_clean_id: return &perform_clean_group; // Standard impl. - default: return noop_recipe; // Configure update. + default: return noop_recipe; // Configure/dist update. } } else |