mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
Discord's game detection matches a running process named hex.exe to the Steam game HEX: Shards of Fate, so the app was shown as that game for as long as Hex ran. The detectable list has exactly one entry with that bare executable, which is why the managed install matched. Windows now installs and runs hex-voice.exe. A terminal still runs hex: PATHEXT resolves it to hex.com, which starts the GUI executable beside it. Releases before the rename were staged as hex.exe by their own updater, so the app copies such an install to the new name, repoints the Start Menu shortcut and Launch at login, and relaunches before claiming the single instance. The installer, script installer, updater, console entry point, and docs use the new name; the published artifact stays hex.exe.
89 lines
3.8 KiB
Shell
89 lines
3.8 KiB
Shell
#!/bin/sh
|
|
# Build one Windows release, dist/hex-<version>-windows-<x64|arm64>.exe (the
|
|
# GUI app) and .com (crates/console, the console entry point installed as
|
|
# hex.com beside it), from Git Bash on Windows: HEX_WINDOWS_ARCH=x86_64
|
|
# (default; Vulkan SDK required) or aarch64 (clang-cl and Ninja, best on an
|
|
# ARM64 host). CI then Authenticode-signs both and wraps them in the Setup.exe
|
|
# installer; the Release workflow publishes all three
|
|
# (docs/plans/release-service.md). Installers name the GUI executable
|
|
# hex-voice.exe, which Discord's game detection does not match to HEX: Shards
|
|
# of Fate (#445).
|
|
set -eu
|
|
|
|
script_root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
|
root=${HEX_RELEASE_SOURCE:-$script_root}
|
|
version=${HEX_VERSION:-$(cargo metadata --no-deps --format-version 1 --manifest-path "$root/Cargo.toml" | jq -r '.packages[] | select(.name == "hex") | .version')}
|
|
dist=${HEX_RELEASE_DIST:-"$root/dist"}
|
|
target_dir=${CARGO_TARGET_DIR:-"$root/target"}
|
|
arch=${HEX_WINDOWS_ARCH:-x86_64}
|
|
case "$arch" in
|
|
x86_64) label=x64 ;;
|
|
aarch64) label=arm64 ;;
|
|
*)
|
|
echo "HEX_WINDOWS_ARCH must be x86_64 or aarch64." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
triple="$arch-pc-windows-msvc"
|
|
|
|
for command in cargo jq; do
|
|
if ! command -v "$command" >/dev/null 2>&1; then
|
|
echo "Windows builds require $command." >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
case "$(uname -s)" in
|
|
MINGW64* | MSYS*) ;;
|
|
*)
|
|
echo "Windows releases must be built from Git Bash on Windows." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
if ! printf '%s\n' "$version" | grep -Eq '^([0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?|0\.0\.0-dev-[0-9]+)$'; then
|
|
echo "Release builds need a version like 2.4.0, 2.5.0-beta.1, or 2.5.0-dev.3, not $version." >&2
|
|
exit 1
|
|
fi
|
|
if [ -n "$(git -C "$root" status --porcelain)" ]; then
|
|
echo "Commit or remove all working-tree changes before building a release." >&2
|
|
exit 1
|
|
fi
|
|
installer="$root/.github/release/install-windows.ps1"
|
|
# PowerShell needs a Windows path; Git Bash converts only bare arguments.
|
|
installer_windows=$(cygpath -w "$installer" 2>/dev/null || printf '%s' "$installer")
|
|
powershell -NoProfile -Command "[void][ScriptBlock]::Create((Get-Content -Raw '$installer_windows'))"
|
|
|
|
"$script_root/scripts/set-crate-version.sh" "$root" "$version"
|
|
mkdir -p "$dist"
|
|
# Portable native code: ggml otherwise tunes its CPU kernels to this build
|
|
# machine (for example AVX-512), and the release would crash on older CPUs.
|
|
cmake_args="-DGGML_NATIVE=OFF"
|
|
if [ "$arch" = aarch64 ]; then
|
|
# ggml's ARM CPU backend refuses MSVC; clang-cl uses LLVM codegen, so
|
|
# ggml's own threadpool replaces OpenMP there.
|
|
cmake_args="$cmake_args -DGGML_OPENMP=OFF"
|
|
export CC=clang-cl CXX=clang-cl CMAKE_GENERATOR=Ninja
|
|
fi
|
|
# Cargo reads .cargo/config.toml (the static Windows runtime) from the
|
|
# working directory, not from --manifest-path.
|
|
(cd "$root" && TRANSCRIBE_CMAKE_ARGS="$cmake_args" cargo build --locked --release --target "$triple")
|
|
(cd "$root" && cargo build --locked --release --target "$triple" -p hex-console)
|
|
executable="$dist/hex-$version-windows-$label.exe"
|
|
console="$dist/hex-$version-windows-$label.com"
|
|
cp "$target_dir/$triple/release/hex.exe" "$executable"
|
|
cp "$target_dir/$triple/release/hex-console.exe" "$console"
|
|
test "$(head -c 2 "$executable")" = MZ
|
|
test "$(head -c 2 "$console")" = MZ
|
|
# An executable for the other architecture cannot run here; the installer
|
|
# test checks it on its own runner. hex.com runs the GUI executable beside it,
|
|
# as installed, and still finds the hex.exe a release before the rename left.
|
|
if [ "$(uname -m)" = "$arch" ]; then
|
|
pair=$(mktemp -d)
|
|
cp "$executable" "$pair/hex-voice.exe"
|
|
cp "$console" "$pair/hex.com"
|
|
test "$("$pair/hex.com" --version | awk 'NF { value=$NF } END { print value }')" = "$version"
|
|
rm "$pair/hex-voice.exe"
|
|
cp "$executable" "$pair/hex.exe"
|
|
test "$("$pair/hex.com" --version | awk 'NF { value=$NF } END { print value }')" = "$version"
|
|
rm -rf "$pair"
|
|
fi
|
|
echo "$executable"
|