#!/usr/bin/env bash # Copyright (c) 2016-2024 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html export HOST=x86_64-w64-mingw32 CXX=x86_64-w64-mingw32-g++-posix CC=x86_64-w64-mingw32-gcc-posix PREFIX="$(pwd)/depends/$HOST" set -eu -o pipefail set -x cd "$(dirname "$(readlink -f "$0")")/.." cd depends/ && make HOST=$HOST V=1 NO_QT=1 cd .. ./autogen.sh CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared # Build CryptoConditions stuff WD=$PWD cd src/cc echo $PWD ./makecustom cd $WD # Build RandomX for Windows cd src/RandomX if [ -f "build-win64/librandomx.a" ] then ls -la build-win64/librandomx* else mkdir -p build-win64 && cd build-win64 CC="${CC} -g " CXX="${CXX} -g " cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc-posix -DARCH=native .. make fi cd $WD sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure # Clean any stale native-compiled objects before cross-compiling. # If objects were previously built with the native Linux compiler (ELF format), # make won't recompile them for Windows (COFF format), causing link failures. if [ -f src/libbitcoin_server.a ]; then echo "Cleaning previous build objects to ensure Windows cross-compilation..." cd src/ && make clean 2>/dev/null || true && cd .. fi cd src/ CC="${CC} -g " CXX="${CXX} -g " make V=1 hushd.exe hush-cli.exe hush-tx.exe # Create release package cd $WD echo "Creating Windows release package..." VERSION=$(grep -oP 'define\(_CLIENT_VERSION.*?,\s*\K[0-9]+' configure.ac | head -3 | tr '\n' '.' | sed 's/\.$//') VERSION=${VERSION:-3.10.5} RELEASE_DIR="release/${VERSION}-win" mkdir -p "$RELEASE_DIR" # Strip binaries x86_64-w64-mingw32-strip -s src/hushd.exe src/hush-cli.exe src/hush-tx.exe # Copy binaries cp src/hushd.exe src/hush-cli.exe src/hush-tx.exe "$RELEASE_DIR/" # Copy required data files cp asmap.dat sapling-spend.params sapling-output.params "$RELEASE_DIR/" # Create DragonX batch files cat > "$RELEASE_DIR/dragonxd.bat" << 'EOF' @call :GET_CURRENT_DIR @cd %THIS_DIR% hushd.exe -ac_name=DRAGONX -ac_algo=randomx -ac_halving=3500000 -ac_reward=300000000 -ac_blocktime=36 -ac_private=1 -addnode=176.126.87.241 %* @goto :EOF :GET_CURRENT_DIR @pushd %~dp0 @set THIS_DIR=%CD% @popd @goto :EOF EOF cat > "$RELEASE_DIR/dragonx-cli.bat" << 'EOF' @call :GET_CURRENT_DIR @cd %THIS_DIR% hush-cli.exe -ac_name=DRAGONX %* @goto :EOF :GET_CURRENT_DIR @pushd %~dp0 @set THIS_DIR=%CD% @popd @goto :EOF EOF # Copy bootstrap script cp contrib/bootstrap/bootstrap-dragonx.bat "$RELEASE_DIR/" # Create ZIP rm -f "$RELEASE_DIR/${VERSION}-win.zip" cd "$RELEASE_DIR" zip -9 "${VERSION}-win.zip" *.exe *.bat *.dat *.params cd ../.. echo "Release package created: $RELEASE_DIR/${VERSION}-win.zip" ls -lh "$RELEASE_DIR/${VERSION}-win.zip"