From fb3a7f3343f9ee0cfd15b540a3209e438f6063eb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Nov 2020 09:27:20 +0200 Subject: Assign fixed extensions to wasm{} and pdb{} target types --- libbuild2/bin/init.cxx | 30 ++++++++++++++++++++++++++++-- libbuild2/scope.cxx | 9 +++++++++ libbuild2/scope.hxx | 5 +++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx index 166ec5d..9c16432 100644 --- a/libbuild2/bin/init.cxx +++ b/libbuild2/bin/init.cxx @@ -415,6 +415,8 @@ namespace build2 return true; } + extern const char wasm_ext[] = "wasm"; // VC14 rejects constexpr. + bool init (scope& rs, scope& bs, @@ -522,7 +524,18 @@ namespace build2 if (tgt.cpu == "wasm32" || tgt.cpu == "wasm64") { - const target_type& wasm (bs.derive_target_type ("wasm").first); + const target_type& wasm ( + rs.derive_target_type( + target_type { + "wasm", + &file::static_type, + nullptr, /* factory */ + &target_extension_fix, + nullptr, /* default_extension */ + &target_pattern_fix, + &target_print_0_ext_verb, // Fixed extension, no use printing. + &file_search, + false /* see_through */})); if (install_loaded) { @@ -855,6 +868,8 @@ namespace build2 return true; } + extern const char pdb_ext[] = "pdb"; // VC14 rejects constexpr. + bool ld_init (scope& rs, scope& bs, @@ -879,7 +894,18 @@ namespace build2 if (lid == "msvc") { - const target_type& pdb (bs.derive_target_type ("pdb").first); + const target_type& pdb ( + rs.derive_target_type( + target_type { + "pdb", + &file::static_type, + nullptr, /* factory */ + &target_extension_fix, + nullptr, /* default_extension */ + &target_pattern_fix, + &target_print_0_ext_verb, // Fixed extension, no use printing. + &file_search, + false /* see_through */})); if (cast_false (rs["install.loaded"])) { diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx index f8fc634..53c859f 100644 --- a/libbuild2/scope.cxx +++ b/libbuild2/scope.cxx @@ -929,6 +929,15 @@ namespace build2 return root_extra->target_types.insert (name, move (dt)); } + const target_type& scope:: + derive_target_type (const target_type& et) + { + assert (root_scope () == this); + unique_ptr dt (new target_type (et)); + dt->factory = &derived_tt_factory; + return root_extra->target_types.insert (et.name, move (dt)).first; + } + // scope_map // diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index 25657a3..d441267 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -367,6 +367,11 @@ namespace build2 return derive_target_type (name, T::static_type); } + // Derive from an "exemplar" type overriding the factory. + // + const target_type& + derive_target_type (const target_type&); + // Rules. // public: -- cgit v1.1