Files
NexaVPN/desktop-client/scripts/build-tunnel-helper.sh
nessi 991df88d58 refactor: migrate Windows target from x86 to x64 architecture
Update all Windows build configurations, scripts, and documentation from i686-pc-windows-msvc (x86) to x86_64-pc-windows-msvc (x64). Update npm scripts, build-tunnel-helper.sh target validation, bundled helper paths, and tunnel manager strategy references. Add XWIN_ARCH=x86_64 environment variable to Linux cross-build command and --xwin-arch flag to cargo xwin invocation.
2026-03-17 19:13:56 +01:00

80 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -eu
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
HELPER_DIR="${ROOT_DIR}/tunnel-helper"
BUNDLED_DIR="${ROOT_DIR}/src-tauri/bundled"
HOST_OS="$(uname -s)"
TARGET="${1:-}"
if [ -z "${TARGET}" ]; then
echo "usage: build-tunnel-helper.sh <cargo-target>"
exit 1
fi
case "${TARGET}" in
x86_64-pc-windows-msvc)
OUTPUT_DIR="${BUNDLED_DIR}/windows-x64"
OUTPUT_NAME="nexavpn-tunnel-helper.exe"
;;
aarch64-apple-darwin)
OUTPUT_DIR="${BUNDLED_DIR}/macos-arm64"
OUTPUT_NAME="nexavpn-tunnel-helper"
;;
*)
echo "unsupported target: ${TARGET}"
exit 1
;;
esac
if [ "${TARGET}" = "x86_64-pc-windows-msvc" ]; then
case "${HOST_OS}" in
MINGW64_NT*|MSYS_NT*|CYGWIN_NT*)
;;
Linux)
if ! cargo xwin --version >/dev/null 2>&1; then
echo "Linux cross-builds for Windows require cargo-xwin."
echo "Install it with:"
echo " cargo install --locked cargo-xwin"
exit 1
fi
;;
*)
echo "Windows x64 helper builds are supported on Windows or on Linux with cargo-xwin."
echo "Current host: ${HOST_OS}"
echo "Install the target with:"
echo " rustup target add x86_64-pc-windows-msvc"
exit 1
;;
esac
fi
if [ "${TARGET}" = "aarch64-apple-darwin" ] && [ "${HOST_OS}" != "Darwin" ]; then
echo "macOS ARM helper builds must run on macOS."
echo "Current host: ${HOST_OS}"
echo "Use a Mac, then install the target with:"
echo " rustup target add aarch64-apple-darwin"
exit 1
fi
if ! command -v rustup >/dev/null 2>&1; then
echo "rustup is required to verify/install Rust targets."
exit 1
fi
if ! rustup target list --installed | grep -qx "${TARGET}"; then
echo "Rust target ${TARGET} is not installed."
echo "Install it with:"
echo " rustup target add ${TARGET}"
exit 1
fi
mkdir -p "${OUTPUT_DIR}"
if [ "${HOST_OS}" = "Linux" ] && [ "${TARGET}" = "x86_64-pc-windows-msvc" ]; then
cargo xwin build --manifest-path "${HELPER_DIR}/Cargo.toml" --release --target "${TARGET}" --xwin-arch x86_64
else
cargo build --manifest-path "${HELPER_DIR}/Cargo.toml" --release --target "${TARGET}"
fi
cp "${HELPER_DIR}/target/${TARGET}/release/${OUTPUT_NAME}" "${OUTPUT_DIR}/${OUTPUT_NAME}"
echo "Bundled ${OUTPUT_NAME} into ${OUTPUT_DIR}"