Skip to content

Commit 80772f8

Browse files
committed
ci: fix in windows environment
1 parent 87f18ba commit 80772f8

File tree

1 file changed

+59
-39
lines changed

1 file changed

+59
-39
lines changed

.github/workflows/CI.yml

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- host: [self-hosted, linux]
9393
target: aarch64-unknown-linux-musl
9494
build: pnpm build --target aarch64-unknown-linux-musl -x
95-
- host: [self-hosted, windows]
95+
- host: [self-hosted, windows-arm64]
9696
target: aarch64-pc-windows-msvc
9797
build: pnpm build --target aarch64-pc-windows-msvc
9898
# - host: [self-hosted, linux]
@@ -116,50 +116,29 @@ jobs:
116116
pnpm store prune || true
117117
pnpm config set store-dir ~/.pnpm-store
118118
continue-on-error: true
119-
- name: Install ARM64 Build Tools (Windows)
119+
- name: Install ARM64 Build Tools (Windows x64)
120120
if: ${{ contains(matrix.settings.host, 'windows') && matrix.settings.target == 'aarch64-pc-windows-msvc' }}
121121
run: |
122-
echo "Installing ARM64 Build Tools for aarch64-pc-windows-msvc target..."
122+
echo "Installing ARM64 Build Tools for cross-compilation on x64 Windows..."
123123
curl -o vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe
124124
.\vs_buildtools.exe --quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
125125
shell: cmd
126126
continue-on-error: true
127-
- name: Setup MSVC Environment (Windows)
127+
128+
- name: Verify ARM64 Environment (Windows ARM64)
129+
if: ${{ contains(matrix.settings.host, 'windows-arm64') }}
130+
run: |
131+
echo "Verifying ARM64 native environment..."
132+
echo "Architecture: %PROCESSOR_ARCHITECTURE%"
133+
where cl.exe
134+
where link.exe
135+
echo "ARM64 native environment verified"
136+
shell: cmd
137+
continue-on-error: true
138+
- name: Setup MSVC Environment (Windows x64)
128139
if: ${{ contains(matrix.settings.host, 'windows') }}
129140
run: |
130-
echo "Setting up MSVC environment for target: ${{ matrix.settings.target }}"
131-
132-
# For ARM64 targets, we need to set up cross-compilation environment
133-
if "%{{ matrix.settings.target }}"=="aarch64-pc-windows-msvc" (
134-
echo "Setting up ARM64 cross-compilation environment..."
135-
REM Try to find ARM64 toolchain
136-
if exist "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\*\bin\Hostx64\arm64\cl.exe" (
137-
echo "Found ARM64 toolchain in VS2022 BuildTools"
138-
for /d %%i in ("C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\*") do (
139-
set "VCToolsVersion=%%~ni"
140-
set "VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC"
141-
set "PATH=%%i\bin\Hostx64\arm64;%PATH%"
142-
goto :arm64_found
143-
)
144-
)
145-
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\*\bin\Hostx64\arm64\cl.exe" (
146-
echo "Found ARM64 toolchain in VS2019 BuildTools"
147-
for /d %%i in ("C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\*") do (
148-
set "VCToolsVersion=%%~ni"
149-
set "VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC"
150-
set "PATH=%%i\bin\Hostx64\arm64;%PATH%"
151-
goto :arm64_found
152-
)
153-
)
154-
echo "ARM64 toolchain not found, falling back to x64 toolchain"
155-
goto :setup_x64
156-
:arm64_found
157-
echo "ARM64 toolchain setup completed"
158-
goto :done
159-
)
160-
161-
:setup_x64
162-
echo "Setting up x64 MSVC environment..."
141+
echo "Setting up MSVC environment for x64 Windows..."
163142
REM Try different Visual Studio paths for x64
164143
if exist "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
165144
echo "Found Visual Studio 2022 BuildTools"
@@ -184,12 +163,40 @@ jobs:
184163
shell: cmd
185164
continue-on-error: true
186165

187-
- name: Install Rust (Windows)
166+
- name: Setup MSVC Environment (Windows ARM64)
167+
if: ${{ contains(matrix.settings.host, 'windows-arm64') }}
168+
run: |
169+
echo "Setting up MSVC environment for ARM64 Windows..."
170+
REM Try different Visual Studio paths for ARM64
171+
if exist "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
172+
echo "Found Visual Studio 2022 BuildTools"
173+
call "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64
174+
goto :done
175+
)
176+
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
177+
echo "Found Visual Studio 2019 BuildTools"
178+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64
179+
goto :done
180+
)
181+
echo "Visual Studio not found, trying to find vcvarsall.bat..."
182+
for /f "tokens=*" %%i in ('where vcvarsall.bat 2^>nul') do (
183+
echo "Found vcvarsall.bat at: %%i"
184+
call "%%i" arm64
185+
goto :done
186+
)
187+
echo "Warning: Visual Studio Build Tools not found"
188+
189+
:done
190+
echo "MSVC environment setup completed"
191+
shell: cmd
192+
continue-on-error: true
193+
194+
- name: Install Rust (Windows x64)
188195
if: ${{ contains(matrix.settings.host, 'windows') }}
189196
run: |
190197
echo "PROCESSOR_ARCHITECTURE: %PROCESSOR_ARCHITECTURE%"
191198
echo "PROCESSOR_ARCHITEW6432: %PROCESSOR_ARCHITEW6432%"
192-
# Always use x86_64 version for Windows runners
199+
# Use x86_64 version for x64 Windows runners
193200
curl -o rustup-init.exe https://win.rustup.rs/x86_64
194201
.\rustup-init.exe -y --default-toolchain stable --default-host x86_64-pc-windows-msvc
195202
echo "%USERPROFILE%\.cargo\bin" >> $env:GITHUB_PATH
@@ -198,6 +205,19 @@ jobs:
198205
echo "CARGO_PATH=%USERPROFILE%\.cargo\bin" >> $env:GITHUB_ENV
199206
shell: cmd
200207

208+
- name: Install Rust (Windows ARM64)
209+
if: ${{ contains(matrix.settings.host, 'windows-arm64') }}
210+
run: |
211+
echo "PROCESSOR_ARCHITECTURE: %PROCESSOR_ARCHITECTURE%"
212+
echo "PROCESSOR_ARCHITEW6432: %PROCESSOR_ARCHITEW6432%"
213+
# Use ARM64 version for ARM64 Windows runners
214+
curl -o rustup-init.exe https://win.rustup.rs/aarch64
215+
.\rustup-init.exe -y --default-toolchain stable --default-host aarch64-pc-windows-msvc
216+
echo "%USERPROFILE%\.cargo\bin" >> $env:GITHUB_PATH
217+
"%USERPROFILE%\.cargo\bin\rustup.exe" component add rustfmt clippy
218+
echo "CARGO_PATH=%USERPROFILE%\.cargo\bin" >> $env:GITHUB_ENV
219+
shell: cmd
220+
201221
- name: Install Rust (Non-Windows)
202222
if: ${{ !contains(matrix.settings.host, 'windows') }}
203223
uses: dtolnay/rust-toolchain@stable

0 commit comments

Comments
 (0)