Module Name: src
Committed By: rillig
Date: Sun Jul 26 20:30:42 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varmisc.exp varmisc.mk
Log Message:
make(1): add test for expanding dynamic variables
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmisc.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmisc.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/varmisc.exp
diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.10 src/usr.bin/make/unit-tests/varmisc.exp:1.11
--- src/usr.bin/make/unit-tests/varmisc.exp:1.10 Sun Jul 26 11:10:29 2020
+++ src/usr.bin/make/unit-tests/varmisc.exp Sun Jul 26 20:30:42 2020
@@ -43,4 +43,5 @@ save-dollars: off = $
export-appended: env
export-appended: env
export-appended: env mk
+parse-dynamic: parse-dynamic parse-dynamic before
exit status 0
Index: src/usr.bin/make/unit-tests/varmisc.mk
diff -u src/usr.bin/make/unit-tests/varmisc.mk:1.14 src/usr.bin/make/unit-tests/varmisc.mk:1.15
--- src/usr.bin/make/unit-tests/varmisc.mk:1.14 Sun Jul 26 11:10:29 2020
+++ src/usr.bin/make/unit-tests/varmisc.mk Sun Jul 26 20:30:42 2020
@@ -1,4 +1,4 @@
-# $Id: varmisc.mk,v 1.14 2020/07/26 11:10:29 rillig Exp $
+# $Id: varmisc.mk,v 1.15 2020/07/26 20:30:42 rillig Exp $
#
# Miscellaneous variable tests.
@@ -6,6 +6,7 @@ all: unmatched_var_paren D_true U_true D
strftime cmpv manok
all: save-dollars
all: export-appended
+all: parse-dynamic
unmatched_var_paren:
@echo ${foo::=foo-text}
@@ -156,3 +157,20 @@ export-appended:
@echo $@: "$$FROM_ENV"
@echo $@: "$$FROM_ENV_BEFORE"
@echo $@: "$$FROM_ENV_AFTER"
+
+# begin parse-dynamic
+#
+# Demonstrate that the target-specific variables are not evaluated in
+# the global context. They are preserved until there is a local context
+# in which resolving them makes sense.
+
+${:U>}= before
+G_TARGET:= $@
+G_MEMBER:= $%
+G_PREFIX:= $*
+G_ARCHIVE:= $!
+G_ALLSRC:= $>
+${:U>}= after
+
+parse-dynamic:
+ @echo $@: ${G_TARGET} ${G_MEMBER} ${G_PREFIX} ${G_ARCHIVE} ${G_ALLSRC}