BlueGit

ict rusty-teams

Files

rusty-teams / .github / actions / setup-windows / action.yml

action.yml

action.yml 2.8 KiB Download Raw
1name: Set up the Windows build
2description: >-
3 Stages a copy of gpui-pre-windows with the patches from
4 scripts/gpui-windows-patches and builds the onnxruntime.dll that ships
5 embedded in the app. Exports GPUI_PRE_WINDOWS_PATCHED and
6 CALLING_ONNXRUNTIME_DLL for the cargo steps that follow.
7runs:
8 using: composite
9 steps:
10 # scripts/build-windows.sh stages a copy of gpui-pre-windows with the patches from
11 # scripts/gpui-windows-patches and points `patch.crates-io` at it. Same here, except the
12 # build.rs rewrite of that script is left out: it only exists so a Linux host can
13 # cross-compile, and it would hide fxc.exe from a native Windows build.
14 - name: Stage the patched gpui-pre-windows
15 shell: bash
16 run: |
17 set -euo pipefail
18 # Git Bash on an ARM runner can report x86_64 when it is emulated.
19 # rustc's host triple is the toolchain this job will compile with.
20 host="$(rustc -vV | sed -n 's/^host: //p')"
21 case "$host" in
22 aarch64-pc-windows-msvc) filter_platform=aarch64-pc-windows-msvc ;;
23 x86_64-pc-windows-msvc) filter_platform=x86_64-pc-windows-msvc ;;
24 *) echo "unexpected rustc host: ${host:-<empty>}" >&2; exit 1 ;;
25 esac
26 manifestPath="$(cargo metadata --format-version 1 --filter-platform "$filter_platform" |
27 jq -re '[.packages[] | select(.name == "gpui-pre-windows") | .manifest_path] | first')"
28 # cygpath first, then dirname: the old `jq | xargs dirname | cygpath` chain let
29 # xargs eat the backslashes of the Windows manifest path as escapes, which left
30 # sourceDir at the C: root and `cp -r` walked the whole system drive.
31 sourceDir="$(dirname "$(cygpath -u "$manifestPath")")"
32 [ -f "$sourceDir/Cargo.toml" ] || { echo "not the gpui-pre-windows crate dir: $sourceDir" >&2; exit 1; }
33 patchedDir="$(cygpath -m "$RUNNER_TEMP")/gpui-pre-windows"
34 rm -rf "$patchedDir"
35 cp -r "$sourceDir" "$patchedDir"
36 chmod -R u+w "$patchedDir"
37 for patchFile in scripts/gpui-windows-patches/*.patch; do
38 git -C "$patchedDir" apply -p1 "$(cygpath -m "$GITHUB_WORKSPACE/$patchFile")"
39 done
40 echo "GPUI_PRE_WINDOWS_PATCHED=$patchedDir" >> "$GITHUB_ENV"
41
42 # Background effects ship as an embedded DLL, see tools/onnxruntime-dll.
43 # The path must be absolute: the calling build script reads it from crates/calling,
44 # and `cygpath -m` leaves a relative path like tools/onnxruntime-dll unchanged.
45 - name: Build the embedded onnxruntime.dll
46 shell: bash
47 run: |
48 (cd tools/onnxruntime-dll && RUSTFLAGS="-C target-feature=-crt-static" cargo build --release)
49 echo "CALLING_ONNXRUNTIME_DLL=$(cygpath -m "$GITHUB_WORKSPACE")/tools/onnxruntime-dll/target/release/onnxruntime.dll" >> "$GITHUB_ENV"