forked from confluentinc/librdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lds-gen.py
executable file
·38 lines (30 loc) · 842 Bytes
/
lds-gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
# Ignore static (unused) functions
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', last_line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')