diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-07 08:09:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:42 +0200 |
commit | 7b9eb752cad04aaadc4552d0f26d307b04af1869 (patch) | |
tree | d19cdb450ddec384ec41d9129f8d4afecc14acb7 /build2/cc/utility.cxx | |
parent | be773edfa2c8f8f3230509bbd713542d20fbb37e (diff) |
Pass const target& to recipes
Diffstat (limited to 'build2/cc/utility.cxx')
-rw-r--r-- | build2/cc/utility.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/build2/cc/utility.cxx b/build2/cc/utility.cxx index 5c5d1fe..4ccdcaf 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<string> (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<target*> (l.s) : l.a); + + assert (r != nullptr); + + return *r; + } + target& link_member (bin::lib& l, lorder lo) { |