Add output path arg in generate-lwlocknames.pl

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.

Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/5e216522-ba3c-f0e6-7f97-5276d0270029@enterprisedb.com
pull/94/head
Andres Freund 3 years ago
parent b3a0d8324c
commit 4f20506fe0
  1. 14
      src/backend/storage/lmgr/generate-lwlocknames.pl
  2. 5
      src/tools/msvc/Solution.pm

@ -5,15 +5,21 @@
use strict;
use warnings;
use Getopt::Long;
my $output_path = '.';
my $lastlockidx = -1;
my $continue = "\n";
GetOptions(
'outdir:s' => \$output_path);
open my $lwlocknames, '<', $ARGV[0] or die;
# Include PID in suffix in case parallel make runs this multiple times.
my $htmp = "lwlocknames.h.tmp$$";
my $ctmp = "lwlocknames.c.tmp$$";
my $htmp = "$output_path/lwlocknames.h.tmp$$";
my $ctmp = "$output_path/lwlocknames.c.tmp$$";
open my $h, '>', $htmp or die "Could not open $htmp: $!";
open my $c, '>', $ctmp or die "Could not open $ctmp: $!";
@ -65,7 +71,7 @@ printf $h "#define NUM_INDIVIDUAL_LWLOCKS %s\n", $lastlockidx + 1;
close $h;
close $c;
rename($htmp, 'lwlocknames.h') || die "rename: $htmp: $!";
rename($ctmp, 'lwlocknames.c') || die "rename: $ctmp: $!";
rename($htmp, "$output_path/lwlocknames.h") || die "rename: $htmp to $output_path/lwlocknames.h: $!";
rename($ctmp, "$output_path/lwlocknames.c") || die "rename: $ctmp: $!";
close $lwlocknames;

@ -625,9 +625,8 @@ sub GenerateFiles
'src/backend/storage/lmgr/lwlocknames.txt'))
{
print "Generating lwlocknames.c and lwlocknames.h...\n";
chdir('src/backend/storage/lmgr');
system('perl generate-lwlocknames.pl lwlocknames.txt');
chdir('../../../..');
my $lmgr = 'src/backend/storage/lmgr';
system("perl $lmgr/generate-lwlocknames.pl --outdir $lmgr $lmgr/lwlocknames.txt");
}
if (IsNewer(
'src/include/storage/lwlocknames.h',

Loading…
Cancel
Save