BlueGit

golden-age paperdoll-renderer

Files

paperdoll-renderer / scripts / package / windows.sh

windows.sh

windows.sh 2.0 KiB Download Raw
1#!/usr/bin/env bash
2# Cross-compile for Windows x86_64 with MinGW.
3# posprint uses this route and states that BlueGit has no Windows runner.
4# This script packages the .exe in a zip. It does not run the Windows binary.
5set -euo pipefail
6
7root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
8version="$(bash "$root/scripts/ci/package-version.sh")"
9export CARGO_HOME="${CARGO_HOME:-$root/cargo-home}"
10export PATH="$CARGO_HOME/bin:$PATH"
11
12if ! command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1; then
13 echo "x86_64-w64-mingw32-gcc is not installed" >&2
14 exit 1
15fi
16rustup target add x86_64-pc-windows-gnu
17cargo build --release --locked --target x86_64-pc-windows-gnu --manifest-path "$root/Cargo.toml"
18
19exe="$root/target/x86_64-pc-windows-gnu/release/paperdoll-renderer.exe"
20if [[ ! -s "$exe" ]]; then
21 echo "Windows executable was not produced" >&2
22 exit 1
23fi
24# PE magic. Refuse to zip an ELF if the linker targeted the wrong OS.
25if ! od -An -tx1 -N 2 "$exe" | grep -q "4d 5a"; then
26 echo "paperdoll-renderer.exe does not start with MZ" >&2
27 exit 1
28fi
29
30stage="$(mktemp -d)"
31trap 'rm -rf "$stage"' EXIT
32install -m 644 "$exe" "$stage/paperdoll-renderer.exe"
33install -m 644 "$root/LICENSE" "$stage/LICENSE.txt"
34install -m 644 "$root/THIRD_PARTY_NOTICES.md" "$stage/THIRD_PARTY_NOTICES.txt"
35printf '%s\n' "Paperdoll Renderer ${version}" \
36 "Projectbestanden, modelimport en een live glTF-preview." \
37 > "$stage/README.txt"
38
39mkdir -p "$root/dist"
40rm -f "$root/dist/paperdoll-renderer-${version}-windows-x86_64.zip" \
41 "$root/dist/paperdoll-renderer-windows-x86_64.zip"
42(
43 cd "$stage"
44 zip -r "$root/dist/paperdoll-renderer-${version}-windows-x86_64.zip" \
45 paperdoll-renderer.exe LICENSE.txt THIRD_PARTY_NOTICES.txt README.txt
46)
47cp -f "$root/dist/paperdoll-renderer-${version}-windows-x86_64.zip" \
48 "$root/dist/paperdoll-renderer-windows-x86_64.zip"
49python3 "$root/scripts/package/pe_has_icon.py" "$exe"
50python3 "$root/scripts/package/pe_has_icon.py" \
51 "$root/dist/paperdoll-renderer-windows-x86_64.zip"
52echo "wrote dist/paperdoll-renderer-windows-x86_64.zip"