From 46b5d6006e46b7e4ed051eec052de4a505a127e9 Mon Sep 17 00:00:00 2001 From: Martin Konrad Date: Tue, 31 Jul 2018 17:29:03 -0400 Subject: [PATCH 1/2] Fix "make --question" mode Fix for lp:1669891 --- configure/CONFIG_BASE | 2 +- configure/CONFIG_COMMON | 1 + configure/RULES_BUILD | 2 +- src/tools/genVersionHeader.pl | 12 +++++++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/configure/CONFIG_BASE b/configure/CONFIG_BASE index 365042775..1b1b9f14f 100644 --- a/configure/CONFIG_BASE +++ b/configure/CONFIG_BASE @@ -67,7 +67,7 @@ REGISTERRECORDDEVICEDRIVER = $(PERL) $(TOOLS)/registerRecordDeviceDriver.pl CONVERTRELEASE = $(PERL) $(call FIND_TOOL,convertRelease.pl) FULLPATHNAME = $(PERL) $(TOOLS)/fullPathName.pl TAPTOJUNIT = $(PERL) $(TOOLS)/tap-to-junit-xml.pl -GENVERSIONHEADER = $(PERL) $(TOOLS)/genVersionHeader.pl $(QUIET_FLAG) +GENVERSIONHEADER = $(PERL) $(TOOLS)/genVersionHeader.pl $(QUIET_FLAG) $(QUESTION_FLAG) #--------------------------------------------------------------- # tools for installing libraries and products diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 79807c2f2..18e5a2cec 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -80,6 +80,7 @@ IOCS_APPL_TOP = $(shell $(FULLPATHNAME) $(INSTALL_LOCATION)) NOP = : ECHO = @$(if $(findstring s,$(patsubst T_A=%,,$(MAKEFLAGS))),$(NOP),echo) QUIET_FLAG := $(if $(findstring s,$(MAKEFLAGS)),-q,) +QUESTION_FLAG := $(if $(findstring q,$(MAKEFLAGS)),-i,) #------------------------------------------------------- ifdef T_A diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index 14e7a32ea..49e6f78ce 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -185,7 +185,7 @@ endif # RELEASE file consistency checking checkRelease: - $(CONVERTRELEASE) checkRelease + +$(CONVERTRELEASE) checkRelease warnRelease: -$(CONVERTRELEASE) checkRelease noCheckRelease: diff --git a/src/tools/genVersionHeader.pl b/src/tools/genVersionHeader.pl index c61f14c98..92dbd81b2 100644 --- a/src/tools/genVersionHeader.pl +++ b/src/tools/genVersionHeader.pl @@ -23,18 +23,20 @@ my $tfmt = '%Y-%m-%dT%H:%M'; $tfmt .= '%z' unless $^O eq 'MSWin32'; # %z returns zone name on Windows my $now = strftime($tfmt, localtime); -our ($opt_h, $opt_v, $opt_q); +our ($opt_d, $opt_h, $opt_i, $opt_v, $opt_q); our $opt_t = '.'; our $opt_N = 'VCSVERSION'; our $opt_V = $now; my $vcs; -getopts('hvqt:N:V:') && @ARGV == 1 +getopts('dhivqt:N:V:') && @ARGV == 1 or HELP_MESSAGE(); my ($outfile) = @ARGV; +if ($opt_d) { exit 0 } # exit if make is run in dry-run mode + if (!$vcs && -d "$opt_t/_darcs") { # Darcs print "== Found /_darcs directory\n" if $opt_v; # v1-4-dirty @@ -148,6 +150,8 @@ if (open($DST, '+<', $outfile)) { or die "Can't create $outfile: $!\n"; } +if ($opt_i) { exit 1 }; # exit if make is run in "question" mode + seek $DST, 0, 0; truncate $DST, 0; print $DST $output; @@ -158,9 +162,11 @@ sub HELP_MESSAGE { Usage: genVersionHeader.pl -h Display this Usage message - genVersionHeader.pl [-v] [-q] [-t top] [-N NAME] [-V version] output.h"; + genVersionHeader.pl [-v] [-d] [-q] [-t top] [-N NAME] [-V version] output.h"; Generate or update the header file output.h -v - Verbose (debugging messages) + -d - Dry-run + -i - Question mode -q - Quiet -t top - Path to the module's top (default '$opt_t') -N NAME - Macro name to be defined (default '$opt_N') From ae38fb2c1c524f2faa99e78c741c95144e602202 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 25 Oct 2018 14:37:50 -0500 Subject: [PATCH 2/2] Improve output from genVersionHeader.pl Especially the responses in 'make --question' mode. --- src/tools/genVersionHeader.pl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/tools/genVersionHeader.pl b/src/tools/genVersionHeader.pl index 92dbd81b2..24e08abf9 100644 --- a/src/tools/genVersionHeader.pl +++ b/src/tools/genVersionHeader.pl @@ -137,14 +137,29 @@ if (open($DST, '+<', $outfile)) { print "== Current:\n$actual==\n" if $opt_v; if ($actual eq $output) { - print "Keeping VCS header $outfile\n $opt_N = \"$opt_V\"\n" + close $DST; + print "Keeping VCS header $outfile\n", + " $opt_N = \"$opt_V\"\n" unless $opt_q; exit 0; } - print "Updating VCS header $outfile\n $opt_N = \"$opt_V\"\n" - unless $opt_q; + + # This regexp must match the #define in $output above: + $actual =~ m/#define (\w+) ("[^"]*")\n/; + if ($opt_i) { + print "Outdated VCS header $outfile\n", + " has: $1 = $2\n", + " needs: $opt_N = \"$opt_V\"\n"; + } + else { + print "Updating VCS header $outfile\n", + " from: $1 = $2\n", + " to: $opt_N = \"$opt_V\"\n" + unless $opt_q; + } } else { - print "Creating VCS header $outfile\n $opt_N = \"$opt_V\"\n" + print "Creating VCS header $outfile\n", + " $opt_N = \"$opt_V\"\n" unless $opt_q; open($DST, '>', $outfile) or die "Can't create $outfile: $!\n";