aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/bin/init.cxx30
-rw-r--r--libbuild2/scope.cxx9
-rw-r--r--libbuild2/scope.hxx5
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<file> ("wasm").first);
+ const target_type& wasm (
+ rs.derive_target_type(
+ target_type {
+ "wasm",
+ &file::static_type,
+ nullptr, /* factory */
+ &target_extension_fix<wasm_ext>,
+ nullptr, /* default_extension */
+ &target_pattern_fix<wasm_ext>,
+ &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<file> ("pdb").first);
+ const target_type& pdb (
+ rs.derive_target_type(
+ target_type {
+ "pdb",
+ &file::static_type,
+ nullptr, /* factory */
+ &target_extension_fix<pdb_ext>,
+ nullptr, /* default_extension */
+ &target_pattern_fix<pdb_ext>,
+ &target_print_0_ext_verb, // Fixed extension, no use printing.
+ &file_search,
+ false /* see_through */}));
if (cast_false<bool> (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<target_type> 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: