Repository Public License
1#!/bin/bash2# ORIX Convert — EmbeddedEngines/duckdb/build.sh3# Description: Downloads the official DuckDB shared library for macOS (pinned version + SHA-256), thins it to arm64,4# and wraps it into EmbeddedEngines/duckdb/CDuckDB.xcframework (SwiftPM binaryTarget of Packages/EngineData).5# Author: Simon-Pierre Boucher — contact@spboucher.ai6set -euo pipefail7export LC_ALL=C8export MACOSX_DEPLOYMENT_TARGET=15.09cd "$(dirname "$0")"1011VERSION="v2.0.1"12ARCHIVE="duckdb-shared-libs-osx-universal.tar.gz"13SHA256="9a4be5a2a31ad5bb8c92bf37f18d59b9c10a79b392d7848cabd6eb2e05837449"14URL="https://github.com/duckdb/duckdb/releases/download/${VERSION}/${ARCHIVE}"1516if [[ -d CDuckDB.xcframework && "${1:-}" != "--force" ]]; then17 echo "CDuckDB.xcframework already present (use --force to rebuild)"; exit 018fi1920rm -rf work && mkdir -p work/dl work/thin work/Headers21curl -fsSL -o "work/${ARCHIVE}" "${URL}"22echo "${SHA256} work/${ARCHIVE}" | shasum -a 256 -c -23tar -xzf "work/${ARCHIVE}" -C work/dl2425# arm64 only (the app is Apple Silicon only); the ad-hoc signature is replaced when the app is signed.26lipo -thin arm64 work/dl/libduckdb.dylib -output work/thin/libduckdb.dylib27codesign --force --sign - work/thin/libduckdb.dylib2829cp work/dl/duckdb.h work/Headers/30printf 'module CDuckDB {\n header "duckdb.h"\n link "duckdb"\n export *\n}\n' > work/Headers/module.modulemap3132rm -rf CDuckDB.xcframework33xcodebuild -create-xcframework -library work/thin/libduckdb.dylib -headers work/Headers -output CDuckDB.xcframework >/dev/null34echo "DuckDB ${VERSION} ready: $(lipo -archs CDuckDB.xcframework/macos-arm64/libduckdb.dylib), $(du -sh CDuckDB.xcframework | cut -f1)"35otool -L CDuckDB.xcframework/macos-arm64/libduckdb.dylib | sed -n '2,20p'3637# Keep module maps out of the shared include directory Xcode builds (see normalize-xcframework.sh).38"$(cd "$(dirname "$0")/.." && pwd)/normalize-xcframework.sh" "$(cd "$(dirname "$0")" && pwd)"/*.xcframework39