public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andres Freund <[email protected]>
Subject: [PATCH v10 05/16] meson: prereq: Add output path arg in generate-lwlocknames.pl
Date: Wed, 19 Jan 2022 23:36:50 -0800

---
 src/backend/storage/lmgr/generate-lwlocknames.pl | 14 ++++++++++----
 src/tools/msvc/Solution.pm                       |  5 ++---
 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 fcbc1a20772..664fcea0d87 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -624,9 +624,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',
-- 
2.37.0.3.g30cc8d0f14


--mqd6wwweo5bfrq2e
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v10-0006-meson-prereq-generate-errcodes.pl-Accept-output-.patch"



view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v10 05/16] meson: prereq: Add output path arg in generate-lwlocknames.pl
  In-Reply-To: <no-message-id-1858760@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox