From 9ae4897cfe935598333a5f709e967fefc4c161aa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 31 May 2017 16:35:50 +0200 Subject: C++ modules work: add target types --- build2/bin/target.cxx | 135 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 49 deletions(-) (limited to 'build2/bin/target.cxx') diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index 962befa..f0e0152 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -19,27 +19,41 @@ namespace build2 extern const char ext_var[] = "extension"; // VC14 rejects constexpr. - template + // obj*{} and bmi*{} member factory. + // + template static pair> - objx_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + m_factory (const target_type&, + dir_path dir, + dir_path out, + string n, + optional ext) { - const obj* g (targets.find (dir, out, n)); + const G* g (targets.find (dir, out, n)); - T* x (new T (move (dir), move (out), move (n))); - x->group = g; + M* m (new M (move (dir), move (out), move (n))); + m->group = g; - return make_pair (x, move (ext)); + return make_pair (m, move (ext)); } const target_type obje::static_type { "obje", &file::static_type, - &objx_factory, + &m_factory, + &target_extension_var, + &target_pattern_var, + nullptr, + &target_search, // Note: not _file(); don't look for an existing file. + false + }; + + const target_type bmie::static_type + { + "bmie", + &file::static_type, + &m_factory, &target_extension_var, &target_pattern_var, nullptr, @@ -51,7 +65,19 @@ namespace build2 { "obja", &file::static_type, - &objx_factory, + &m_factory, + &target_extension_var, + &target_pattern_var, + nullptr, + &target_search, // Note: not _file(); don't look for an existing file. + false + }; + + const target_type bmia::static_type + { + "bmia", + &file::static_type, + &m_factory, &target_extension_var, &target_pattern_var, nullptr, @@ -63,7 +89,7 @@ namespace build2 { "objs", &file::static_type, - &objx_factory, + &m_factory, &target_extension_var, &target_pattern_var, nullptr, @@ -71,39 +97,54 @@ namespace build2 false }; + const target_type bmis::static_type + { + "bmis", + &file::static_type, + &m_factory, + &target_extension_var, + &target_pattern_var, + nullptr, + &target_search, // Note: not _file(); don't look for an existing file. + false + }; + + // obj{} and bmi{} group factory. + // + template static pair> - obj_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + g_factory (const target_type&, + dir_path dir, + dir_path out, + string n, + optional ext) { // Casts are MT-aware (during serial load). // - obje* e (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) - : nullptr); - obja* a (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) - : nullptr); - objs* s (phase == run_phase::load - ? const_cast (targets.find (dir, out, n)) - : nullptr); + E* e (phase == run_phase::load + ? const_cast (targets.find (dir, out, n)) + : nullptr); + A* a (phase == run_phase::load + ? const_cast (targets.find (dir, out, n)) + : nullptr); + S* s (phase == run_phase::load + ? const_cast (targets.find (dir, out, n)) + : nullptr); - obj* o (new obj (move (dir), move (out), move (n))); + G* g (new G (move (dir), move (out), move (n))); - if (e != nullptr) e->group = o; - if (a != nullptr) a->group = o; - if (s != nullptr) s->group = o; + if (e != nullptr) e->group = g; + if (a != nullptr) a->group = g; + if (s != nullptr) s->group = g; - return make_pair (o, move (ext)); + return make_pair (g, move (ext)); } const target_type obj::static_type { "obj", &target::static_type, - &obj_factory, + &g_factory, nullptr, nullptr, nullptr, @@ -111,21 +152,17 @@ namespace build2 false }; - template - static pair> - libx_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + const target_type bmi::static_type { - const lib* g (targets.find (dir, out, n)); - - T* x (new T (move (dir), move (out), move (n))); - x->group = g; - - return make_pair (x, move (ext)); - } + "bmi", + &target::static_type, + &g_factory, + nullptr, + nullptr, + nullptr, + &target_search, + false + }; // What extensions should we use? At the outset, this is platform- // dependent. And if we consider cross-compilation, is it build or @@ -141,7 +178,7 @@ namespace build2 { "liba", &file::static_type, - &libx_factory, + &m_factory, &target_extension_var, &target_pattern_var, nullptr, @@ -153,7 +190,7 @@ namespace build2 { "libs", &file::static_type, - &libx_factory, + &m_factory, &target_extension_var, &target_pattern_var, nullptr, -- cgit v1.1