Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4f20506

Browse files
committed
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
1 parent b3a0d83 commit 4f20506

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/backend/storage/lmgr/generate-lwlocknames.pl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55

66
use strict;
77
use warnings;
8+
use Getopt::Long;
9+
10+
my $output_path = '.';
811

912
my $lastlockidx = -1;
1013
my $continue = "\n";
1114

15+
GetOptions(
16+
'outdir:s' => \$output_path);
17+
1218
open my $lwlocknames, '<', $ARGV[0] or die;
1319

1420
# Include PID in suffix in case parallel make runs this multiple times.
15-
my $htmp = "lwlocknames.h.tmp$$";
16-
my $ctmp = "lwlocknames.c.tmp$$";
21+
my $htmp = "$output_path/lwlocknames.h.tmp$$";
22+
my $ctmp = "$output_path/lwlocknames.c.tmp$$";
1723
open my $h, '>', $htmp or die "Could not open $htmp: $!";
1824
open my $c, '>', $ctmp or die "Could not open $ctmp: $!";
1925

@@ -65,7 +71,7 @@
6571
close $h;
6672
close $c;
6773

68-
rename($htmp, 'lwlocknames.h') || die "rename: $htmp: $!";
69-
rename($ctmp, 'lwlocknames.c') || die "rename: $ctmp: $!";
74+
rename($htmp, "$output_path/lwlocknames.h") || die "rename: $htmp to $output_path/lwlocknames.h: $!";
75+
rename($ctmp, "$output_path/lwlocknames.c") || die "rename: $ctmp: $!";
7076

7177
close $lwlocknames;

src/tools/msvc/Solution.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,8 @@ sub GenerateFiles
625625
'src/backend/storage/lmgr/lwlocknames.txt'))
626626
{
627627
print "Generating lwlocknames.c and lwlocknames.h...\n";
628-
chdir('src/backend/storage/lmgr');
629-
system('perl generate-lwlocknames.pl lwlocknames.txt');
630-
chdir('../../../..');
628+
my $lmgr = 'src/backend/storage/lmgr';
629+
system("perl $lmgr/generate-lwlocknames.pl --outdir $lmgr $lmgr/lwlocknames.txt");
631630
}
632631
if (IsNewer(
633632
'src/include/storage/lwlocknames.h',

0 commit comments

Comments
 (0)