public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andres Freund <[email protected]>
Subject: [PATCH v12 04/15] meson: prereq: Add src/tools/gen_export.pl
Date: Wed, 19 Jan 2022 23:36:50 -0800
Currently the logic is all in src/Makefile.shlib. This adds a sketch of a
generation script that can be used from meson.
Author: Andres Freund <[email protected]>
Reviewed-By: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/[email protected]
---
src/tools/gen_export.pl | 81 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100644 src/tools/gen_export.pl
diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl
new file mode 100644
index 00000000000..3a368c85381
--- /dev/null
+++ b/src/tools/gen_export.pl
@@ -0,0 +1,81 @@
+use strict;
+use warnings;
+use Getopt::Long;
+
+my $format;
+my $libname;
+my $input;
+my $output;
+
+GetOptions(
+ 'format:s' => \$format,
+ 'libname:s' => \$libname,
+ 'input:s' => \$input,
+ 'output:s' => \$output) or die "wrong arguments";
+
+if (not ($format eq 'aix' or $format eq 'darwin' or $format eq 'gnu' or $format eq 'win'))
+{
+ die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
+}
+
+open(my $input_handle, '<', $input)
+ or die "$0: could not open input file '$input': $!\n";
+
+open(my $output_handle, '>', $output)
+ or die "$0: could not open output file '$output': $!\n";
+
+
+if ($format eq 'gnu')
+{
+ print $output_handle "{
+ global:
+";
+}
+elsif ($format eq 'win')
+{
+ # XXX: Looks like specifying LIBRARY $libname is optional, which makes it
+ # easier to build a generic command for generating export files...
+ if ($libname)
+ {
+ print $output_handle "LIBRARY $libname\n";
+ }
+ print $output_handle "EXPORTS\n";
+}
+
+while (<$input_handle>)
+{
+ if (/^#/)
+ {
+ # don't do anything with a comment
+ }
+ elsif (/^(\S+)\s+(\S+)/)
+ {
+ if ($format eq 'aix')
+ {
+ print $output_handle " $1\n";
+ }
+ elsif ($format eq 'darwin')
+ {
+ print $output_handle " _$1\n";
+ }
+ elsif ($format eq 'gnu')
+ {
+ print $output_handle " $1;\n";
+ }
+ elsif ($format eq 'win')
+ {
+ print $output_handle " $1 @ $2\n";
+ }
+ }
+ else
+ {
+ die "$0: unexpected line $_\n";
+ }
+}
+
+if ($format eq 'gnu')
+{
+ print $output_handle " local: *;
+};
+";
+}
--
2.37.0.3.g30cc8d0f14
--3jz64y4qgcz5d4ku
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v12-0005-meson-prereq-Refactor-PG_TEST_EXTRA-logic-in-aut.patch"
view thread (102+ 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 v12 04/15] meson: prereq: Add src/tools/gen_export.pl
In-Reply-To: <no-message-id-1858993@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