Improve grammar of options for command arrays in TAP tests
[pgsql.git] / src / tools / gen_export.pl
blob86a7742b36981d9b1f7f5fc9d858631d00282e5f
2 # Copyright (c) 2024-2025, PostgreSQL Global Development Group
4 use strict;
5 use warnings FATAL => 'all';
6 use Getopt::Long;
8 my $format;
9 my $libname;
10 my $input;
11 my $output;
13 GetOptions(
14 'format:s' => \$format,
15 'libname:s' => \$libname,
16 'input:s' => \$input,
17 'output:s' => \$output) or die "wrong arguments";
19 if (not( $format eq 'darwin'
20 or $format eq 'gnu'
21 or $format eq 'win'))
23 die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
26 open(my $input_handle, '<', $input)
27 or die "$0: could not open input file '$input': $!\n";
29 open(my $output_handle, '>', $output)
30 or die "$0: could not open output file '$output': $!\n";
33 if ($format eq 'gnu')
35 print $output_handle "{
36 global:
39 elsif ($format eq 'win')
41 # XXX: Looks like specifying LIBRARY $libname is optional, which makes it
42 # easier to build a generic command for generating export files...
43 if ($libname)
45 print $output_handle "LIBRARY $libname\n";
47 print $output_handle "EXPORTS\n";
50 while (<$input_handle>)
52 if (/^#/)
54 # don't do anything with a comment
56 elsif (/^(\S+)\s+(\S+)/)
58 if ($format eq 'darwin')
60 print $output_handle "_$1\n";
62 elsif ($format eq 'gnu')
64 print $output_handle " $1;\n";
66 elsif ($format eq 'win')
68 print $output_handle "$1 @ $2\n";
71 else
73 die "$0: unexpected line $_\n";
77 if ($format eq 'gnu')
79 print $output_handle " local: *;