diff --git a/build.sh b/build.sh index e76cc82..91049e3 100755 --- a/build.sh +++ b/build.sh @@ -213,6 +213,21 @@ require_wallet_rebuild_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 ────────────────────────────────────────────── find_sapling_params() { local dirs=( @@ -1083,6 +1098,12 @@ TOOLCHAIN fi 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" \ -DCMAKE_TOOLCHAIN_FILE="$bd/osxcross-toolchain.cmake" \ -DCMAKE_BUILD_TYPE=Release \ @@ -1090,6 +1111,7 @@ TOOLCHAIN -DDRAGONX_USE_SYSTEM_SDL3=OFF \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ ${COMPILER_RT:+-DOSXCROSS_COMPILER_RT="$COMPILER_RT"} \ + "${BDB_ARGS[@]}" \ "${CMAKE_LITE_ARGS[@]}" else # Build libsodium as universal if needed @@ -1111,12 +1133,19 @@ TOOLCHAIN fi 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" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \ -DDRAGONX_USE_SYSTEM_SDL3=OFF \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -DCMAKE_OSX_ARCHITECTURES="$MAC_ARCHS" \ + "${BDB_ARGS[@]}" \ "${CMAKE_LITE_ARGS[@]}" fi @@ -1128,7 +1157,7 @@ TOOLCHAIN # 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/) — otherwise CMake # 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 if $IS_CROSS; then