timescaledb/scripts/export_prefix_check.sh.in
Joshua Lockerman a7b54b159b Have prefix check verify all functions in headers and clean up missings
This commit makes four changes:
1. Adds the ts_ prefix to some functions that were missed in the last
   pass
2. Adds static to some variables that were confined to a single file but
   missing it
3. Adds the ability to disable using "hidden" visibility by default by
   setting the USE_DEFAULT_VISIBILITY variable
4. Switches the prefix-check in travis to use the flag defined in 3 so
   that the checker now checks all non-static symbols we define
2018-12-12 17:22:24 -05:00

41 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
if [ ! -x "@NM@" ];
then
echo "Cannot check export format because nm is not installed" >&2
exit 1
fi
DEFINED_ONLY="--defined-only"
EXTERN_ONLY="--extern-only"
if nm --help | grep -q llvm; then
DEFINED_ONLY="-defined-only"
EXTERN_ONLY="-extern-only"
fi
# this script outputs all symbols not starting with an allowed prefix
# exported symbols are allowed to start with
# ts_ for regular timescaledb functions
# pg_finfo for metadata defined by PG_FUNCTION_INFO_V1
# we also whitelist a couple of special symbols
# _.*_init module startup functions
# _.*_fini module shutdown functions
# Pg_magic_func used by postgres to check extension compatability
# timescaledb_hello used to test that our name collision resitsance works
# loader_hello used to test that our name collision resitsance works
# test_symbol_conflict used to test that our name collision resitsance works
# all of these symbols start with an additional leading '_' on macos
find @CMAKE_BINARY_DIR@ -not -path '*/\.*' -name '*.so' -print0 \
| xargs -0 @NM@ ${DEFINED_ONLY} ${EXTERN_ONLY} \
| sed -e 's:^/.*$::' -e '/^$/d' -e 's/[a-f0-9]* [A-Za-z] //' \
| grep -v \
-e '^_\?ts_' \
-e '^_\?pg_finfo' \
-e '^_\?_.*_init$' \
-e '^_\?_.*_fini$' \
-e '^_\?Pg_magic_func$' \
-e '^_\?timescaledb_' \
-e '^_\?loader_hello$' \
-e '^_\?test_symbol_conflict$' \