From 4941fc15c0b12ced1827806969b484675ce66895 Mon Sep 17 00:00:00 2001 From: Benjamin Block Date: Mon, 19 Sep 2022 17:45:33 +0200 Subject: [PATCH] zfcpdbf: test-compile the script during the build using `perl -c` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a slightly easier development loop add a pseudo compilation of the zfcpdbf Perl script. This will run the Perl interpreter in syntax-check mode: -c causes Perl to check the syntax of the program and then exit without executing it. Actually, it will execute any "BEGIN", "UNITCHECK", or "CHECK" blocks and any "use" statements: these are considered as occurring outside the execution of your program. "INIT" and "END" blocks, however, will be skipped. Additionally add the `-w` switch when the Make variable `W` is `1`. This will print additional warnings about dubious constructs (according to Perl). So this pseudo compilation only happens whenever the script is changed during development create a file `.zfcpdbf.ct` as a result so we can describe the relationship and dependency in Make. This file can be ignored otherwise. Signed-off-by: Benjamin Block Reviewed-by: Steffen Maier Reviewed-by: Jan Höppner Signed-off-by: Jan Höppner --- common.mak | 8 ++++++++ scripts/.gitignore | 1 + scripts/Makefile | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 scripts/.gitignore diff --git a/common.mak b/common.mak index 1d5e1a27..8ed7c531 100644 --- a/common.mak +++ b/common.mak @@ -75,6 +75,7 @@ $(eval $(call cmd_define, CAT," CAT ",cat)) $(eval $(call cmd_define, SED," SED ",sed)) $(eval $(call cmd_define, GZIP," GZIP ",gzip)) $(eval $(call cmd_define, MV," MV ",mv)) +$(eval $(call cmd_define, PERLC," PERLC ",perl -c)) CHECK = sparse CHECK_SILENT := $(CHECK) @@ -113,6 +114,11 @@ ifeq ("${ASAN}","1") DEFAULT_LDFLAGS += -fsanitize=address endif +DEFAULT_PERLCFLAGS = +ifeq ("${W}","1") + DEFAULT_PERLCFLAGS += -w +endif + # # Check for header prerequisite # @@ -260,6 +266,8 @@ ALL_CXXFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \ ALL_CPPFLAGS = -I $(rootdir)include $(CPPFLAGS) ALL_LDFLAGS = $(LDFLAGS) +ALL_PERLCFLAGS = $(DEFAULT_PERLCFLAGS) + # make G=1 # Compile tools so that gcov can be used to collect code coverage data. # See the gcov man page for details. diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 00000000..4324fa0e --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +/.zfcpdbf.ct diff --git a/scripts/Makefile b/scripts/Makefile index d7d12f34..deaed573 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -36,4 +36,21 @@ install: clean: +.zfcpdbf.ct: zfcpdbf + $(PERLC) $(ALL_PERLCFLAGS) zfcpdbf 2>$(@); \ + if [ "$${?}" -ne 0 ]; then \ + cat "$(@)" >&2 && rm "$(@)"; \ + elif [ "$$(cat '$(@)' | wc -l)" -gt 1 ]; then \ + cat "$(@)" >&2; \ + elif [ " $(V)" = " 1" ]; then \ + cat "$(@)"; \ + fi + +.PHONY: .zfcpdbf.ct-clean +.zfcpdbf.ct-clean: + rm -f .zfcpdbf.ct + +all: .zfcpdbf.ct +clean: .zfcpdbf.ct-clean + .PHONY: all install clean