On 5/10/21 12:07 PM, Tom Lane wrote: > Andrew Dunstan <and...@dunslane.net> writes: >> On 5/10/21 7:16 AM, Dagfinn Ilmari Mannsåker wrote: >>> Peter Eisentraut <peter.eisentr...@enterprisedb.com> writes: >>>> This recipe doesn't produce a Gen_dummy_probes.pl that matches exactly >>>> the one that is there now. If this is going to be the preferred method, >>>> then we should generate it once so that it matches going forward. >>> Which version of perltidy do you have installed? For me it generates >>> identical versions using any of 20170521 (per src/tools/pgindent/README), >>> 20201207 (what I happened to have installed before), and 20210402 (the >>> latest). >> Yep: > For me, using App-s2p-1.003 and perltidy v20170521, it works > as long as I start with the previous version of > Gen_dummy_probes.pl in place. I first tried to test this by > "rm Gen_dummy_probes.pl; make Gen_dummy_probes.pl", and what > I got was a script without all the initial commentary nor > the first line of actual Perl code. > > I don't think this is good practice; it implies that any > accidental corruption of the commentary would be carried > forward. I think we should be extracting the commentary > from Gen_dummy_probes.sed. > >
I don't know how likely accidental corruption is, but OK, let's not make the next generation dependent on the current generation of the file. The simplest way around that seems to me to cache the perl prolog, as in the attached patch Is that more to your liking? I also adjusted it so we pick up the first line of code from s2p rather than from the prolog, which is now just comments and the #! line. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
diff --git a/src/backend/utils/Gen_dummy_probes.pl.prolog b/src/backend/utils/Gen_dummy_probes.pl.prolog new file mode 100644 index 0000000000..1c8993377d --- /dev/null +++ b/src/backend/utils/Gen_dummy_probes.pl.prolog @@ -0,0 +1,19 @@ +#! /usr/bin/perl -w +#------------------------------------------------------------------------- +# +# Gen_dummy_probes.pl +# Perl script that generates probes.h file when dtrace is not available +# +# Portions Copyright (c) 2008-2021, PostgreSQL Global Development Group +# +# +# IDENTIFICATION +# src/backend/utils/Gen_dummy_probes.pl +# +# This program was generated by running perl's s2p over Gen_dummy_probes.sed +# +#------------------------------------------------------------------------- + +# turn off perlcritic for autogenerated code +## no critic + diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile index bcf9dd41ad..d2c0f5764c 100644 --- a/src/backend/utils/Makefile +++ b/src/backend/utils/Makefile @@ -92,9 +92,9 @@ $(top_builddir)/src/include/utils/probes.h: probes.h # Nothing depends on it, so it will never be called unless explicitly requested # The last two lines of the recipe format the script according to our # standard and put back some blank lines for improved readability. -Gen_dummy_probes.pl: Gen_dummy_probes.sed - perl -ni -e ' print; exit if /^\$$0/;' $@ - s2p -f $< | sed -e 1,4d -e '/# #/d' -e '$$d' >> $@ +Gen_dummy_probes.pl: Gen_dummy_probes.sed Gen_dummy_probes.pl.prolog + cp Gen_dummy_probes.pl.prolog $@ + s2p -f $< | sed -e 1,3d -e '/# #/ d' -e '$$d' >> $@ perltidy --profile=../../tools/pgindent/perltidyrc $@ perl -pi -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\ -e '$$lb = m/^\n/; ' $@