hololake-platform/scripts/build-windows-jd-cross.sh

77 lines
3.0 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
set -euo pipefail
target="x86_64-pc-windows-msvc"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
if [[ "$(uname -s)" != "Linux" ]]; then
echo "This cross-build entrypoint is intended for the JD Linux build node." >&2
exit 2
fi
if command -v apt-get >/dev/null 2>&1; then
apt_prefix=()
if [[ "$(id -u)" -ne 0 ]]; then apt_prefix=(sudo); fi
"${apt_prefix[@]}" apt-get update
"${apt_prefix[@]}" apt-get install -y clang curl lld llvm nsis build-essential pkg-config libssl-dev
fi
command -v node >/dev/null || { echo "Node.js is required." >&2; exit 2; }
version="$(node scripts/internal-release-version.mjs src-tauri/tauri.conf.json "${HOLOLAKE_VERSION:-}")"
export PATH="$HOME/.cargo/bin:$PATH"
if ! command -v cargo >/dev/null 2>&1; then
command -v curl >/dev/null || { echo "curl is required to install Rust." >&2; exit 2; }
export RUSTUP_DIST_SERVER="${RUSTUP_DIST_SERVER:-https://rsproxy.cn}"
export RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://rsproxy.cn/rustup}"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
fi
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo-jd}"
mkdir -p "$CARGO_HOME"
cp scripts/cargo-config-jd.toml "$CARGO_HOME/config.toml"
export PATH="$CARGO_HOME/bin:$HOME/.cargo/bin:$PATH"
if ! command -v corepack >/dev/null 2>&1; then
npm install --global corepack
fi
corepack enable 2>/dev/null || true
corepack prepare pnpm@10.25.0 --activate
rustup target add "$target"
command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked
pnpm install --frozen-lockfile
# Tauri's Linux CLI intentionally only exposes Linux bundle targets. Compile the
# Windows application with cargo-xwin, then hand the resulting payload to NSIS.
pnpm tauri build --runner cargo-xwin --target "$target" --no-bundle
release_dir="$repo_root/src-tauri/target/$target/release"
app_exe="$release_dir/tolaria.exe"
[[ -f "$app_exe" ]] || { echo "No Windows executable was produced: $app_exe" >&2; exit 1; }
bundle_dir="$release_dir/bundle/nsis"
stage_dir="$bundle_dir/stage"
installer="$bundle_dir/HoloLake-Era_${version}_x64-internal-setup.exe"
rm -rf "$stage_dir"
mkdir -p "$stage_dir/resources" "$bundle_dir"
cp "$app_exe" "$stage_dir/HoloLake Era.exe"
cp src-tauri/icons/icon.ico "$stage_dir/icon.ico"
cp -R src-tauri/resources/mcp-server "$stage_dir/resources/"
cp -R src-tauri/resources/agent-docs "$stage_dir/resources/"
cp -R src-tauri/resources/public-architecture "$stage_dir/resources/"
makensis \
-DAPP_VERSION="$version" \
-DSTAGE_DIR="$stage_dir" \
-DOUTPUT_FILE="$installer" \
scripts/windows-installer.nsi
[[ -f "$installer" ]] || { echo "No NSIS installer was produced." >&2; exit 1; }
[[ "$(basename "$installer")" == *"$version"* ]] || { echo "Installer filename does not contain version $version: $installer" >&2; exit 1; }
node scripts/verify-internal-package-content.mjs dist
node scripts/verify-internal-package-content.mjs "$stage_dir"
sha256sum "$installer" > "$installer.sha256"
echo "$installer"