2020-04-29 10:19:32 +03:00
|
|
|
#!/usr/bin/env python3
|
2016-01-13 15:22:02 +03:00
|
|
|
#
|
2019-05-27 16:27:22 +03:00
|
|
|
# librdkafka - Apache Kafka C library
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Magnus Edenhill
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions and the following disclaimer in the documentation
|
|
|
|
# and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2016-01-13 15:22:02 +03:00
|
|
|
#
|
|
|
|
# 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:
|
2021-05-19 17:56:00 +03:00
|
|
|
if line.startswith('typedef'):
|
|
|
|
last_line = line
|
|
|
|
continue
|
|
|
|
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_[\w_]+)\s*\([^)]', line)
|
2016-01-13 15:22:02 +03:00
|
|
|
if m:
|
|
|
|
sym = m.group(2)
|
2016-05-18 14:24:28 +03:00
|
|
|
# Ignore static (unused) functions
|
2021-10-28 19:01:18 +03:00
|
|
|
m2 = re.match(
|
|
|
|
r'(RD_UNUSED|__attribute__\(\(unused\)\))',
|
|
|
|
last_line)
|
2016-01-13 15:22:02 +03:00
|
|
|
if not m2:
|
|
|
|
funcs.append(sym)
|
|
|
|
last_line = ''
|
|
|
|
else:
|
|
|
|
last_line = line
|
|
|
|
|
2019-12-13 14:35:37 +03:00
|
|
|
# Special symbols not covered by above matches or not exposed in
|
|
|
|
# the public header files.
|
|
|
|
funcs.append('rd_ut_coverage_check')
|
|
|
|
|
2016-01-26 16:50:04 +03:00
|
|
|
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
|
|
|
|
print('{\n global:')
|
2016-01-13 15:22:02 +03:00
|
|
|
if len(funcs) == 0:
|
2016-01-26 16:50:04 +03:00
|
|
|
print(' *;')
|
2016-01-13 15:22:02 +03:00
|
|
|
else:
|
|
|
|
for f in sorted(funcs):
|
2016-01-26 16:50:04 +03:00
|
|
|
print(' %s;' % f)
|
2016-01-13 15:22:02 +03:00
|
|
|
|
2016-01-28 10:19:15 +03:00
|
|
|
print('local:\n *;')
|
|
|
|
|
2016-01-26 16:50:04 +03:00
|
|
|
print('};')
|