mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
ee914ef902
Lots more unit tests and code cleanup Relevant changes from ChangeLog o job.c: Print -de error information when running multiple jobs o var.c: only report error for unmatched regex subexpression when linting (-dL) since we cannot tell when an unmatched subexpression is an expected result. reduce memory allocations in the modifiers ':D' and ':U' reduce memory allocation and strlen calls in modifier ':from=to' in the ':Q' modifier, only allocate memory if necessary improve performance for LazyBuf reduce debug logging and memory allocation for ${:U...} reduce verbosity of the -dv debug logging for standard cases fix double varname expansion in the variable modifier '::=' o var.c: avoid evaluating many modifiers in parse only mode in strict mode (-dL) many variable references are parsed twice, the first time just to report parse errors early, so we want to avoid side effects and wasted effort to the extent possible.
108 lines
2.7 KiB
Makefile
108 lines
2.7 KiB
Makefile
# $NetBSD: directive-undef.mk,v 1.10 2021/02/16 18:02:19 rillig Exp $
|
|
#
|
|
# Tests for the .undef directive.
|
|
#
|
|
# See also:
|
|
# directive-misspellings.mk
|
|
|
|
# Before var.c 1.737 from 2020-12-19, .undef only undefined the first
|
|
# variable, silently skipping all further variable names.
|
|
#
|
|
# Before var.c 1.761 from 2020-12-22, .undef complained about too many
|
|
# arguments.
|
|
#
|
|
# Since var.c 1.761 from 2020-12-22, .undef handles multiple variable names
|
|
# just like the .export directive.
|
|
1= 1
|
|
2= 2
|
|
3= 3
|
|
.undef 1 2 3
|
|
.if ${1:U_}${2:U_}${3:U_} != ___
|
|
. warning $1$2$3
|
|
.endif
|
|
|
|
|
|
# Without any arguments, until var.c 1.736 from 2020-12-19, .undef tried
|
|
# to delete the variable with the empty name, which never exists; see
|
|
# varname-empty.mk. Since var.c 1.737 from 2020-12-19, .undef complains
|
|
# about a missing argument.
|
|
.undef
|
|
|
|
|
|
# Trying to delete the variable with the empty name is ok, it just won't
|
|
# ever do anything since that variable is never defined.
|
|
.undef ${:U}
|
|
|
|
|
|
# The argument of .undef is first expanded exactly once and then split into
|
|
# words, just like everywhere else. This prevents variables whose names
|
|
# contain spaces or unbalanced 'single' or "double" quotes from being
|
|
# undefined, but these characters do not appear in variables names anyway.
|
|
1= 1
|
|
2= 2
|
|
3= 3
|
|
${:U1 2 3}= one two three
|
|
VARNAMES= 1 2 3
|
|
.undef ${VARNAMES} # undefines the variable "1 2 3"
|
|
.if !defined(${:U1 2 3})
|
|
. error
|
|
.endif
|
|
.if ${1:U_}${2:U_}${3:U_} != "___" # these are still defined
|
|
. error
|
|
.endif
|
|
|
|
|
|
# A variable named " " cannot be undefined. There's no practical use case
|
|
# for such variables anyway.
|
|
SPACE= ${:U }
|
|
${SPACE}= space
|
|
.if !defined(${SPACE})
|
|
. error
|
|
.endif
|
|
.undef ${SPACE}
|
|
.if !defined(${SPACE})
|
|
. error
|
|
.endif
|
|
|
|
|
|
# A variable named "$" can be undefined since the argument to .undef is
|
|
# expanded exactly once, before being split into words.
|
|
DOLLAR= $$
|
|
${DOLLAR}= dollar
|
|
.if !defined(${DOLLAR})
|
|
. error
|
|
.endif
|
|
.undef ${DOLLAR}
|
|
.if defined(${DOLLAR})
|
|
. error
|
|
.endif
|
|
|
|
|
|
# Since var.c 1.762 from 2020-12-22, parse errors in the argument should be
|
|
# properly detected and should stop the .undef directive from doing any work.
|
|
#
|
|
# As of var.c 1.762, this doesn't happen though because the error handling
|
|
# in Var_Parse and Var_Subst is not done properly.
|
|
.undef ${VARNAMES:L:Z}
|
|
|
|
|
|
UT_EXPORTED= exported-value
|
|
.export UT_EXPORTED
|
|
.if ${:!echo "\${UT_EXPORTED:-not-exported}"!} != "exported-value"
|
|
. error
|
|
.endif
|
|
.if !${.MAKE.EXPORTED:MUT_EXPORTED}
|
|
. error
|
|
.endif
|
|
.undef UT_EXPORTED # XXX: does not update .MAKE.EXPORTED
|
|
.if ${:!echo "\${UT_EXPORTED:-not-exported}"!} != "not-exported"
|
|
. error
|
|
.endif
|
|
.if ${.MAKE.EXPORTED:MUT_EXPORTED}
|
|
. warning UT_EXPORTED is still listed in .MAKE.EXPORTED even though $\
|
|
it is not exported anymore.
|
|
.endif
|
|
|
|
|
|
all:
|