Skip to content

Commit 97b2640

Browse files
committed
meson: prereq: Add src/tools/gen_versioning_script.pl
Currently the logic is all in src/Makefile.shlib. This adds a sketch of a generation script that can be used from meson.
1 parent eb6569f commit 97b2640

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/tools/gen_versioning_script.pl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use strict;
2+
use warnings;
3+
4+
my $format = $ARGV[0] or die "$0: missing required argument: format\n";
5+
my $input = $ARGV[1] or die "$0: missing required argument: input\n";
6+
my $output = $ARGV[2] or die "$0: missing required argument: output\n";
7+
8+
#FIXME: better argument handling
9+
if (not ($format eq 'aix' or $format eq 'darwin' or $format eq 'gnu'))
10+
{
11+
die "$0: $format is not yet handled (only aix, darwin, gnu are)\n";
12+
}
13+
14+
open(my $input_handle, '<', $input)
15+
or die "$0: could not open input file '$input': $!\n";
16+
17+
open(my $output_handle, '>', $output)
18+
or die "$0: could not open output file '$output': $!\n";
19+
20+
21+
if ($format eq 'gnu')
22+
{
23+
print $output_handle "{
24+
global:
25+
";
26+
}
27+
28+
while (<$input_handle>)
29+
{
30+
if (/^#/)
31+
{
32+
# don't do anything with a comment
33+
}
34+
elsif (/^([^\s]+)\s+([^\s]+)/)
35+
{
36+
if ($format eq 'aix')
37+
{
38+
print $output_handle " $1\n";
39+
}
40+
elsif ($format eq 'darwin')
41+
{
42+
print $output_handle " _$1\n";
43+
}
44+
elsif ($format eq 'gnu')
45+
{
46+
print $output_handle " $1;\n";
47+
}
48+
}
49+
else
50+
{
51+
die "$0: unexpected line $_\n";
52+
}
53+
}
54+
55+
if ($format eq 'gnu')
56+
{
57+
print $output_handle " local: *;
58+
};
59+
";
60+
}
61+
62+
exit(0);

0 commit comments

Comments
 (0)