diff options
Diffstat (limited to 'libbuild2/bin/utility.ixx')
-rw-r--r-- | libbuild2/bin/utility.ixx | 35 |
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); + } } } |