diff options
author | rillig <rillig@pkgsrc.org> | 2020-04-23 19:30:29 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-04-23 19:30:29 +0000 |
commit | 254978b5b8a8795703558ddd1c98daba64992157 (patch) | |
tree | afee0e514cd97bcc68eed6bd4a646a8d5b442001 | |
parent | 40a7384d7102f519552e03320eb4c89cf0c11a07 (diff) | |
download | pkgsrc-254978b5b8a8795703558ddd1c98daba64992157.tar.gz |
mk/subst.mk: warn about all noop patterns before erroring out
-rw-r--r-- | mk/subst.mk | 21 | ||||
-rw-r--r-- | regress/infra-unittests/subst.sh | 9 |
2 files changed, 21 insertions, 9 deletions
diff --git a/mk/subst.mk b/mk/subst.mk index 1b439f56ad4..308c2b3c827 100644 --- a/mk/subst.mk +++ b/mk/subst.mk @@ -1,4 +1,4 @@ -# $NetBSD: subst.mk,v 1.82 2020/04/23 19:16:49 rillig Exp $ +# $NetBSD: subst.mk,v 1.83 2020/04/23 19:30:29 rillig Exp $ # # The subst framework replaces text in one or more files in the WRKSRC # directory. Packages can define several ``classes'' of replacements. @@ -156,13 +156,16 @@ ${SUBST_STAGE.${class}}: subst-${class} subst-${class}: ${_SUBST_COOKIE.${class}} ${_SUBST_COOKIE.${class}}: - ${RUN} \ + ${RUN} set -u; \ message=${SUBST_MESSAGE.${class}:Q}; \ [ "$$message" ] && ${ECHO_SUBST_MSG} "$$message"; \ \ cd ${WRKSRC}; \ patterns=${SUBST_FILES.${class}:Q}; \ set -f; \ + noop_count=''; \ + noop_patterns=''; \ + noop_sep=''; \ for pattern in $$patterns; do \ set +f; \ changed=no; \ @@ -191,10 +194,18 @@ ${_SUBST_COOKIE.${class}}: ${ECHO} "$$file" >> ${.TARGET}.tmp; \ done; \ \ - [ "$$changed,${SUBST_NOOP_OK.${class}:tl}" = no,no ] \ - && ${FAIL_MSG} "[subst.mk:${class}] The filename pattern \"$$pattern\" has no effect."; \ - done; \ + [ "$$changed,${SUBST_NOOP_OK.${class}:tl}" = no,no ] && { \ + noop_count="$$noop_count+"; \ + noop_patterns="$$noop_patterns$$noop_sep$$pattern"; \ + noop_sep=" "; \ + }; \ + done; \ \ + case $$noop_count in \ + ('') ;; \ + (+) ${FAIL_MSG} "[subst.mk:${class}] The filename pattern \"$$noop_patterns\" has no effect.";; \ + (*) ${FAIL_MSG} "[subst.mk:${class}] The filename patterns \"$$noop_patterns\" have no effect."; \ + esac; \ ${TOUCH} ${TOUCH_FLAGS} ${.TARGET}.tmp; \ ${MV} ${.TARGET}.tmp ${.TARGET} .endfor diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index 7210a0814ad..07addd835d6 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -938,10 +938,10 @@ if test_case_begin "pattern matches only directory"; then fi -if test_case_begin "first filename pattern has no effect"; then +if test_case_begin "two filename patterns have no effect"; then - # All patterns of SUBST_FILES should be applied before erroring out. - # TODO: also warn about file2 + # All patterns of SUBST_FILES should be applied before erroring out, + # to give a complete picture of the situation. create_file_lines "testcase.mk" \ 'SUBST_CLASSES+= id' \ @@ -963,7 +963,8 @@ if test_case_begin "first filename pattern has no effect"; then assert_that "out" --file-is-lines \ '=> Substituting "id" in file1 file2' \ 'warning: [subst.mk:id] Nothing changed in "file1".' \ - 'fail: [subst.mk:id] The filename pattern "file1" has no effect.' \ + 'warning: [subst.mk:id] Nothing changed in "file2".' \ + 'fail: [subst.mk:id] The filename patterns "file1 file2" have no effect.' \ '*** Error code 1' \ '' \ 'Stop.' \ |