From b2374e3174e13682fcfa3ffe3fc62f2fd161a7cc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Nov 2015 14:31:40 +0200 Subject: Implement target type/pattern-specific variables For example: cxx{*-options}: dist = true 1. Only single '*' wildcard is supported, matches 0 or more characters. 2. If target type is not specified, it defaults to any target. 3. Appending (+=) is not allowed. 4. The value is expanded immediately in the context of the scope. 5. The more specific pattern (i.e., with the shortest "stem") is preferred. If the stem has the same length, then the last defined (but not redefined) pattern is used. This will probably have to change to become an error. See tests/variable/type-pattern for more examples. --- tests/variable/type-pattern/buildfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/variable/type-pattern/buildfile (limited to 'tests/variable') diff --git a/tests/variable/type-pattern/buildfile b/tests/variable/type-pattern/buildfile new file mode 100644 index 0000000..8c353a5 --- /dev/null +++ b/tests/variable/type-pattern/buildfile @@ -0,0 +1,33 @@ +#dir/foo{*}: x = y # directory +#foo{*.*}: x = y # multiple wildcards +#foo{*}: x = y # unknown target type +#file{*}: x += y # append + +# Use --verbose 6 to examine. +# + +dir{*}: x = y + +x = z +dir{*-foo}: x = $x # 'z' + +x = G +file{*-foo}: x = x +file{xfoo}: x = $x # 'G' +file{-foo}: x = $x # 'x' +file{x-foo}: x = $x # 'x' +file{bar-*-foo}: x = X +file{bar-x}: x = $x # 'G' +file{bar--foo}: x = $x # 'X' +file{bar-x-foo}: x = $x # 'X' + +file{*-fox}: x = 1 +file{fox-*}: x = 2 +file{fox-fox}: x = $x # '2' +file{*-fox}: x = 3 +file{fox-x-fox}: x = $x # still '2'! + +*-foz: x = z # any target +file{x-foz}: x = $x # 'z' + +./: -- cgit v1.1