aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/bin/utility.ixx
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.ixx
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.ixx')
-rw-r--r--libbuild2/bin/utility.ixx35
1 files changed, 31 insertions, 4 deletions
diff --git a/libbuild2/bin/utility.ixx b/libbuild2/bin/utility.ixx
index 91c919b..65dffa8 100644
--- a/libbuild2/bin/utility.ixx
+++ b/libbuild2/bin/utility.ixx
@@ -6,16 +6,43 @@ namespace build2
namespace bin
{
inline ltype
- link_type (const target& t)
+ link_type (const target_type& tt)
{
bool u (false);
otype o (
- t.is_a<exe> () || (u = t.is_a<libue> ()) ? otype::e :
- t.is_a<liba> () || (u = t.is_a<libua> ()) ? otype::a :
- t.is_a<libs> () || (u = t.is_a<libus> ()) ? otype::s :
+ tt.is_a<exe> () || (u = tt.is_a<libue> ()) ? otype::e :
+ tt.is_a<liba> () || (u = tt.is_a<libua> ()) ? otype::a :
+ tt.is_a<libs> () || (u = tt.is_a<libus> ()) ? otype::s :
static_cast<otype> (0xFF));
return ltype {o, u};
}
+
+ inline pair<otype, bool>
+ link_member (lmembers lm, lorder lo)
+ {
+ bool r (true);
+
+ bool s (true);
+ switch (lo)
+ {
+ case lorder::a:
+ case lorder::a_s:
+ s = false; // Fall through.
+ case lorder::s:
+ case lorder::s_a:
+ {
+ if (s ? !lm.s : !lm.a)
+ {
+ if (lo == lorder::a_s || lo == lorder::s_a)
+ s = !s;
+ else
+ r = false; // Not available.
+ }
+ }
+ }
+
+ return make_pair (s ? otype::s : otype::a, r);
+ }
}
}