Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Add output path arg in generate-lwlocknames.pl
authorAndres Freund <andres@anarazel.de>
Mon, 18 Jul 2022 19:13:14 +0000 (12:13 -0700)
committerAndres Freund <andres@anarazel.de>
Mon, 18 Jul 2022 19:24:32 +0000 (12:24 -0700)
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

src/backend/storage/lmgr/generate-lwlocknames.pl
src/tools/msvc/Solution.pm

index 4565ff8760e8194ebc5068142ed593424c215e8d..5fadc4503bff9df9aedf34258f48fe5903961d7b 100644 (file)
@@ -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;
index 312f9c3058e62f611d928634028af129f495c829..98121c0f5f8bfdcfde41cd89c2eb4327c88dd22e 100644 (file)
@@ -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',