aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-06 10:22:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-06 10:22:12 +0200
commit9a9276e1d151910ba31db4d91521b41e5ea1435f (patch)
treea4bf5d320c6c1c6f5d98e00a2620c2bb8a33fb3e /tests
parent736812cb586e0f80742337dce802ad24adf331ad (diff)
Adjust variable block applicability in dependency chains
Before the block used to apply to the set of prerequisites before the last `:`. This turned out to be counterintuitive and not very useful since prerequisite-specific variables are a lot less common than target specific. And it doesn't fit with ad hoc recipes. The new rule is if the chain ends with `:`, then the block applies to the last set of prerequisites. Otherwise, it applies to the last set of targets. For example: ./: exe{test}: cxx{main} { test = true # Applies to the exe{test} target. } ./: exe{test}: libue{test}: { bin.whole = false # Applies to the libue{test} prerequisite. } This is actually consistent with both non-chain and non-block cases. Consider: exe{test}: cxx{main} { test = true } exe{test}: libue{test}: { bin.whole = false } exe{test}: libue{test}: bin.whole = false The only exception we now have in this overall approach of "if the dependency declaration ends with a colon, then what follows is for a prerequisite" is for the first semicolon: exe{test}: { test = true } exe{test}: test = true But that's probably intuitive enough since there cannot be a prerequisite without a target.
Diffstat (limited to 'tests')
-rw-r--r--tests/dependency/chain/testscript49
-rw-r--r--tests/dependency/recipe/testscript46
2 files changed, 95 insertions, 0 deletions
diff --git a/tests/dependency/chain/testscript b/tests/dependency/chain/testscript
index ac4a946..a24ace3 100644
--- a/tests/dependency/chain/testscript
+++ b/tests/dependency/chain/testscript
@@ -36,3 +36,52 @@ EOI
% .+/dir\{y/\}: .+:dir\{a/\} .+:dir\{b/\}%
EOE
+
+: var-prereq
+:
+$* <<EOI 2>>/~%EOE%
+./: dir{x}: dir{a}: x = y
+dump dir{x}
+EOI
+<stdin>:2:1: dump:
+% .+/dir\{x/\}: .+:dir\{a/\}:%
+ {
+ x = y
+ }
+EOE
+
+: var-prereq-block
+:
+$* <<EOI 2>>/~%EOE%
+./: dir{x}: dir{a}:
+{
+ x = y
+ z = x
+}
+dump dir{x}
+EOI
+<stdin>:6:1: dump:
+% .+/dir\{x/\}: .+:dir\{a/\}:%
+ {
+ x = y
+ z = x
+ }
+EOE
+
+: var-target-block
+:
+$* <<EOI 2>>/~%EOE%
+./: dir{x}: dir{a}
+{
+ x = y
+ z = x
+}
+dump dir{x}
+EOI
+<stdin>:6:1: dump:
+% .+/dir\{x/\}: .+:dir\{a/\}%
+ {
+ x = y
+ z = x
+ }
+EOE
diff --git a/tests/dependency/recipe/testscript b/tests/dependency/recipe/testscript
index bd33bcc..43ec514 100644
--- a/tests/dependency/recipe/testscript
+++ b/tests/dependency/recipe/testscript
@@ -139,6 +139,52 @@ EOI
}}
EOE
+: with-vars-depchain
+:
+$* <<EOI 2>>/~%EOE%
+./: alias{x}: alias{y}
+{
+ var = x
+}
+{{
+ echo
+}}
+dump alias{x}
+EOI
+<stdin>:8:1: dump:
+% .+/alias\{x\}: .+/:alias\{y\}%
+ {
+ var = x
+ }
+ % [diag=echo] perform(update)
+ {{
+ echo
+ }}
+EOE
+
+: with-vars-replay-depchain
+:
+$* <<EOI 2>>/~%EOE%
+./: alias{x y}: alias{z}
+{
+ var = x
+}
+{{
+ echo
+}}
+dump alias{y}
+EOI
+<stdin>:8:1: dump:
+% .+/alias\{y\}: .+/:alias\{z\}%
+ {
+ var = x
+ }
+ % [diag=echo] perform(update)
+ {{
+ echo
+ }}
+EOE
+
: with-vars-header
:
$* <<EOI 2>>/~%EOE%