pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc
Module Name: pkgsrc
Committed By: rillig
Date: Sat Nov 10 10:40:56 UTC 2018
Modified Files:
pkgsrc/mk/misc: show.mk
pkgsrc/regress: Makefile
Added Files:
pkgsrc/regress/show-all: DESCR Makefile PLIST spec
Log Message:
mk/misc: in show-all, list values of *_ENV and *_ARGS in separate lines
The *_ENV and *_ARG values are typically very long, and reading them in
a single line is unnecessarily difficult. Therefore, each of their
values is listed on a separate line, for example:
fetch:
usr DIST_PATH (undefined)
pkg MASTER_SITES = \
http://ftp.gnome.org/pub/GNOME/sources/glib/2.56/ \
ftp://ftp.gnome.org/pub/GNOME/sources/glib/2.56/ \
ftp://ftp.cse.buffalo.edu/pub/Gnome/sources/glib/2.56/ \
https://download.gnome.org/sources/glib/2.56/ \
# end of MASTER_SITES
pkg DIST_SUBDIR (undefined)
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 pkgsrc/mk/misc/show.mk
cvs rdiff -u -r1.20 -r1.21 pkgsrc/regress/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/show-all/DESCR \
pkgsrc/regress/show-all/Makefile pkgsrc/regress/show-all/PLIST \
pkgsrc/regress/show-all/spec
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/mk/misc/show.mk
diff -u pkgsrc/mk/misc/show.mk:1.14 pkgsrc/mk/misc/show.mk:1.15
--- pkgsrc/mk/misc/show.mk:1.14 Mon May 28 22:34:47 2018
+++ pkgsrc/mk/misc/show.mk Sat Nov 10 10:40:55 2018
@@ -1,4 +1,4 @@
-# $NetBSD: show.mk,v 1.14 2018/05/28 22:34:47 rillig Exp $
+# $NetBSD: show.mk,v 1.15 2018/11/10 10:40:55 rillig Exp $
#
# This file contains some targets that print information gathered from
# variables. They do not modify any variables.
@@ -136,30 +136,72 @@ show-all: .PHONY
show-all: show-all-${g}
+# In the following code, the variables are evaluated as late as possible.
+# This is especially important for variables that use the :sh modifier,
+# like SUBST_FILES.pkglocaledir from mk/configure/replace-localedir.mk.
+#
+# When finally showing the variables, it is unavoidable that variables
+# using the :sh modifier may show warnings, for example because ${WRKDIR}
+# doesn't exist.
+
show-all-${g}: .PHONY
@echo "${g}:"
. for c in ${_SHOW_ALL_CATEGORIES}
. for v in ${${c}.${g}}
-. if defined(${v})
-# Be careful not to evaluate variables too early. Some may use the :sh
-# modifier, which can end up taking much time and issuing unexpected
-# warnings and error messages.
-#
-# When finally showing the variables, it is unavoidable that those
-# variables requiring ${WRKDIR} to exist will show a warning.
-#
- @value=${${v}:M*:Q}; \
- if [ "$$value" ]; then \
- echo " ${_LABEL.${c}} ${v} = $$value"; \
+. if (${v:M*_ENV} \
+ || ${v:M*_ENV.*})
+
+# multi-valued variables, values are sorted
+ ${RUN} \
+ if ${!defined(${v}) :? true : false}; then \
+ printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \
+ elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \
+ printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \
+ else \
+ printf ' %s\t%s (sorted) = \\\n' ${_LABEL.${c}} ${v:Q}; \
+ printf ' \t\t%s \\\n' ${${v}:O:@x@${x:Q}@}; \
+ printf ' \t\t# end of %s\n' ${v:Q}; \
+ fi
+
+. elif (${v:M*_ARGS} \
+ || ${v:M*_ARGS.*} \
+ || ${v:M*_CMD} \
+ || ${v:M*_CMD_DEFAULT} \
+ || ${v:M*_SKIP} \
+ || ${v:MMASTER_SITE*} \
+ || ${v:MSUBST_FILES.*} \
+ || ${v:MSUBST_SED.*} \
+ || ${v:MSUBST_FILTER_CMD.*} \
+ || ${v:M*_SUBST})
+
+# multi-valued variables, preserving original order
+ ${RUN} \
+ if ${!defined(${v}) :? true : false}; then \
+ printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \
+ elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \
+ printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \
else \
- echo " ${_LABEL.${c}} ${v} (defined, but empty)"; \
+ printf ' %s\t%s = \\\n' ${_LABEL.${c}} ${v:Q}; \
+ printf ' \t\t%s \\\n' ${${v}:@x@${x:Q}@}; \
+ printf ' \t\t# end of %s\n' ${v:Q}; \
fi
+
. else
- @echo " ${_LABEL.${c}} ${v} (undefined)"
+
+# single-valued variables
+ ${RUN} \
+ if ${!defined(${v}) :? true : false}; then \
+ printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \
+ elif value=${${v}:U:Q} && test "x$$value" = "x"; then \
+ printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \
+ else \
+ printf ' %s\t%s = %s\n' ${_LABEL.${c}} ${v:Q} "$$value"; \
+ fi
+
. endif
. endfor
. endfor
- @echo ""
+ ${RUN} printf '\n'
.endfor
.PHONY: show-depends-options
Index: pkgsrc/regress/Makefile
diff -u pkgsrc/regress/Makefile:1.20 pkgsrc/regress/Makefile:1.21
--- pkgsrc/regress/Makefile:1.20 Fri Nov 9 06:48:27 2018
+++ pkgsrc/regress/Makefile Sat Nov 10 10:40:55 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.20 2018/11/09 06:48:27 rillig Exp $
+# $NetBSD: Makefile,v 1.21 2018/11/10 10:40:55 rillig Exp $
#
# See https://www.netbsd.org/docs/pkgsrc/regression.html for more
# information about these tests.
@@ -20,6 +20,7 @@ SUBDIR+= make-quoting
SUBDIR+= pkg-options
SUBDIR+= pkgfail
SUBDIR+= print-plist
+SUBDIR+= show-all
SUBDIR+= subst
SUBDIR+= tools
Added files:
Index: pkgsrc/regress/show-all/DESCR
diff -u /dev/null pkgsrc/regress/show-all/DESCR:1.1
--- /dev/null Sat Nov 10 10:40:56 2018
+++ pkgsrc/regress/show-all/DESCR Sat Nov 10 10:40:56 2018
@@ -0,0 +1,5 @@
+Ensures that the show-all target prints all variants of variable values
+as intended. This involves sorted multi-valued variables (like
+CONFIGURE_ENV), other multi-valued variables (like CONFIGURE_ARGS),
+variables containing special characters that need to be escaped, and
+various other edge cases.
Index: pkgsrc/regress/show-all/Makefile
diff -u /dev/null pkgsrc/regress/show-all/Makefile:1.1
--- /dev/null Sat Nov 10 10:40:56 2018
+++ pkgsrc/regress/show-all/Makefile Sat Nov 10 10:40:56 2018
@@ -0,0 +1,35 @@
+# $NetBSD: Makefile,v 1.1 2018/11/10 10:40:56 rillig Exp $
+
+DISTNAME= show-all-1.0
+CATEGORIES= regress
+MASTER_SITES= # none
+DISTFILES= # none
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+COMMENT= Demonstrates the show-all target
+LICENSE= 2-clause-bsd
+
+REGRESS.empty= # empty
+REGRESS.value= All * kinds of `strange' \escape $$characters
+
+REGRESS_ENV.empty= # empty
+REGRESS_ENV.space= # initially empty
+REGRESS_ENV.space+= # now it contains a single space
+REGRESS_ENV.value= VAR1=value1 VAR2=`command execution via backticks` *=all
+
+REGRESS_ARGS.empty= # empty
+REGRESS_ARGS.space= # initially empty
+REGRESS_ARGS.space+= # now it contains a single space
+REGRESS_ARGS.value= VAR1=value1 VAR2=`command execution via backticks` *=all
+
+# Variable names may also contain special characters that must be escaped.
+*= bmake built-in
+**= asterisk
+
+_VARGROUPS+= regress
+_PKG_VARS.regress+= REGRESS.undefined REGRESS.empty REGRESS.value
+_PKG_VARS.regress+= REGRESS_ENV.undefined REGRESS_ENV.empty REGRESS_ENV.space REGRESS_ENV.value
+_PKG_VARS.regress+= REGRESS_ARGS.undefined REGRESS_ARGS.empty REGRESS_ARGS.space REGRESS_ARGS.value
+_PKG_VARS.regress+= * **
+
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/regress/show-all/PLIST
diff -u /dev/null pkgsrc/regress/show-all/PLIST:1.1
--- /dev/null Sat Nov 10 10:40:56 2018
+++ pkgsrc/regress/show-all/PLIST Sat Nov 10 10:40:56 2018
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2018/11/10 10:40:56 rillig Exp $
+@comment intentionally empty
Index: pkgsrc/regress/show-all/spec
diff -u /dev/null pkgsrc/regress/show-all/spec:1.1
--- /dev/null Sat Nov 10 10:40:56 2018
+++ pkgsrc/regress/show-all/spec Sat Nov 10 10:40:56 2018
@@ -0,0 +1,70 @@
+# $NetBSD: spec,v 1.1 2018/11/10 10:40:56 rillig Exp $
+
+tmpdir=${TMPDIR:-/tmp}/pkgsrc-show-all
+rm -rf "$tmpdir"
+mkdir -p "$tmpdir"
+
+require_file() {
+ if diff -u "$3" "$1" > /dev/null; then
+ :
+ else
+ regress_fail "Expected files to be equal."
+ diff -u "$3" "$1" || true
+ fi
+}
+
+
+do_test() {
+ $TEST_MAKE show-all-regress > "$tmpdir/show-all-regress.out"
+}
+
+check_result() {
+ exit_status 0
+
+ cat <<'EOF' > "$tmpdir/expected"
+regress:
+ pkg REGRESS.undefined (undefined)
+ pkg REGRESS.empty = # empty
+ pkg REGRESS.value = All * kinds of `strange' \escape $characters
+ pkg REGRESS_ENV.undefined (undefined)
+ pkg REGRESS_ENV.empty = # empty
+ pkg REGRESS_ENV.space = # empty
+ pkg REGRESS_ENV.value (sorted) = \
+ *=all \
+ VAR1=value1 \
+ VAR2=`command \
+ backticks` \
+ execution \
+ via \
+ # end of REGRESS_ENV.value
+ pkg REGRESS_ARGS.undefined (undefined)
+ pkg REGRESS_ARGS.empty = # empty
+ pkg REGRESS_ARGS.space = # empty
+ pkg REGRESS_ARGS.value = \
+ VAR1=value1 \
+ VAR2=`command \
+ execution \
+ via \
+ backticks` \
+ *=all \
+ # end of REGRESS_ARGS.value
+ pkg * = show-all-regress
+ pkg ** = asterisk
+
+EOF
+
+ # The "*" variable is built-in into bmake and expands to the current
+ # make target, which in this case is "show-all-regress".
+
+ # The "**" variable ensures that show-all doesn't accidentally expand
+ # filenames.
+
+ # It's a bit strange that bmake doesn't handle the backticks command
+ # as a single word. Luckily, this is a rare case.
+ #
+ # On the other hand, if it did, bmake would also have to handle
+ # variable expansion and all the other syntactic difficulties from
+ # parsing shell commands, and that would be just too much.
+
+ require_file "$tmpdir/show-all-regress.out" --equals "$tmpdir/expected"
+}
Home |
Main Index |
Thread Index |
Old Index