mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
psql: Output dir and dependency generation for sql_help
This is in preparation for building postgres with meson / ninja. When building with meson, commands are run at the root of the build tree. Add an option to put build output into the appropriate place. This can be utilized by src/tools/msvc/ for a minor simplification, which also provides some coverage for the new option. To deal with dependencies to the variable set of input files to this script, add an option to generate a dependency file (which meson / ninja can consume). Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Discussion: https://postgr.es/m/5e216522-ba3c-f0e6-7f97-5276d0270029@enterprisedb.com
This commit is contained in:
@ -56,7 +56,7 @@ sql_help.c: sql_help.h
|
||||
touch $@
|
||||
|
||||
sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
|
||||
$(PERL) $< $(REFDOCDIR) $*
|
||||
$(PERL) $< --docdir $(REFDOCDIR) --basename $*
|
||||
|
||||
psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
|
||||
psqlscanslash.c: FLEX_NO_BACKUP=yes
|
||||
|
@ -21,21 +21,24 @@
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
|
||||
my $docdir = $ARGV[0] or die "$0: missing required argument: docdir\n";
|
||||
my $hfile = $ARGV[1] . '.h'
|
||||
or die "$0: missing required argument: output file\n";
|
||||
my $cfile = $ARGV[1] . '.c';
|
||||
my $docdir = '';
|
||||
my $outdir = '.';
|
||||
my $depfile = '';
|
||||
my $hfilebasename = '';
|
||||
|
||||
my $hfilebasename;
|
||||
if ($hfile =~ m!.*/([^/]+)$!)
|
||||
{
|
||||
$hfilebasename = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hfilebasename = $hfile;
|
||||
}
|
||||
GetOptions(
|
||||
'docdir=s' => \$docdir,
|
||||
'outdir=s' => \$outdir,
|
||||
'basename=s' => \$hfilebasename,
|
||||
'depfile=s' => \$depfile,) or die "$0: wrong arguments";
|
||||
|
||||
$docdir or die "$0: missing required argument: docdir\n";
|
||||
$hfilebasename or die "$0: missing required argument: basename\n";
|
||||
|
||||
my $hfile = $hfilebasename . '.h';
|
||||
my $cfile = $hfilebasename . '.c';
|
||||
|
||||
my $define = $hfilebasename;
|
||||
$define =~ tr/a-z/A-Z/;
|
||||
@ -43,11 +46,18 @@ $define =~ s/\W/_/g;
|
||||
|
||||
opendir(DIR, $docdir)
|
||||
or die "$0: could not open documentation source dir '$docdir': $!\n";
|
||||
open(my $hfile_handle, '>', $hfile)
|
||||
open(my $hfile_handle, '>', "$outdir/$hfile")
|
||||
or die "$0: could not open output file '$hfile': $!\n";
|
||||
open(my $cfile_handle, '>', $cfile)
|
||||
open(my $cfile_handle, '>', "$outdir/$cfile")
|
||||
or die "$0: could not open output file '$cfile': $!\n";
|
||||
|
||||
my $depfile_handle;
|
||||
if ($depfile)
|
||||
{
|
||||
open($depfile_handle, '>', $depfile)
|
||||
or die "$0: could not open output file '$depfile': $!\n";
|
||||
}
|
||||
|
||||
print $hfile_handle "/*
|
||||
* *** Do not change this file by hand. It is automatically
|
||||
* *** generated from the DocBook documentation.
|
||||
@ -98,6 +108,9 @@ foreach my $file (sort readdir DIR)
|
||||
my ($cmdid, @cmdnames, $cmddesc, $cmdsynopsis);
|
||||
$file =~ /\.sgml$/ or next;
|
||||
|
||||
print $depfile_handle "$outdir/$cfile $outdir/$hfile: $docdir/$file\n"
|
||||
if ($depfile);
|
||||
|
||||
open(my $fh, '<', "$docdir/$file") or next;
|
||||
my $filecontent = join('', <$fh>);
|
||||
close $fh;
|
||||
@ -216,4 +229,5 @@ print $hfile_handle "
|
||||
|
||||
close $cfile_handle;
|
||||
close $hfile_handle;
|
||||
close $depfile_handle if ($depfile);
|
||||
closedir DIR;
|
||||
|
@ -692,9 +692,8 @@ sub GenerateFiles
|
||||
if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
|
||||
{
|
||||
print "Generating sql_help.h...\n";
|
||||
chdir('src/bin/psql');
|
||||
system("perl create_help.pl ../../../doc/src/sgml/ref sql_help");
|
||||
chdir('../../..');
|
||||
my $psql = 'src/bin/psql';
|
||||
system("perl $psql/create_help.pl --docdir doc/src/sgml/ref --outdir $psql --basename sql_help");
|
||||
}
|
||||
|
||||
if (IsNewer('src/common/kwlist_d.h', 'src/include/parser/kwlist.h'))
|
||||
|
Reference in New Issue
Block a user