From 4d1c02b736f4c1e827b11085cdc83ce4b46c03d1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 26 Jun 2016 16:06:54 +0200 Subject: Add notion of ad hoc group, use to handle DLL/import library --- build2/parser.cxx | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'build2/parser.cxx') diff --git a/build2/parser.cxx b/build2/parser.cxx index 9d11d74..20cb75f 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -1112,31 +1112,6 @@ namespace build2 fail (t) << "expected newline instead of " << t; } - static target* - derived_factory (const target_type& t, - dir_path d, - dir_path o, - string n, - const string* e) - { - // Pass our type to the base factory so that it can detect that it is - // being called to construct a derived target. This can be used, for - // example, to decide whether to "link up" to the group. - // - // One exception: if we are derived from a derived target type, the this - // logic will lead to infinite recursion. In this case get the ultimate - // base. - // - const target_type* bt (t.base); - for (; bt->factory == &derived_factory; bt = bt->base) ; - - target* r (bt->factory (t, move (d), move (o), move (n), e)); - r->derived_type = &t; - return r; - } - - constexpr const char derived_ext_var[] = "extension"; - void parser:: define (token& t, type& tt) { @@ -1167,29 +1142,9 @@ namespace build2 if (bt == nullptr) fail (t) << "unknown target type " << bn; - unique_ptr dt (new target_type (*bt)); - dt->base = bt; - dt->factory = &derived_factory; - - // Override extension derivation function: we most likely don't want - // to use the same default as our base (think cli: file). But, if our - // base doesn't use extensions, then most likely neither do we (think - // foo: alias). - // - if (bt->extension != nullptr) - dt->extension = &target_extension_var; - - target_type& rdt (*dt); // Save a non-const reference to the object. - - auto pr (scope_->target_types.emplace (dn, target_type_ref (move (dt)))); - - if (!pr.second) + if (!scope_->derive_target_type (move (dn), *bt).second) fail (dnl) << "target type " << dn << " already define in this scope"; - // Patch the alias name to use the map's key storage. - // - rdt.name = pr.first->first.c_str (); - next (t, tt); // Get newline. } else -- cgit v1.1