From 32e04ad4b4a8dec07836b7c9fcf90fe72a006990 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 25 Aug 2018 17:40:21 +0200 Subject: Implement missing pieces in utility libraries support In particular, we can now build static libraries out of utility libraries. --- build2/bin/target.cxx | 108 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 26 deletions(-) (limited to 'build2/bin/target.cxx') 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 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, + "obja", + &objx::static_type, + &m_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -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, + "bmia", + &bmix::static_type, + &m_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -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, + "objs", + &objx::static_type, + &m_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -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, + "bmis", + &bmix::static_type, + &m_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -163,11 +163,33 @@ namespace build2 false }; - const target_type objs::static_type + // libu*{} member factory. + // + template + static target* + libux_factory (const target_type&, dir_path dir, dir_path out, string n) { - "objs", - &objx::static_type, - &m_factory, + const target* g (targets.find (dir, out, n)); + + if (const target* g2 = targets.find (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, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -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, + "libua", + &libux::static_type, + &libux_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -193,7 +216,7 @@ namespace build2 { "libus", &libux::static_type, - &m_factory, + &libux_factory, nullptr, /* fixed_extension */ &target_extension_var, &target_pattern_var, @@ -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 (targets.find (dir, out, n)) + : nullptr); + libus* s (phase == run_phase::load + ? const_cast (targets.find (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", -- cgit v1.1