diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-25 17:40:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-25 17:40:21 +0200 |
commit | 32e04ad4b4a8dec07836b7c9fcf90fe72a006990 (patch) | |
tree | 8a0ce76d3a2f644396348fbf0d3d5d00bab82a0c /build2/bin/target.cxx | |
parent | 236497a013790c879e9e798bd68083252b43b057 (diff) |
Implement missing pieces in utility libraries support
In particular, we can now build static libraries out of utility libraries.
Diffstat (limited to 'build2/bin/target.cxx')
-rw-r--r-- | build2/bin/target.cxx | 108 |
1 files changed, 82 insertions, 26 deletions
diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index 0560b8e..6c62258 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -71,7 +71,7 @@ namespace build2 // running serial. For the members it is also safe to set the group during // creation. - // obj*{}, bmi*{}, libu*{} member factory. + // obj*{} and bmi*{} member factory. // template <typename M, typename G> static target* @@ -111,11 +111,11 @@ namespace build2 false }; - const target_type libue::static_type + const target_type obja::static_type { - "libue", - &libux::static_type, - &m_factory<libue, libu>, + "obja", + &objx::static_type, + &m_factory<obja, obj>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -124,11 +124,11 @@ namespace build2 false }; - const target_type obja::static_type + const target_type bmia::static_type { - "obja", - &objx::static_type, - &m_factory<obja, obj>, + "bmia", + &bmix::static_type, + &m_factory<bmia, bmi>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -137,11 +137,11 @@ namespace build2 false }; - const target_type bmia::static_type + const target_type objs::static_type { - "bmia", - &bmix::static_type, - &m_factory<bmia, bmi>, + "objs", + &objx::static_type, + &m_factory<objs, obj>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -150,11 +150,11 @@ namespace build2 false }; - const target_type libua::static_type + const target_type bmis::static_type { - "libua", - &libux::static_type, - &m_factory<libua, libu>, + "bmis", + &bmix::static_type, + &m_factory<bmis, bmi>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -163,11 +163,33 @@ namespace build2 false }; - const target_type objs::static_type + // libu*{} member factory. + // + template <typename M> + static target* + libux_factory (const target_type&, dir_path dir, dir_path out, string n) { - "objs", - &objx::static_type, - &m_factory<objs, obj>, + const target* g (targets.find<libu> (dir, out, n)); + + if (const target* g2 = targets.find<libul> (dir, out, n)) + { + if (g != 0) + fail << "both " << *g << " and " << g2 << " targets declared"; + + g = g2; + } + + M* m (new M (move (dir), move (out), move (n))); + m->group = g; + + return m; + } + + const target_type libue::static_type + { + "libue", + &libux::static_type, + &libux_factory<libue>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -176,11 +198,12 @@ namespace build2 false }; - const target_type bmis::static_type + + const target_type libua::static_type { - "bmis", - &bmix::static_type, - &m_factory<bmis, bmi>, + "libua", + &libux::static_type, + &libux_factory<libua>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -193,7 +216,7 @@ namespace build2 { "libus", &libux::static_type, - &m_factory<libus, libu>, + &libux_factory<libus>, nullptr, /* fixed_extension */ &target_extension_var<var_extension, nullptr>, &target_pattern_var<var_extension, nullptr>, @@ -255,6 +278,39 @@ namespace build2 false }; + // The same as g_factory() but without E. + // + static target* + libul_factory (const target_type&, dir_path dir, dir_path out, string n) + { + libua* a (phase == run_phase::load + ? const_cast<libua*> (targets.find<libua> (dir, out, n)) + : nullptr); + libus* s (phase == run_phase::load + ? const_cast<libus*> (targets.find<libus> (dir, out, n)) + : nullptr); + + libul* g (new libul (move (dir), move (out), move (n))); + + if (a != nullptr) a->group = g; + if (s != nullptr) s->group = g; + + return g; + } + + const target_type libul::static_type + { + "libul", + &libx::static_type, + &libul_factory, + nullptr, + nullptr, + nullptr, + nullptr, + &target_search, + false + }; + const target_type libu::static_type { "libu", |