aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/bin/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-16 09:43:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-16 10:51:49 +0200
commitaf73b1603d851dcb2ce7ae84bd57df0c2f9a716d (patch)
tree2c59bbf5ecdb2b5cec2f8f656ee3f7b13bc1b97b /libbuild2/bin/utility.cxx
parentecfae2da0b23631cee3e723a562f64f8aace6879 (diff)
Add $bin.link_member() function
Given a linker output target type ("exe", "lib[as]", or "libu[eas]") return the target type of lib{} group member ("liba" or "libs") that will be picked when linking a lib{} group to this target type.
Diffstat (limited to 'libbuild2/bin/utility.cxx')
-rw-r--r--libbuild2/bin/utility.cxx27
1 files changed, 6 insertions, 21 deletions
diff --git a/libbuild2/bin/utility.cxx b/libbuild2/bin/utility.cxx
index 8032b79..6b0c4de 100644
--- a/libbuild2/bin/utility.cxx
+++ b/libbuild2/bin/utility.cxx
@@ -87,29 +87,14 @@ namespace build2
group_view gv (resolve_members (a, l));
assert (gv.members != nullptr);
- lorder lo (li.order);
+ pair<otype, bool> r (
+ link_member (lmembers {l.a != nullptr, l.s != nullptr}, li.order));
- bool ls (true);
- switch (lo)
- {
- case lorder::a:
- case lorder::a_s:
- ls = false; // Fall through.
- case lorder::s:
- case lorder::s_a:
- {
- if (ls ? l.s == nullptr : l.a == nullptr)
- {
- if (lo == lorder::a_s || lo == lorder::s_a)
- ls = !ls;
- else
- fail << (ls ? "shared" : "static") << " variant of " << l
- << " is not available";
- }
- }
- }
+ if (!r.second)
+ fail << (r.first == otype::s ? "shared" : "static")
+ << " variant of " << l << " is not available";
- return ls ? static_cast<const target*> (l.s) : l.a;
+ return r.first == otype::s ? static_cast<const target*> (l.s) : l.a;
}
}