aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-07-18 12:13:14 -0700
committerAndres Freund <andres@anarazel.de>2022-07-18 12:24:32 -0700
commit4f20506fe04092a9174bfc6dea908c3dfdbaaf1e (patch)
tree0f1b28c6b8424032fd0d9bae3e6790430c661fd8 /src
parentb3a0d8324cf1f02c04a7099a436cfd68cfbf4566 (diff)
downloadpostgresql-4f20506fe04092a9174bfc6dea908c3dfdbaaf1e.tar.gz
postgresql-4f20506fe04092a9174bfc6dea908c3dfdbaaf1e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/lmgr/generate-lwlocknames.pl14
-rw-r--r--src/tools/msvc/Solution.pm5
2 files changed, 12 insertions, 7 deletions
diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl
index 4565ff8760e..5fadc4503bf 100644
--- a/src/backend/storage/lmgr/generate-lwlocknames.pl
+++ b/src/backend/storage/lmgr/generate-lwlocknames.pl
@@ -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;
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 312f9c3058e..98121c0f5f8 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -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',