Files
hush3/build.sh
dan_s 8a0eb77692 Fix RandomX validation exploit with difficulty reset, improve build system
- One-time difficulty reset to minimum for 17 blocks at activation height
- Separate RandomX build dirs for linux/win64 cross-compilation
- Add build target tracking to auto-clean on target switch
- Automated win64 release packaging to release-win64/
- Add build artifacts to .gitignore
- Miner memory diagnostics and large-page dataset fallback
2026-02-19 22:07:38 -06:00

59 lines
1.8 KiB
Bash
Executable File

#!/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
set -eu -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_TARGET_FILE="$SCRIPT_DIR/src/.build_target"
# Function to check and clean if target changed
check_and_clean_target() {
local new_target="$1"
local current_target=""
if [[ -f "$BUILD_TARGET_FILE" ]]; then
current_target=$(cat "$BUILD_TARGET_FILE")
fi
if [[ -n "$current_target" && "$current_target" != "$new_target" ]]; then
echo "Build target changed from '$current_target' to '$new_target'"
echo "Cleaning old build artifacts to prevent cross-compilation contamination..."
cd "$SCRIPT_DIR"
make distclean 2>/dev/null || true
# Clean leveldb separately as it often causes issues
if [[ -d src/leveldb ]]; then
make -C src/leveldb clean 2>/dev/null || true
fi
echo "Clean complete."
fi
# Record the new target
echo "$new_target" > "$BUILD_TARGET_FILE"
}
# Check for --win-release flag for cross-compilation
if [[ "${1:-}" == "--win-release" ]]; then
check_and_clean_target "windows"
shift
./util/build-win.sh "$@"
exit $?
fi
# run correct build script for detected OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
check_and_clean_target "linux"
./util/build.sh --disable-tests "$@"
elif [[ "$OSTYPE" == "darwin"* ]]; then
check_and_clean_target "macos"
./util/build-mac.sh --disable-tests "$@"
elif [[ "$OSTYPE" == "msys"* ]]; then
check_and_clean_target "windows"
./util/build-win.sh --disable-tests "$@"
#elif [[ "$OSTYPE" == "freebsd"* ]]; then
# placeholder
else
echo "Unable to detect your OS. What are you using?"
fi