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

Commit adba4b7

Browse files
committed
Add output directory option to gen_node_support.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 c8a9246 commit adba4b7

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

src/backend/nodes/gen_node_support.pl

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@
1919
use warnings;
2020

2121
use File::Basename;
22+
use Getopt::Long;
2223

2324
use FindBin;
2425
use lib "$FindBin::RealBin/../catalog";
2526

2627
use Catalog; # for RenameTempFile
2728

29+
my $output_path = '.';
30+
31+
GetOptions(
32+
'outdir:s' => \$output_path)
33+
or die "$0: wrong arguments";
34+
2835

2936
# Test whether first argument is element of the list in the second
3037
# argument
@@ -576,7 +583,7 @@ sub elem
576583
# nodetags.h
577584

578585
push @output_files, 'nodetags.h';
579-
open my $nt, '>', 'nodetags.h' . $tmpext or die $!;
586+
open my $nt, '>', "$output_path/nodetags.h$tmpext" or die "$output_path/nodetags.h$tmpext: $!";
580587

581588
printf $nt $header_comment, 'nodetags.h';
582589

@@ -620,13 +627,13 @@ sub elem
620627
# copyfuncs.c, equalfuncs.c
621628

622629
push @output_files, 'copyfuncs.funcs.c';
623-
open my $cff, '>', 'copyfuncs.funcs.c' . $tmpext or die $!;
630+
open my $cff, '>', "$output_path/copyfuncs.funcs.c$tmpext" or die $!;
624631
push @output_files, 'equalfuncs.funcs.c';
625-
open my $eff, '>', 'equalfuncs.funcs.c' . $tmpext or die $!;
632+
open my $eff, '>', "$output_path/equalfuncs.funcs.c$tmpext" or die $!;
626633
push @output_files, 'copyfuncs.switch.c';
627-
open my $cfs, '>', 'copyfuncs.switch.c' . $tmpext or die $!;
634+
open my $cfs, '>', "$output_path/copyfuncs.switch.c$tmpext" or die $!;
628635
push @output_files, 'equalfuncs.switch.c';
629-
open my $efs, '>', 'equalfuncs.switch.c' . $tmpext or die $!;
636+
open my $efs, '>', "$output_path/equalfuncs.switch.c$tmpext" or die $!;
630637

631638
printf $cff $header_comment, 'copyfuncs.funcs.c';
632639
printf $eff $header_comment, 'equalfuncs.funcs.c';
@@ -819,13 +826,13 @@ sub elem
819826
# outfuncs.c, readfuncs.c
820827

821828
push @output_files, 'outfuncs.funcs.c';
822-
open my $off, '>', 'outfuncs.funcs.c' . $tmpext or die $!;
829+
open my $off, '>', "$output_path/outfuncs.funcs.c$tmpext" or die $!;
823830
push @output_files, 'readfuncs.funcs.c';
824-
open my $rff, '>', 'readfuncs.funcs.c' . $tmpext or die $!;
831+
open my $rff, '>', "$output_path/readfuncs.funcs.c$tmpext" or die $!;
825832
push @output_files, 'outfuncs.switch.c';
826-
open my $ofs, '>', 'outfuncs.switch.c' . $tmpext or die $!;
833+
open my $ofs, '>', "$output_path/outfuncs.switch.c$tmpext" or die $!;
827834
push @output_files, 'readfuncs.switch.c';
828-
open my $rfs, '>', 'readfuncs.switch.c' . $tmpext or die $!;
835+
open my $rfs, '>', "$output_path/readfuncs.switch.c$tmpext" or die $!;
829836

830837
printf $off $header_comment, 'outfuncs.funcs.c';
831838
printf $rff $header_comment, 'readfuncs.funcs.c';
@@ -1130,7 +1137,7 @@ sub elem
11301137
# now rename the temporary files to their final names
11311138
foreach my $file (@output_files)
11321139
{
1133-
Catalog::RenameTempFile($file, $tmpext);
1140+
Catalog::RenameTempFile("$output_path/$file", $tmpext);
11341141
}
11351142

11361143

@@ -1144,7 +1151,7 @@ END
11441151
{
11451152
foreach my $file (@output_files)
11461153
{
1147-
unlink($file . $tmpext);
1154+
unlink("$output_path/$file$tmpext");
11481155
}
11491156
}
11501157

src/tools/msvc/Solution.pm

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,12 @@ EOF
865865
utils/rel.h
866866
);
867867

868-
chdir('src/backend/nodes');
868+
my @node_files = map { "src/include/$_" } @node_headers;
869869

870-
my @node_files = map { "../../../src/include/$_" } @node_headers;
871-
872-
system("perl gen_node_support.pl @node_files");
873-
open(my $f, '>', 'node-support-stamp')
870+
system("perl src/backend/nodes/gen_node_support.pl --outdir src/backend/nodes @node_files");
871+
open(my $f, '>', 'src/backend/nodes/node-support-stamp')
874872
|| confess "Could not touch node-support-stamp";
875873
close($f);
876-
chdir('../../..');
877874
}
878875

879876
if (IsNewer(

0 commit comments

Comments
 (0)