Merge ~info-martin-konrad/epics-base:fix-make-question-mode into ~epics-core/epics-base/+git/epics-base:3.16

Proposed by Martin Konrad
Status: Merged
Approved by: Andrew Johnson
Approved revision: 46b5d6006e46b7e4ed051eec052de4a505a127e9
Merged at revision: 31870b4c412da043d4df6a66e45a83e2f88c3115
Proposed branch: ~info-martin-konrad/epics-base:fix-make-question-mode
Merge into: ~epics-core/epics-base/+git/epics-base:3.16
Diff against target: 87 lines (+12/-5)
4 files modified
configure/CONFIG_BASE (+1/-1)
configure/CONFIG_COMMON (+1/-0)
configure/RULES_BUILD (+1/-1)
src/tools/genVersionHeader.pl (+9/-3)
Reviewer Review Type Date Requested Status
Andrew Johnson Approve
mdavidsaver Approve
Review via email: mp+354520@code.launchpad.net
To post a comment you must log in.
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

I haven't tried, but this looks like the change I had in mind.

review: Approve
Revision history for this message
Andrew Johnson (anj) wrote :
Download full text (4.1 KiB)

tux% make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

tux% cd base-3.16
tux% make -sq || echo Build required
tux% touch src/std/rec/aaiRecord.dbd
tux% make -sq || echo Build required
Build required
tux% make -sj
tux% make -sq || echo Build required
tux% cd ..

'make -q' works for Base, but Base doesn't actually use genVersionHeader.pl itself so let's try an example application, which does:

tux% mkdir example
tux% ../base-3.16/bin/linux-x86_64/makeBaseApp.pl -t example example
tux% tux% make -sq || echo Build required
Build required
tux% make -s
tux% make -sq || echo Build required
Build required

Oops, why's that?

tux% make -q --no-print-directory || echo Build required
make -C ./configure install
make -C O.linux-x86_64 -f ../Makefile TOP=../.. \
    T_A=linux-x86_64 install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/convertRelease.pl checkRelease
make -C O.vxWorks-ppc32 -f ../Makefile TOP=../.. \
    T_A=vxWorks-ppc32 install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/convertRelease.pl checkRelease
make -C O.RTEMS-uC5282 -f ../Makefile TOP=../.. \
    T_A=RTEMS-uC5282 install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/convertRelease.pl checkRelease
make -C O.windows-x64-mingw -f ../Makefile TOP=../.. \
    T_A=windows-x64-mingw install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/convertRelease.pl checkRelease
make -C ./exampleApp install
make -C ./src install
make -C O.linux-x86_64 -f ../Makefile TOP=../../.. \
    T_A=linux-x86_64 install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/genVersionHeader.pl -i -t ../../.. -N exampleVERSION -V "" ../O.Common/exampleVersion.h
Updating VCS header ../O.Common/exampleVersion.h
    exampleVERSION = "2018-10-18T16:16-0500"
make[3]: *** No rule to make target '../O.Common/exampleVersion.h', needed by 'devexampleVersion.o'. Stop.
make[2]: *** [/local/anj/base-3.16/configure/RULES_ARCHS:58: install.linux-x86_64] Error 2
make[1]: *** [/local/anj/base-3.16/configure/RULES_DIRS:84: src.install] Error 2
make: *** [/local/anj/base-3.16/configure/RULES_DIRS:84: exampleApp.install] Error 2
Build required

I don't have time to investigate myself right now, but it looks like this doesn't actually do what it's supposed to. One more test with an older GNUmake:

tux% /bin/make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
tux% /bin/make -q --no-print-directory || echo Build required
/bin/make -C ./configure install
/bin/make -C O.linux-x86_64 -f ../Makefile TOP=../.. \
    T_A=linux-x86_64 install
perl -CSD /local/anj/base-3.16/bin/linux-x86_64/convertRelease.pl checkRelease
/bin/make -C O.vxWorks-ppc32 -f ../Makefile TOP=../.. \
    T_A=vxWorks-ppc32 install
perl -C...

Read more...

review: Needs Fixing
Revision history for this message
Andrew Johnson (anj) wrote :

Actually this is doing the right thing after all.

If there is no VCS (the case I was testing above) the version generated contains the build time-stamp using an strftime of '%Y-%m-%dT%H:%M' (hours and minutes but not seconds). Thus the header will almost always be out of date with no VCS.

What confused me above was the messages being output including GNUmake's response to getting an error from the script. The implication is that the genVersionHeader.pl script failed, but it was really just reporting that the header needed to be updated. In question mode when the version doesn't match the message needs to say something slightly different. I think this is easier to understand:

tux% make -sq
tux% make -sq
Outdated VCS header ../O.Common/exampleVersion.h
    has: exampleVERSION = "2018-10-25T14:18-0500"
    needs: exampleVERSION = "2018-10-25T14:19-0500"
make[3]: *** No rule to make target '../O.Common/exampleVersion.h', needed by 'devexampleVersion.o'. Stop.
make[2]: *** [/local/anj/base-3.16/configure/RULES_ARCHS:58: install.linux-x86_64] Error 2
make[1]: *** [/local/anj/base-3.16/configure/RULES_DIRS:84: src.install] Error 2
make: *** [/local/anj/base-3.16/configure/RULES_DIRS:84: exampleApp.install] Error 2

Despite the -s option the script now prints an error if a rebuild is needed, showing how the version number needs to change. A slightly different message is used when the file is actually being changed:

Updating VCS header ../O.Common/exampleVersion.h
    from: exampleVERSION = "2018-10-25T14:18-0500"
    to: exampleVERSION = "2018-10-25T14:22-0500"

Sorry for the confusion. I will commit this change and merge the result, then tag 3.16.2-rc1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/configure/CONFIG_BASE b/configure/CONFIG_BASE
2index 3650427..1b1b9f1 100644
3--- a/configure/CONFIG_BASE
4+++ b/configure/CONFIG_BASE
5@@ -67,7 +67,7 @@ REGISTERRECORDDEVICEDRIVER = $(PERL) $(TOOLS)/registerRecordDeviceDriver.pl
6 CONVERTRELEASE = $(PERL) $(call FIND_TOOL,convertRelease.pl)
7 FULLPATHNAME = $(PERL) $(TOOLS)/fullPathName.pl
8 TAPTOJUNIT = $(PERL) $(TOOLS)/tap-to-junit-xml.pl
9-GENVERSIONHEADER = $(PERL) $(TOOLS)/genVersionHeader.pl $(QUIET_FLAG)
10+GENVERSIONHEADER = $(PERL) $(TOOLS)/genVersionHeader.pl $(QUIET_FLAG) $(QUESTION_FLAG)
11
12 #---------------------------------------------------------------
13 # tools for installing libraries and products
14diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON
15index 79807c2..18e5a2c 100644
16--- a/configure/CONFIG_COMMON
17+++ b/configure/CONFIG_COMMON
18@@ -80,6 +80,7 @@ IOCS_APPL_TOP = $(shell $(FULLPATHNAME) $(INSTALL_LOCATION))
19 NOP = :
20 ECHO = @$(if $(findstring s,$(patsubst T_A=%,,$(MAKEFLAGS))),$(NOP),echo)
21 QUIET_FLAG := $(if $(findstring s,$(MAKEFLAGS)),-q,)
22+QUESTION_FLAG := $(if $(findstring q,$(MAKEFLAGS)),-i,)
23
24 #-------------------------------------------------------
25 ifdef T_A
26diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD
27index 14e7a32..49e6f78 100644
28--- a/configure/RULES_BUILD
29+++ b/configure/RULES_BUILD
30@@ -185,7 +185,7 @@ endif
31
32 # RELEASE file consistency checking
33 checkRelease:
34- $(CONVERTRELEASE) checkRelease
35+ +$(CONVERTRELEASE) checkRelease
36 warnRelease:
37 -$(CONVERTRELEASE) checkRelease
38 noCheckRelease:
39diff --git a/src/tools/genVersionHeader.pl b/src/tools/genVersionHeader.pl
40index c61f14c..92dbd81 100644
41--- a/src/tools/genVersionHeader.pl
42+++ b/src/tools/genVersionHeader.pl
43@@ -23,18 +23,20 @@ my $tfmt = '%Y-%m-%dT%H:%M';
44 $tfmt .= '%z' unless $^O eq 'MSWin32'; # %z returns zone name on Windows
45 my $now = strftime($tfmt, localtime);
46
47-our ($opt_h, $opt_v, $opt_q);
48+our ($opt_d, $opt_h, $opt_i, $opt_v, $opt_q);
49 our $opt_t = '.';
50 our $opt_N = 'VCSVERSION';
51 our $opt_V = $now;
52
53 my $vcs;
54
55-getopts('hvqt:N:V:') && @ARGV == 1
56+getopts('dhivqt:N:V:') && @ARGV == 1
57 or HELP_MESSAGE();
58
59 my ($outfile) = @ARGV;
60
61+if ($opt_d) { exit 0 } # exit if make is run in dry-run mode
62+
63 if (!$vcs && -d "$opt_t/_darcs") { # Darcs
64 print "== Found <top>/_darcs directory\n" if $opt_v;
65 # v1-4-dirty
66@@ -148,6 +150,8 @@ if (open($DST, '+<', $outfile)) {
67 or die "Can't create $outfile: $!\n";
68 }
69
70+if ($opt_i) { exit 1 }; # exit if make is run in "question" mode
71+
72 seek $DST, 0, 0;
73 truncate $DST, 0;
74 print $DST $output;
75@@ -158,9 +162,11 @@ sub HELP_MESSAGE {
76 Usage:
77 genVersionHeader.pl -h
78 Display this Usage message
79- genVersionHeader.pl [-v] [-q] [-t top] [-N NAME] [-V version] output.h";
80+ genVersionHeader.pl [-v] [-d] [-q] [-t top] [-N NAME] [-V version] output.h";
81 Generate or update the header file output.h
82 -v - Verbose (debugging messages)
83+ -d - Dry-run
84+ -i - Question mode
85 -q - Quiet
86 -t top - Path to the module's top (default '$opt_t')
87 -N NAME - Macro name to be defined (default '$opt_N')

Subscribers

People subscribed via source and target branches