From 24232d72c33b0c037c860a6bf9ae28c1038f6bb2 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 10 Mar 2026 20:26:13 -0500 Subject: [PATCH] Add top-level build.sh release script --- .gitignore | 4 ++ build.sh | 124 +++++++++++++++++++++++++++++++++++++++ scripts/build_windows.sh | 4 +- 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 14ffd41e..8089fc49 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ src/config.json Thumbs.db *.swp *~ +release/ +build-linux/ +build-windows/ +deps-windows/ diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..300cd502 --- /dev/null +++ b/build.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# XMRig-HAC Release Build Script +# Usage: ./build.sh [--linux-release] [--win-release] + +set -e + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +RELEASE_DIR="$ROOT_DIR/release" +VERSION=$(grep '#define APP_VERSION' "$ROOT_DIR/src/version.h" | sed 's/.*"\(.*\)"/\1/') + +BUILD_LINUX=false +BUILD_WIN=false + +for arg in "$@"; do + case "$arg" in + --linux-release) BUILD_LINUX=true ;; + --win-release) BUILD_WIN=true ;; + *) + echo "Usage: $0 [--linux-release] [--win-release]" + exit 1 + ;; + esac +done + +if ! $BUILD_LINUX && ! $BUILD_WIN; then + echo "Usage: $0 [--linux-release] [--win-release]" + echo "" + echo "Flags:" + echo " --linux-release Build Linux x86_64 release" + echo " --win-release Build Windows x86_64 release (cross-compile with MinGW)" + exit 1 +fi + +echo "=== XMRig-HAC Release Builder v${VERSION} ===" +mkdir -p "$RELEASE_DIR" + +build_linux() { + echo "" + echo "=========================================" + echo " Building Linux x86_64 Release" + echo "=========================================" + + local BUILD_DIR="$ROOT_DIR/build-linux" + local DEPS_DIR="$ROOT_DIR/scripts/deps" + + # Build dependencies if needed + if [ ! -f "$DEPS_DIR/lib/libuv.a" ] || [ ! -f "$DEPS_DIR/lib/libssl.a" ] || [ ! -f "$DEPS_DIR/lib/libhwloc.a" ]; then + echo "--- Building Linux dependencies ---" + cd "$ROOT_DIR/scripts" + bash build_deps.sh + fi + + # Configure and build + mkdir -p "$BUILD_DIR" + cd "$BUILD_DIR" + + cmake "$ROOT_DIR" \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_STATIC=ON \ + -DWITH_OPENCL=OFF \ + -DWITH_CUDA=OFF \ + -DXMRIG_DEPS="$DEPS_DIR" + + make -j"$(nproc)" + strip xmrig + + # Package + local PKG_NAME="xmrig-hac-${VERSION}-linux-x64" + local PKG_DIR="$RELEASE_DIR/$PKG_NAME" + rm -rf "$PKG_DIR" + mkdir -p "$PKG_DIR" + + cp "$BUILD_DIR/xmrig" "$PKG_DIR/" + cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json" + cp "$ROOT_DIR/README.md" "$PKG_DIR/" + + cd "$RELEASE_DIR" + zip -r "${PKG_NAME}.zip" "$PKG_NAME" + rm -rf "$PKG_DIR" + + echo "" + echo "Linux release: release/${PKG_NAME}.zip" +} + +build_windows() { + echo "" + echo "=========================================" + echo " Building Windows x86_64 Release" + echo "=========================================" + + # Delegate to the existing cross-compilation script + cd "$ROOT_DIR/scripts" + bash build_windows.sh + + local BUILD_DIR="$ROOT_DIR/build-windows" + + # Package + local PKG_NAME="xmrig-hac-${VERSION}-win-x64" + local PKG_DIR="$RELEASE_DIR/$PKG_NAME" + rm -rf "$PKG_DIR" + mkdir -p "$PKG_DIR" + + cp "$BUILD_DIR/xmrig.exe" "$PKG_DIR/" + cp "$ROOT_DIR/bin/WinRing0/WinRing0x64.sys" "$PKG_DIR/" + cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json" + cp "$ROOT_DIR/README.md" "$PKG_DIR/" + + cd "$RELEASE_DIR" + zip -r "${PKG_NAME}.zip" "$PKG_NAME" + rm -rf "$PKG_DIR" + + echo "" + echo "Windows release: release/${PKG_NAME}.zip" +} + +# Run selected builds +$BUILD_LINUX && build_linux +$BUILD_WIN && build_windows + +echo "" +echo "=========================================" +echo " Release artifacts in release/" +echo "=========================================" +ls -lh "$RELEASE_DIR"/*.zip 2>/dev/null || true diff --git a/scripts/build_windows.sh b/scripts/build_windows.sh index 83c71d9d..df58e422 100755 --- a/scripts/build_windows.sh +++ b/scripts/build_windows.sh @@ -61,14 +61,14 @@ if [ ! -f "$DEPS_DIR/lib/libuv.a" ]; then echo "=== Building libuv dependency ===" cd "$DEPS_DIR" - if [ ! -d "libuv-v1.51.0" ]; then + if [ ! -d "libuv-1.51.0" ]; then if [ ! -f "libuv.tar.gz" ]; then curl -L -o libuv.tar.gz https://github.com/libuv/libuv/archive/refs/tags/v1.51.0.tar.gz fi tar -xzf libuv.tar.gz fi - cd libuv-v1.51.0 + cd libuv-1.51.0 mkdir -p build && cd build cmake .. \ -DCMAKE_TOOLCHAIN_FILE="$XMRIG_DIR/cmake/mingw-w64-toolchain.cmake" \