aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-06-08 12:47:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-06-08 15:43:08 +0200
commit5900f155a4a0da88cfd56bedccef0c74cc19c9f7 (patch)
tree80312123e3a61a1315d549f2e692391631183eed
parent0baeb5209d3a111a53070c032d7cdb1e609e3516 (diff)
Get rid of special *{} wildcard target type notation in target type/patterns
Explicit target{} should be used instead. Also, in this context, absent target type is now treated as file{} rather than target{}, for consistency with all other cases.
-rw-r--r--libbuild2/adhoc-rule-regex-pattern.cxx4
-rw-r--r--libbuild2/context.cxx24
-rw-r--r--libbuild2/parser.cxx23
-rw-r--r--libbuild2/target.hxx2
-rw-r--r--tests/variable/target-type-pattern-specific/testscript2
5 files changed, 24 insertions, 31 deletions
diff --git a/libbuild2/adhoc-rule-regex-pattern.cxx b/libbuild2/adhoc-rule-regex-pattern.cxx
index 4c8c1e5..c621b67 100644
--- a/libbuild2/adhoc-rule-regex-pattern.cxx
+++ b/libbuild2/adhoc-rule-regex-pattern.cxx
@@ -83,9 +83,7 @@ namespace build2
{
if (tt == nullptr)
{
- tt = n.untyped () || n.type == "*"
- ? &target::static_type
- : s.find_target_type (n.type);
+ tt = n.untyped () ? &file::static_type : s.find_target_type (n.type);
if (tt == nullptr)
fail (loc) << "unknown target type " << n.type;
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index e8232c7..924c370 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -262,15 +262,21 @@ namespace build2
{
target_type_map& t (data_->global_target_types);
- t.insert<file> ();
- t.insert<alias> ();
- t.insert<dir> ();
- t.insert<fsdir> ();
- t.insert<exe> ();
- t.insert<doc> ();
- t.insert<legal> ();
- t.insert<man> ();
- t.insert<man1> ();
+ // These are abstract.
+ //
+ t.insert<target> ();
+ t.insert<mtime_target> ();
+ t.insert<path_target> ();
+
+ t.insert<file> ();
+ t.insert<alias> ();
+ t.insert<dir> ();
+ t.insert<fsdir> ();
+ t.insert<exe> ();
+ t.insert<doc> ();
+ t.insert<legal> ();
+ t.insert<man> ();
+ t.insert<man1> ();
{
auto& tt (t.insert<manifest> ());
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index a7e84f7..6f59b30 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -733,18 +733,11 @@ namespace build2
sg = enter_scope (*this, move (n.dir));
}
- // Resolve target type. If none is specified or if it is '*',
- // use the root of the target type hierarchy. So these are all
- // equivalent:
+ // Resolve target type. If none is specified, then it's file{}.
//
- // *: foo = bar
- // {*}: foo = bar
- // *{*}: foo = bar
- //
- const target_type* ttype (
- n.untyped () || n.type == "*"
- ? &target::static_type
- : scope_->find_target_type (n.type));
+ const target_type* ttype (n.untyped ()
+ ? &file::static_type
+ : scope_->find_target_type (n.type));
if (ttype == nullptr)
fail (nloc) << "unknown target type " << n.type;
@@ -1074,12 +1067,8 @@ namespace build2
{
// Resolve target type (same as in for_one_pat()).
//
- // @@ TODO: maybe untyped should mean file{} as everywhere else?
- // Also, why do we bother with *{}, is it that hard to write
- // target{*}? Note: here, in vars, and in regex_pattern.
- //
- ttype = n.untyped () || n.type == "*"
- ? &target::static_type
+ ttype = n.untyped ()
+ ? &file::static_type
: scope_->find_target_type (n.type);
if (ttype == nullptr)
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index e8895ea..01f01e1 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -786,8 +786,8 @@ namespace build2
return derived_type != nullptr ? *derived_type : dynamic_type ();
}
- virtual const target_type& dynamic_type () const = 0;
static const target_type static_type;
+ virtual const target_type& dynamic_type () const = 0;
// RW access.
//
diff --git a/tests/variable/target-type-pattern-specific/testscript b/tests/variable/target-type-pattern-specific/testscript
index 9962342..016380b 100644
--- a/tests/variable/target-type-pattern-specific/testscript
+++ b/tests/variable/target-type-pattern-specific/testscript
@@ -58,7 +58,7 @@ print $(file{x-foz}: x)
*: x1 = X1
{*}: x2 = X2
-*{*}: x3 = X3
+target{*}: x3 = X3
print $(file{x}: x1)
print $(file{x}: x2)
print $(file{x}: x3)