From b37f1aa6398065be806e6605a023189685669885 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Feb 2017 03:55:15 +0200 Subject: Implement parallel match --- build2/bin/rule.cxx | 55 +++++++++++------------------------------------------ 1 file changed, 11 insertions(+), 44 deletions(-) (limited to 'build2/bin/rule.cxx') diff --git a/build2/bin/rule.cxx b/build2/bin/rule.cxx index 446f91b..3ea8e75 100644 --- a/build2/bin/rule.cxx +++ b/build2/bin/rule.cxx @@ -20,7 +20,7 @@ namespace build2 // obj // match_result obj_rule:: - match (slock&, action a, target& t, const string&) const + match (action a, target& t, const string&) const { fail << diag_doing (a, t) << " target group" << info << "explicitly select obje{}, obja{}, or objs{} member"; @@ -29,29 +29,20 @@ namespace build2 } recipe obj_rule:: - apply (slock&, action, target&) const {return empty_recipe;} + apply (action, target&) const {return empty_recipe;} // lib // // The whole logic is pretty much as if we had our two group members as // our prerequisites. // - - struct match_data - { - const string& type; - }; - - static_assert (sizeof (match_data) <= target::data_size, - "insufficient space"); - match_result lib_rule:: - match (slock&, action act, target& xt, const string&) const + match (action act, target& xt, const string&) const { lib& t (xt.as ()); - // Get the library type to build. If not set for a target, this - // should be configured at the project scope by init(). + // Get the library type to build. If not set for a target, this should + // be configured at the project scope by init(). // const string& type (cast (t["bin.lib"])); @@ -62,7 +53,8 @@ namespace build2 fail << "unknown library type: " << type << info << "'static', 'shared', or 'both' expected"; - t.data (match_data {type}); // Save in the target's auxilary storage. + t.a = a ? &search (t.dir, t.out, t.name) : nullptr; + t.s = s ? &search (t.dir, t.out, t.name) : nullptr; match_result mr (true); @@ -76,31 +68,12 @@ namespace build2 } recipe lib_rule:: - apply (slock& ml, action act, target& xt) const + apply (action act, target& xt) const { lib& t (xt.as ()); - const match_data& md (t.data ()); - const string& type (md.type); - - bool a (type == "static" || type == "both"); - bool s (type == "shared" || type == "both"); - - if (a) - { - if (t.a == nullptr) - t.a = &search (t.dir, t.out, t.name, nullptr, nullptr); - - build2::match (ml, act, *t.a); - } - - if (s) - { - if (t.s == nullptr) - t.s = &search (t.dir, t.out, t.name, nullptr, nullptr); - - build2::match (ml, act, *t.s); - } + const target* m[] = {t.a, t.s}; + match_members (act, t, m); return &perform; } @@ -110,13 +83,7 @@ namespace build2 { const lib& t (xt.as ()); - const match_data& md (t.data ()); - const string& type (md.type); - - bool a (type == "static" || type == "both"); - bool s (type == "shared" || type == "both"); - - const target* m[] = {a ? t.a : nullptr, s ? t.s : nullptr}; + const target* m[] = {t.a, t.s}; return execute_members (act, t, m); } } -- cgit v1.1