sqlite: Don't rename types / macros
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Generate sqlite3_namespace.h from sqlite3.c and sqlite3.h
|
||||
# Generate sqlite3_namespace.h from sqlite3.c
|
||||
#
|
||||
# This script extracts all public SQLite3 symbols and generates a header
|
||||
# that renames them with a heim_ prefix to avoid symbol conflicts.
|
||||
# This script extracts all public SQLite3 function and data symbols
|
||||
# (marked with SQLITE_API) and generates a header that renames them
|
||||
# with a heim_ prefix to avoid symbol conflicts.
|
||||
#
|
||||
# Usage: ./gen-sqlite3-namespace.sh [sqlite3.c] [sqlite3.h]
|
||||
# Usage: ./gen-sqlite3-namespace.sh [sqlite3.c]
|
||||
#
|
||||
# Run this script after importing a new version of SQLite3.
|
||||
|
||||
set -e
|
||||
|
||||
SQLITE3_C="${1:-sqlite3.c}"
|
||||
SQLITE3_H="${2:-sqlite3.h}"
|
||||
OUTPUT="sqlite3_namespace.h"
|
||||
|
||||
if [ ! -f "$SQLITE3_C" ]; then
|
||||
@@ -20,30 +20,16 @@ if [ ! -f "$SQLITE3_C" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$SQLITE3_H" ]; then
|
||||
echo "Error: $SQLITE3_H not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract symbols from SQLITE_API declarations in sqlite3.c
|
||||
# This catches functions and variables like sqlite3_open, sqlite3_version, etc.
|
||||
# This catches functions and data symbols like sqlite3_open, sqlite3_version, etc.
|
||||
# Also catches sqlite3session_*, sqlite3changegroup_*, sqlite3rbu_*, etc.
|
||||
grep '^SQLITE_API' "$SQLITE3_C" | grep -oE 'sqlite3[a-zA-Z0-9_]*' | sort -u > /tmp/sqlite_funcs.$$
|
||||
|
||||
# Extract type names from typedef declarations in sqlite3.h
|
||||
grep -E '^typedef' "$SQLITE3_H" | grep -oE 'sqlite3[a-zA-Z0-9_]*' | sort -u > /tmp/sqlite_types.$$
|
||||
|
||||
# Also get sqlite_int64 and sqlite_uint64
|
||||
grep -E '^typedef' "$SQLITE3_H" | grep -oE 'sqlite_[a-zA-Z0-9_]*' | sort -u >> /tmp/sqlite_types.$$
|
||||
|
||||
# Combine and deduplicate
|
||||
cat /tmp/sqlite_funcs.$$ /tmp/sqlite_types.$$ | sort -u > /tmp/all_symbols.$$
|
||||
grep '^SQLITE_API' "$SQLITE3_C" | grep -oE 'sqlite3[a-zA-Z0-9_]*' | sort -u > /tmp/sqlite_symbols.$$
|
||||
|
||||
# Clean up temp files on exit
|
||||
trap "rm -f /tmp/sqlite_funcs.$$ /tmp/sqlite_types.$$ /tmp/all_symbols.$$" EXIT
|
||||
trap "rm -f /tmp/sqlite_symbols.$$" EXIT
|
||||
|
||||
# Count symbols
|
||||
NUM_SYMBOLS=$(wc -l < /tmp/all_symbols.$$)
|
||||
NUM_SYMBOLS=$(wc -l < /tmp/sqlite_symbols.$$)
|
||||
echo "Found $NUM_SYMBOLS symbols to rename"
|
||||
|
||||
# Generate the header
|
||||
@@ -82,9 +68,9 @@ cat > "$OUTPUT" << 'HEADER_EOF'
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header renames all public SQLite3 symbols to use a heim_ prefix
|
||||
* to avoid symbol conflicts when both libheimsqlite and libsqlite3 are
|
||||
* loaded in the same process.
|
||||
* This header renames all public SQLite3 function and data symbols to use
|
||||
* a heim_ prefix to avoid symbol conflicts when both libheimsqlite and
|
||||
* libsqlite3 are loaded in the same process.
|
||||
*
|
||||
* This file is auto-generated by gen-sqlite3-namespace.sh
|
||||
* Regenerate after importing a new SQLite version:
|
||||
@@ -100,7 +86,7 @@ HEADER_EOF
|
||||
# Generate the #define lines
|
||||
while read sym; do
|
||||
echo "#define $sym heim_$sym"
|
||||
done < /tmp/all_symbols.$$ >> "$OUTPUT"
|
||||
done < /tmp/sqlite_symbols.$$ >> "$OUTPUT"
|
||||
|
||||
cat >> "$OUTPUT" << 'FOOTER_EOF'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user