aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scope.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-05-21 15:11:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-05-28 10:10:44 +0200
commite1f472e471533330db05a42d5bcd4e99b211da0c (patch)
treecdaa6a1de2a69965a347d6132a63c5b12d051c68 /libbuild2/scope.cxx
parent7d0cbd244d218bca8b806c283a5ae095f221b324 (diff)
Clean default target type extension logic
Diffstat (limited to 'libbuild2/scope.cxx')
-rw-r--r--libbuild2/scope.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx
index e16e773..3b612f8 100644
--- a/libbuild2/scope.cxx
+++ b/libbuild2/scope.cxx
@@ -887,6 +887,7 @@ namespace build2
dt->base = &base;
dt->factory = &derived_tt_factory;
+#if 0
// @@ We should probably inherit the fixed extension unless overriden with
// another fixed? But then any derivation from file{} will have to specify
// (or override) the fixed extension? But what is the use of deriving from
@@ -918,6 +919,43 @@ namespace build2
dt->fixed_extension != nullptr
? &target_print_0_ext_verb // Fixed extension, no use printing.
: nullptr; // Normal.
+#endif
+
+ // An attempt to clarify the above mess:
+ //
+ // 1. If we have a "really fixed" extension (like man1{}) then we keep
+ // it (including pattern and print functions).
+ //
+ // 2. Otherwise, we make it target_extension_var.
+ //
+ // Note that this still mis-fires for the following scenarios:
+ //
+ // file{} -- What if the user does not set the default extension expecting
+ // similar semantics as file{} or man{} itself. Maybe explicit
+ // via attribute (i.e., inherit from base)?
+ //
+ // @@ Get the fallback extension from base target_extension_var
+ // somehow (we know the base target type so could just call it)?
+ //
+ if (ext)
+ {
+ if (dt->fixed_extension == nullptr ||
+ dt->fixed_extension == &target_extension_none ||
+ dt->fixed_extension == &target_extension_must)
+ {
+ dt->fixed_extension = nullptr;
+ dt->default_extension = &target_extension_var<nullptr>;
+ dt->pattern = &target_pattern_var<nullptr>;
+ dt->print = nullptr;
+ }
+ }
+ else
+ {
+ dt->fixed_extension = nullptr;
+ dt->default_extension = nullptr;
+ dt->pattern = nullptr;
+ dt->print = nullptr;
+ }
return root_extra->target_types.insert (name, move (dt));
}