diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-24 17:41:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-08-28 15:01:48 +0300 |
commit | 4bdf53837e010073de802070d4e6087410662d3e (patch) | |
tree | 2820d3964877d1a7d498833da325aa3d3a699353 /libbuild2/cc/utility.ixx | |
parent | ea24f530048cbce0c5335ca3fd3632c8ce34315a (diff) |
Move cc build system module to separate library
Diffstat (limited to 'libbuild2/cc/utility.ixx')
-rw-r--r-- | libbuild2/cc/utility.ixx | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/libbuild2/cc/utility.ixx b/libbuild2/cc/utility.ixx new file mode 100644 index 0000000..1509bf2 --- /dev/null +++ b/libbuild2/cc/utility.ixx @@ -0,0 +1,73 @@ +// file : libbuild2/cc/utility.ixx -*- C++ -*- +// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +namespace build2 +{ + namespace cc + { + inline otype + compile_type (const target& t, unit_type u) + { + using namespace bin; + + auto test = [&t, u] (const auto& h, const auto& i, const auto& o) + { + return t.is_a (u == unit_type::module_header ? h : + u == unit_type::module_iface ? i : + o); + }; + + return + test (hbmie::static_type, bmie::static_type, obje::static_type) ? otype::e : + test (hbmia::static_type, bmia::static_type, obja::static_type) ? otype::a : + otype::s; + } + + inline ltype + link_type (const target& t) + { + using namespace bin; + + 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 : + static_cast<otype> (0xFF)); + + return ltype {o, u}; + } + + inline compile_target_types + compile_types (otype t) + { + using namespace bin; + + const target_type* o (nullptr); + const target_type* i (nullptr); + const target_type* h (nullptr); + + switch (t) + { + case otype::e: + o = &obje::static_type; + i = &bmie::static_type; + h = &hbmie::static_type; + break; + case otype::a: + o = &obja::static_type; + i = &bmia::static_type; + h = &hbmia::static_type; + break; + case otype::s: + o = &objs::static_type; + i = &bmis::static_type; + h = &hbmis::static_type; + break; + } + + return compile_target_types {*o, *i, *h}; + } + } +} |