Re: Why do we have perl and sed versions of Gen_dummy_probes?
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, pgsql-hackers@postgresql.org, Michael Paquier <michael@paquier.xyz>, Craig Ringer <craig.ringer@enterprisedb.com>
Date: 2021-05-11T19:46:40Z
Lists: pgsql-hackers
On 5/11/21 2:30 PM, Andrew Dunstan wrote:
> On 5/11/21 1:21 PM, Andres Freund wrote:
>> Hi,
>>
>> On 2021-05-11 10:52:22 -0400, Tom Lane wrote:
>>> Works for me. One other thought --- do we care whether this works
>>> in a VPATH build, and if so does it? The $< and $@ references should
>>> be OK, but I'm betting you need $(srcdir)/Gen_dummy_probes.pl.prolog
>>> or the like.
>> It doesn't work in a VPATH build right now, FWIW. $@, $< will point to a
>> local file in the build directory, right now. And the path to perltidyrc
>> doesn't work either. It seems to work after the following modifications
>>
>> diff --git i/src/backend/utils/Makefile w/src/backend/utils/Makefile
>> index bcf9dd41adf..ca733d12dce 100644
>> --- i/src/backend/utils/Makefile
>> +++ w/src/backend/utils/Makefile
>> @@ -92,10 +92,10 @@ $(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
>> +$(top_srcdir)/src/backend/utils/Gen_dummy_probes.pl: $(top_srcdir)/src/backend/utils/Gen_dummy_probes.sed
>> perl -ni -e ' print; exit if /^\$$0/;' $@
>> s2p -f $< | sed -e 1,4d -e '/# #/d' -e '$$d' >> $@
>> - perltidy --profile=../../tools/pgindent/perltidyrc $@
>> + perltidy --profile=$(top_srcdir)/src/tools/pgindent/perltidyrc $@
>> perl -pi -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\
>> -e '$$lb = m/^\n/; ' $@
>>
>
> Yeah, but this will create the perl file in the vpath directory where it
> won't ever be used anyway. You really want this back in the source
> directory where you can check it in etc.
>
> I came up with this:
>
>
> Gen_dummy_probes.pl: $(top_srcdir)/$(subdir)/Gen_dummy_probes.sed $(top_srcdir)/$(subdir)/Gen_dummy_probes.pl.prolog
> cp $(top_srcdir)/$(subdir)/Gen_dummy_probes.pl.prolog $(top_srcdir)/$(subdir)/$@
> s2p -f $< | sed -e 1,3d -e '/# #/ d' -e '$$d' >> $(top_srcdir)/$(subdir)/$@
> perltidy --profile=$(top_srcdir)/$(subdir)/../../tools/pgindent/perltidyrc $(top_srcdir)/$(subdir)/$@
> perl -pi -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\
> -e '$$lb = m/^\n/; ' $(top_srcdir)/$(subdir)/$@
>
>
> I'm not aware of any other case where we generate an in-tree file from a
> vpath, which is why it feels strange.
Simplified version:
Gen_dummy_probes.pl: $(srcdir)/Gen_dummy_probes.sed $(srcdir)/Gen_dummy_probes.pl.prolog
cp $(srcdir)/Gen_dummy_probes.pl.prolog $(srcdir)/$@
s2p -f $< | sed -e 1,3d -e '/# #/ d' -e '$$d' >> $(srcdir)/$@
perltidy --profile=$(srcdir)/../../tools/pgindent/perltidyrc $(srcdir)/$@
perl -pi -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};'\
-e '$$lb = m/^\n/; ' $(srcdir)/$@
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Commits
-
Tweak generation of Gen_dummy_probes.pl
- 0bf62931cae0 14.0 landed
-
Add a README and Makefile recipe for Gen_dummy_probes.pl
- 8292c0675a79 14.0 landed
-
Remove dependency on psed for MSVC builds.
- 5d0320105699 9.6.0 cited