setup script improvements, automatically clone xmrig-hac and build for multiple platforms
This commit is contained in:
@@ -77,7 +77,7 @@ case "$TARGET" in
|
||||
mac)
|
||||
# Cross-compile for macOS via osxcross
|
||||
if [[ -z "${OSXCROSS:-}" ]]; then
|
||||
for try in "$HOME/osxcross" "/opt/osxcross" "$PROJECT_DIR/osxcross"; do
|
||||
for try in "$PROJECT_DIR/external/osxcross" "$HOME/osxcross" "/opt/osxcross" "$PROJECT_DIR/osxcross"; do
|
||||
[[ -d "$try/target" ]] && OSXCROSS="$try" && break
|
||||
done
|
||||
fi
|
||||
|
||||
112
scripts/setup.sh
112
scripts/setup.sh
@@ -109,16 +109,19 @@ detect_os() {
|
||||
pkgs_core_debian="build-essential cmake git pkg-config
|
||||
libgl1-mesa-dev libx11-dev libxcursor-dev libxrandr-dev
|
||||
libxinerama-dev libxi-dev libxkbcommon-dev libwayland-dev
|
||||
libsodium-dev libcurl4-openssl-dev"
|
||||
libsodium-dev libcurl4-openssl-dev
|
||||
autoconf automake libtool wget"
|
||||
|
||||
pkgs_core_fedora="gcc gcc-c++ cmake git pkg-config
|
||||
mesa-libGL-devel libX11-devel libXcursor-devel libXrandr-devel
|
||||
libXinerama-devel libXi-devel libxkbcommon-devel wayland-devel
|
||||
libsodium-devel libcurl-devel"
|
||||
libsodium-devel libcurl-devel
|
||||
autoconf automake libtool wget"
|
||||
|
||||
pkgs_core_arch="base-devel cmake git pkg-config
|
||||
mesa libx11 libxcursor libxrandr libxinerama libxi
|
||||
libxkbcommon wayland libsodium curl"
|
||||
libxkbcommon wayland libsodium curl
|
||||
autoconf automake libtool wget"
|
||||
|
||||
pkgs_core_macos="cmake"
|
||||
|
||||
@@ -306,8 +309,13 @@ if $SETUP_MAC; then
|
||||
# Fetch libsodium for macOS
|
||||
if [[ ! -f "$PROJECT_DIR/libs/libsodium-mac/lib/libsodium.a" ]]; then
|
||||
if ! $CHECK_ONLY; then
|
||||
info "Building libsodium for macOS target..."
|
||||
"$SCRIPT_DIR/fetch-libsodium.sh" --mac
|
||||
# Requires osxcross — skip gracefully if not available
|
||||
if [[ -d "$PROJECT_DIR/external/osxcross/target" ]] || [[ -d "${OSXCROSS:-}/target" ]]; then
|
||||
info "Building libsodium for macOS target..."
|
||||
"$SCRIPT_DIR/fetch-libsodium.sh" --mac || warn "libsodium-mac build failed"
|
||||
else
|
||||
skip "libsodium-mac (requires osxcross — see README)"
|
||||
fi
|
||||
else
|
||||
miss "libsodium-mac (not built yet)"
|
||||
fi
|
||||
@@ -368,7 +376,99 @@ else
|
||||
skip "Sapling params not found (use --sapling to download, or they'll be extracted at runtime from embedded builds)"
|
||||
fi
|
||||
|
||||
# ── 6. Binary directories ───────────────────────────────────────────────────
|
||||
# ── 6. xmrig-hac (mining binary) ────────────────────────────────────────────
|
||||
header "xmrig-hac Mining Binary"
|
||||
|
||||
XMRIG_SRC="$PROJECT_DIR/external/xmrig-hac"
|
||||
XMRIG_PREBUILT="$PROJECT_DIR/prebuilt-binaries/xmrig-hac"
|
||||
|
||||
# Helper: clone xmrig-hac if not present
|
||||
clone_xmrig_if_needed() {
|
||||
if [[ ! -d "$XMRIG_SRC" ]]; then
|
||||
info "Cloning xmrig-hac..."
|
||||
git clone https://git.dragonx.is/dragonx/xmrig-hac.git "$XMRIG_SRC"
|
||||
else
|
||||
ok "xmrig-hac source already present"
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Linux xmrig ─────────────────────────────────────────────────────────────
|
||||
XMRIG_LINUX="$XMRIG_PREBUILT/xmrig"
|
||||
|
||||
if [[ -f "$XMRIG_LINUX" ]]; then
|
||||
ok "xmrig (Linux) already built ($(du -h "$XMRIG_LINUX" | cut -f1))"
|
||||
elif $CHECK_ONLY; then
|
||||
miss "xmrig (Linux) not built (run setup without --check to build)"
|
||||
else
|
||||
clone_xmrig_if_needed
|
||||
|
||||
# Build dependencies (libuv, hwloc, openssl)
|
||||
info "Building xmrig-hac dependencies (libuv, hwloc, openssl)..."
|
||||
(
|
||||
cd "$XMRIG_SRC/scripts"
|
||||
sh build_deps.sh
|
||||
)
|
||||
ok "xmrig-hac dependencies built"
|
||||
|
||||
# Build xmrig
|
||||
info "Building xmrig-hac (Linux)..."
|
||||
mkdir -p "$XMRIG_SRC/build"
|
||||
(
|
||||
cd "$XMRIG_SRC/build"
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DWITH_OPENCL=OFF \
|
||||
-DWITH_CUDA=OFF \
|
||||
-DWITH_HWLOC=ON \
|
||||
-DCMAKE_PREFIX_PATH="$XMRIG_SRC/scripts/deps"
|
||||
make -j"$(nproc)"
|
||||
)
|
||||
|
||||
# Copy binary to prebuilt-binaries
|
||||
mkdir -p "$XMRIG_PREBUILT"
|
||||
if [[ -f "$XMRIG_SRC/build/xmrig" ]]; then
|
||||
cp "$XMRIG_SRC/build/xmrig" "$XMRIG_LINUX"
|
||||
ok "xmrig (Linux) built and installed to prebuilt-binaries/xmrig-hac/"
|
||||
else
|
||||
err "xmrig (Linux) build failed — binary not found"
|
||||
MISSING=$((MISSING + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Windows xmrig (cross-compile, only with --win or --all) ─────────────────
|
||||
XMRIG_WIN="$XMRIG_PREBUILT/xmrig.exe"
|
||||
|
||||
if ! $SETUP_WIN; then
|
||||
if [[ -f "$XMRIG_WIN" ]]; then
|
||||
ok "xmrig.exe (Windows) already built ($(du -h "$XMRIG_WIN" | cut -f1))"
|
||||
else
|
||||
skip "xmrig.exe (Windows) — use --win to cross-compile"
|
||||
fi
|
||||
elif [[ -f "$XMRIG_WIN" ]]; then
|
||||
ok "xmrig.exe (Windows) already built ($(du -h "$XMRIG_WIN" | cut -f1))"
|
||||
elif $CHECK_ONLY; then
|
||||
miss "xmrig.exe (Windows) not built (run setup --win without --check to build)"
|
||||
else
|
||||
clone_xmrig_if_needed
|
||||
|
||||
info "Building xmrig-hac (Windows cross-compile)..."
|
||||
(
|
||||
cd "$XMRIG_SRC/scripts"
|
||||
bash build_windows.sh
|
||||
)
|
||||
|
||||
# Copy binary to prebuilt-binaries
|
||||
mkdir -p "$XMRIG_PREBUILT"
|
||||
if [[ -f "$XMRIG_SRC/build-windows/xmrig.exe" ]]; then
|
||||
cp "$XMRIG_SRC/build-windows/xmrig.exe" "$XMRIG_WIN"
|
||||
ok "xmrig.exe (Windows) built and installed to prebuilt-binaries/xmrig-hac/"
|
||||
else
|
||||
err "xmrig.exe (Windows) build failed — binary not found"
|
||||
MISSING=$((MISSING + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 7. Binary directories ───────────────────────────────────────────────────
|
||||
header "Binary Directories"
|
||||
|
||||
for platform in dragonxd-linux dragonxd-win dragonxd-mac xmrig; do
|
||||
|
||||
Reference in New Issue
Block a user