Merge dev: macOS Berkeley DB build fix (build.sh)

Derive the macOS BDB depends triple from the build arch + pass the BDB paths
to CMake, so the full-node mac release builds the wallet-rebuild helper on
Intel (x86_64) as well as Apple Silicon.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-02 02:29:37 -05:00

View File

@@ -213,6 +213,21 @@ require_wallet_rebuild_helper() {
info " wallet-rebuild helper present: $helper" info " wallet-rebuild helper present: $helper"
} }
# Vendored Berkeley DB depends directory for the macOS wallet-rebuild helper, by TARGET arch. The daemon
# links a static libdb-6.2; the helper must match the build arch, so derive the triple from it rather than
# hardcoding one. Single-arch: x86_64 -> x86_64-apple-darwin, arm64 -> aarch64-apple-darwin. "universal"
# (or anything unexpected) falls back to the host arch — a universal .app needs a universal libdb, so if
# only a single-arch libdb is vendored, build single-arch via DRAGONX_MAC_ARCHS.
mac_bdb_dir() {
local arch="$1" triple
case "$arch" in
x86_64) triple="x86_64-apple-darwin" ;;
arm64) triple="aarch64-apple-darwin" ;;
*) [[ "$(uname -m)" == "arm64" ]] && triple="aarch64-apple-darwin" || triple="x86_64-apple-darwin" ;;
esac
printf '%s/external/dragonx/depends/%s\n' "$SCRIPT_DIR" "$triple"
}
# ── Helper: find resource files ────────────────────────────────────────────── # ── Helper: find resource files ──────────────────────────────────────────────
find_sapling_params() { find_sapling_params() {
local dirs=( local dirs=(
@@ -1083,6 +1098,12 @@ TOOLCHAIN
fi fi
info "Configuring (cross-compile via osxcross) ..." info "Configuring (cross-compile via osxcross) ..."
# Vendored static libdb for the recovery helper (full-node only), by target arch; see mac_bdb_dir.
local mac_bdb; mac_bdb="$(mac_bdb_dir "$MAC_ARCH")"
local BDB_ARGS=()
if should_bundle_full_node_assets && [[ -f "$mac_bdb/lib/libdb-6.2.a" && -f "$mac_bdb/include/db.h" ]]; then
BDB_ARGS=( -DBDB_INCLUDE_DIR="$mac_bdb/include" -DBDB_LIBRARY="$mac_bdb/lib/libdb-6.2.a" )
fi
cmake "$SCRIPT_DIR" \ cmake "$SCRIPT_DIR" \
-DCMAKE_TOOLCHAIN_FILE="$bd/osxcross-toolchain.cmake" \ -DCMAKE_TOOLCHAIN_FILE="$bd/osxcross-toolchain.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
@@ -1090,6 +1111,7 @@ TOOLCHAIN
-DDRAGONX_USE_SYSTEM_SDL3=OFF \ -DDRAGONX_USE_SYSTEM_SDL3=OFF \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
${COMPILER_RT:+-DOSXCROSS_COMPILER_RT="$COMPILER_RT"} \ ${COMPILER_RT:+-DOSXCROSS_COMPILER_RT="$COMPILER_RT"} \
"${BDB_ARGS[@]}" \
"${CMAKE_LITE_ARGS[@]}" "${CMAKE_LITE_ARGS[@]}"
else else
# Build libsodium as universal if needed # Build libsodium as universal if needed
@@ -1111,12 +1133,19 @@ TOOLCHAIN
fi fi
info "Configuring (native macOS, arch: $MAC_ARCHS) ..." info "Configuring (native macOS, arch: $MAC_ARCHS) ..."
# Point CMake at the vendored static libdb for the recovery helper (full-node only); see mac_bdb_dir.
local mac_bdb; mac_bdb="$(mac_bdb_dir "$MAC_ARCH")"
local BDB_ARGS=()
if should_bundle_full_node_assets && [[ -f "$mac_bdb/lib/libdb-6.2.a" && -f "$mac_bdb/include/db.h" ]]; then
BDB_ARGS=( -DBDB_INCLUDE_DIR="$mac_bdb/include" -DBDB_LIBRARY="$mac_bdb/lib/libdb-6.2.a" )
fi
cmake "$SCRIPT_DIR" \ cmake "$SCRIPT_DIR" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \
-DDRAGONX_USE_SYSTEM_SDL3=OFF \ -DDRAGONX_USE_SYSTEM_SDL3=OFF \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_OSX_ARCHITECTURES="$MAC_ARCHS" \ -DCMAKE_OSX_ARCHITECTURES="$MAC_ARCHS" \
"${BDB_ARGS[@]}" \
"${CMAKE_LITE_ARGS[@]}" "${CMAKE_LITE_ARGS[@]}"
fi fi
@@ -1128,7 +1157,7 @@ TOOLCHAIN
# A full-node release MUST include the recovery helper. macOS needs a static libdb-6.2 (Homebrew # A full-node release MUST include the recovery helper. macOS needs a static libdb-6.2 (Homebrew
# berkeley-db for a native build, or a vendored external/dragonx/depends/<triple>) — otherwise CMake # berkeley-db for a native build, or a vendored external/dragonx/depends/<triple>) — otherwise CMake
# skips the target and this fails loudly rather than shipping a mac release with no recovery option. # skips the target and this fails loudly rather than shipping a mac release with no recovery option.
require_wallet_rebuild_helper "bin/dragonx-wallet-rebuild" "$SCRIPT_DIR/external/dragonx/depends/aarch64-apple-darwin" require_wallet_rebuild_helper "bin/dragonx-wallet-rebuild" "$(mac_bdb_dir "$MAC_ARCH")"
# Strip — use osxcross strip for cross-builds # Strip — use osxcross strip for cross-builds
if $IS_CROSS; then if $IS_CROSS; then