| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $Id: varmisc.mk,v 1.16 2020/07/26 21:09:49 rillig Exp $ | | 1 | # $Id: varmisc.mk,v 1.17 2020/07/26 21:46:10 rillig Exp $ |
2 | # | | 2 | # |
3 | # Miscellaneous variable tests. | | 3 | # Miscellaneous variable tests. |
4 | | | 4 | |
5 | all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ | | 5 | all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ |
6 | strftime cmpv manok | | 6 | strftime cmpv manok |
7 | all: save-dollars | | 7 | all: save-dollars |
8 | all: export-appended | | 8 | all: export-appended |
9 | all: parse-dynamic | | 9 | all: parse-dynamic |
10 | all: varerror-unclosed | | 10 | all: varerror-unclosed |
11 | | | 11 | |
12 | unmatched_var_paren: | | 12 | unmatched_var_paren: |
13 | @echo ${foo::=foo-text} | | 13 | @echo ${foo::=foo-text} |
14 | | | 14 | |
| @@ -155,32 +155,47 @@ FROM_ENV_AFTER+= mk | | | @@ -155,32 +155,47 @@ FROM_ENV_AFTER+= mk |
155 | .export FROM_ENV_AFTER | | 155 | .export FROM_ENV_AFTER |
156 | | | 156 | |
157 | export-appended: | | 157 | export-appended: |
158 | @echo $@: "$$FROM_ENV" | | 158 | @echo $@: "$$FROM_ENV" |
159 | @echo $@: "$$FROM_ENV_BEFORE" | | 159 | @echo $@: "$$FROM_ENV_BEFORE" |
160 | @echo $@: "$$FROM_ENV_AFTER" | | 160 | @echo $@: "$$FROM_ENV_AFTER" |
161 | | | 161 | |
162 | # begin parse-dynamic | | 162 | # begin parse-dynamic |
163 | # | | 163 | # |
164 | # Demonstrate that the target-specific variables are not evaluated in | | 164 | # Demonstrate that the target-specific variables are not evaluated in |
165 | # the global context. They are preserved until there is a local context | | 165 | # the global context. They are preserved until there is a local context |
166 | # in which resolving them makes sense. | | 166 | # in which resolving them makes sense. |
167 | | | 167 | |
| | | 168 | # There are different code paths for short names ... |
168 | ${:U>}= before | | 169 | ${:U>}= before |
169 | G_TARGET:= $@ | | 170 | GS_TARGET:= $@ |
170 | G_MEMBER:= $% | | 171 | GS_MEMBER:= $% |
171 | G_PREFIX:= $* | | 172 | GS_PREFIX:= $* |
172 | G_ARCHIVE:= $! | | 173 | GS_ARCHIVE:= $! |
173 | G_ALLSRC:= $> | | 174 | GS_ALLSRC:= $> |
174 | ${:U>}= after | | 175 | ${:U>}= after |
| | | 176 | # ... and for braced short names ... |
| | | 177 | GB_TARGET:= ${@} |
| | | 178 | GB_MEMBER:= ${%} |
| | | 179 | GB_PREFIX:= ${*} |
| | | 180 | GB_ARCHIVE:= ${!} |
| | | 181 | GB_ALLSRC:= ${>} |
| | | 182 | # ... and for long names. |
| | | 183 | GL_TARGET:= ${.TARGET} |
| | | 184 | GL_MEMBER:= ${.MEMBER} |
| | | 185 | GL_PREFIX:= ${.PREFIX} |
| | | 186 | GL_ARCHIVE:= ${.ARCHIVE} |
| | | 187 | GL_ALLSRC:= ${.ALLSRC} |
175 | | | 188 | |
176 | parse-dynamic: | | 189 | parse-dynamic: |
177 | @echo $@: ${G_TARGET} ${G_MEMBER} ${G_PREFIX} ${G_ARCHIVE} ${G_ALLSRC} | | 190 | @echo $@: ${GS_TARGET} ${GS_MEMBER} ${GS_PREFIX} ${GS_ARCHIVE} ${GS_ALLSRC} |
| | | 191 | @echo $@: ${GB_TARGET} ${GB_MEMBER} ${GB_PREFIX} ${GB_ARCHIVE} ${GB_ALLSRC} |
| | | 192 | @echo $@: ${GL_TARGET} ${GL_MEMBER} ${GL_PREFIX} ${GL_ARCHIVE} ${GL_ALLSRC} |
178 | | | 193 | |
179 | # As of 2020-07-26, make does not complain about unclosed variables. | | 194 | # As of 2020-07-26, make does not complain about unclosed variables. |
180 | # It does complain about unclosed variables when parsing modifiers though. | | 195 | # It does complain about unclosed variables when parsing modifiers though. |
181 | varerror-unclosed: | | 196 | varerror-unclosed: |
182 | @echo $@:begin | | 197 | @echo $@:begin |
183 | @echo ${UNCLOSED | | 198 | @echo ${UNCLOSED |
184 | @echo ${UNCLOSED:M${PATTERN | | 199 | @echo ${UNCLOSED:M${PATTERN |
185 | @echo ${UNCLOSED.${param | | 200 | @echo ${UNCLOSED.${param |
186 | @echo $@:end | | 201 | @echo $@:end |