From 7b9eb752cad04aaadc4552d0f26d307b04af1869 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Feb 2017 08:09:53 +0200 Subject: Pass const target& to recipes --- build2/cc/utility.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'build2/cc/utility.cxx') diff --git a/build2/cc/utility.cxx b/build2/cc/utility.cxx index 5c5d1fec..4ccdcafe 100644 --- a/build2/cc/utility.cxx +++ b/build2/cc/utility.cxx @@ -38,6 +38,37 @@ namespace build2 : v.size () > 1 && v[1] == "shared" ? lorder::a_s : lorder::a; } + const target& + link_member (const bin::lib& l, lorder lo) + { + bool ls (true); + const string& at (cast (l["bin.lib"])); // Available members. + + switch (lo) + { + case lorder::a: + case lorder::a_s: + ls = false; // Fall through. + case lorder::s: + case lorder::s_a: + { + if (ls ? at == "static" : at == "shared") + { + if (lo == lorder::a_s || lo == lorder::s_a) + ls = !ls; + else + assert (false); + } + } + } + + target* r (ls ? static_cast (l.s) : l.a); + + assert (r != nullptr); + + return *r; + } + target& link_member (bin::lib& l, lorder lo) { -- cgit