From a89f1e4f4efd291beedea03c65c8185b7d0df20e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Dec 2017 12:06:59 +0200 Subject: Distinguish between "fixed" and "default" target extensions This fixes wrong merging of, say, file{README} and file{README.MySQL} (in libmysqlclient). --- build2/bin/target.cxx | 100 ++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 47 deletions(-) (limited to 'build2/bin') diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index d9dc64b..533da43 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include + #include using namespace std; @@ -18,6 +20,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -30,6 +33,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -41,24 +45,18 @@ namespace build2 // running serial. For the members it is also safe to set the group during // creation. - extern const char ext_var[] = "extension"; // VC14 rejects constexpr. - // obj*{}, bmi*{}, libu*{} member factory. // template - static pair> - m_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + static target* + m_factory (const target_type&, dir_path dir, dir_path out, string n) { const G* g (targets.find (dir, out, n)); M* m (new M (move (dir), move (out), move (n))); m->group = g; - return make_pair (m, move (ext)); + return m; } const target_type obje::static_type @@ -66,8 +64,9 @@ namespace build2 "obje", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -78,8 +77,9 @@ namespace build2 "bmie", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -90,8 +90,9 @@ namespace build2 "libue", &libux::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -102,8 +103,9 @@ namespace build2 "obja", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -114,8 +116,9 @@ namespace build2 "bmia", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -126,8 +129,9 @@ namespace build2 "libua", &libux::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -138,8 +142,9 @@ namespace build2 "objs", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -150,8 +155,9 @@ namespace build2 "bmis", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -162,8 +168,9 @@ namespace build2 "libus", &libux::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -172,12 +179,8 @@ namespace build2 // obj{}, bmi{}, and libu{} group factory. // template - static pair> - g_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + static target* + g_factory (const target_type&, dir_path dir, dir_path out, string n) { // Casts are MT-aware (during serial load). // @@ -197,7 +200,7 @@ namespace build2 if (a != nullptr) a->group = g; if (s != nullptr) s->group = g; - return make_pair (g, move (ext)); + return g; } const target_type obj::static_type @@ -208,6 +211,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -220,6 +224,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -232,6 +237,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -251,8 +257,9 @@ namespace build2 "liba", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &file_search, false @@ -263,8 +270,9 @@ namespace build2 "libs", &file::static_type, &m_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &file_search, false @@ -283,12 +291,8 @@ namespace build2 : group_view {nullptr, 0}; } - static pair> - lib_factory (const target_type&, - dir_path dir, - dir_path out, - string n, - optional ext) + static target* + lib_factory (const target_type&, dir_path dir, dir_path out, string n) { // Casts are MT-aware (during serial load). // @@ -304,7 +308,7 @@ namespace build2 if (a != nullptr) a->group = l; if (s != nullptr) s->group = l; - return make_pair (l, move (ext)); + return l; } const target_type lib::static_type @@ -315,6 +319,7 @@ namespace build2 nullptr, nullptr, nullptr, + nullptr, &target_search, false }; @@ -326,8 +331,9 @@ namespace build2 "libi", &file::static_type, &target_factory, - &target_extension_var, - &target_pattern_var, + nullptr, /* fixed_extension */ + &target_extension_var, + &target_pattern_var, nullptr, &file_search, false -- cgit v1.1