mk/subst.mk: fix bmake warnings in case of duplicate SUBST classes

This commit is contained in:
rillig 2020-03-21 12:22:31 +00:00
parent ee99620e36
commit 68730ad3f1
2 changed files with 31 additions and 3 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: subst.mk,v 1.65 2020/03/20 09:00:44 rillig Exp $
# $NetBSD: subst.mk,v 1.66 2020/03/21 12:22:31 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@ -101,10 +101,10 @@ _SUBST_IS_TEXT_FILE_CMD?= \
[ -z "`LC_ALL=C ${TR} -cd '\\0' < "$$file" | ${TR} '\\0' 'x'`" ]
.if ${SUBST_CLASSES:U:O} != ${SUBST_CLASSES:U:O:u}
PKG_FAIL_REASON+= "[subst.mk] duplicate SUBST class: ${SUBST_CLASSES:O:u}"
PKG_FAIL_REASON+= "[subst.mk] duplicate SUBST class in: ${SUBST_CLASSES:O}"
.endif
.for _class_ in ${SUBST_CLASSES}
.for _class_ in ${SUBST_CLASSES:O:u}
_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
SUBST_FILTER_CMD.${_class_}?= LC_ALL=C ${SED} ${SUBST_SED.${_class_}}

View file

@ -510,3 +510,31 @@ EOF
test_case_end
fi
if test_case_begin "duplicate SUBST class"; then
create_file "testcase.mk" <<EOF
SUBST_CLASSES+= one
SUBST_CLASSES+= two
SUBST_CLASSES+= one
all:
@printf 'fail reason: %s\n' \${PKG_FAIL_REASON} 1>&2
.include "prepare-subst.mk"
.include "mk/subst.mk"
EOF
test_file "testcase.mk" "all" \
1> "$tmpdir/stdout" \
2> "$tmpdir/stderr" \
&& exitcode=0 || exitcode=$?
assert_that "stdout" --file-is-empty
assert_that "stderr" --file-is-lines \
"fail reason: [subst.mk] duplicate SUBST class in: one one two"
assert_that "$exitcode" --equals 0
test_case_end
fi