Skip to content

Commit e251a24

Browse files
committed
Improve Windows vcpkg setup and error handling in OpenXR engine installation
Add vcpkg PATH resolution using VCPKG_INSTALLATION_ROOT. Add error checking after simple_engine and openxr-loader installation steps. Implement vcpkg caching in GitHub Actions workflow to speed up CI builds. Consolidate vcpkg environment setup into separate step with binary cache configuration.
1 parent 392c995 commit e251a24

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.github/workflows/openxr_engine_ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,22 @@ jobs:
121121
echo "CMAKE_PREFIX_PATH=$SDK_SYSROOT" >> "$GITHUB_ENV"
122122
echo "Vulkan_INCLUDE_DIR=$SDK_SYSROOT/include" >> "$GITHUB_ENV"
123123
124-
- name: Bootstrap vcpkg (Windows)
124+
# Use the engine's dependency install scripts instead of calling vcpkg directly in CI.
125+
- name: Cache vcpkg (Windows)
125126
if: runner.os == 'Windows'
127+
id: cache-vcpkg-windows
128+
uses: actions/cache@v4
129+
with:
130+
path: |
131+
${{ runner.temp }}/vcpkg
132+
${{ runner.temp }}/vcpkg-cache
133+
key: ${{ runner.os }}-openxr-vcpkg-${{ hashFiles('attachments/simple_engine/vcpkg.json') }}
134+
135+
- name: Bootstrap vcpkg (Windows)
136+
if: runner.os == 'Windows' && steps.cache-vcpkg-windows.outputs.cache-hit != 'true'
126137
shell: pwsh
127138
run: |
139+
$ErrorActionPreference = 'Stop'
128140
$vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg"
129141
if (-not (Test-Path $vcpkgRoot)) {
130142
git clone https://github.com/microsoft/vcpkg $vcpkgRoot
@@ -133,7 +145,23 @@ jobs:
133145
.\bootstrap-vcpkg.bat
134146
Pop-Location
135147
"VCPKG_INSTALLATION_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
148+
"$vcpkgRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
149+
"CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
150+
151+
- name: Set vcpkg env (Windows)
152+
if: runner.os == 'Windows'
153+
shell: pwsh
154+
run: |
155+
$vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg"
156+
$vcpkgCache = Join-Path $env:RUNNER_TEMP "vcpkg-cache"
157+
if (-not (Test-Path $vcpkgCache)) {
158+
New-Item -Path $vcpkgCache -ItemType Directory
159+
}
160+
"VCPKG_INSTALLATION_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
161+
"$vcpkgRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
136162
"CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
163+
"VCPKG_DEFAULT_BINARY_CACHE=$vcpkgCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
164+
"VCPKG_BINARY_SOURCES=clear;files,$vcpkgCache,readwrite" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
137165
138166
- name: Install dependencies (Windows)
139167
if: runner.os == 'Windows'

attachments/openxr_engine/install_dependencies_windows.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,30 @@ if not exist "%SIMPLE_ENGINE_DIR%" (
77
exit /b 1
88
)
99

10+
:: Ensure vcpkg is accessible
11+
where vcpkg >nul 2>nul
12+
if %ERRORLEVEL% neq 0 (
13+
if defined VCPKG_INSTALLATION_ROOT (
14+
if exist "%VCPKG_INSTALLATION_ROOT%\vcpkg.exe" (
15+
set "PATH=%VCPKG_INSTALLATION_ROOT%;%PATH%"
16+
)
17+
)
18+
)
19+
1020
echo Calling simple_engine dependencies installer...
1121
call "%SIMPLE_ENGINE_DIR%\install_dependencies_windows.bat"
22+
if %ERRORLEVEL% neq 0 (
23+
echo Error: simple_engine dependencies installation failed.
24+
exit /b %ERRORLEVEL%
25+
)
1226

1327
echo.
1428
echo Installing OpenXR loader...
1529
vcpkg install openxr-loader --triplet=x64-windows
30+
if %ERRORLEVEL% neq 0 (
31+
echo Error: Failed to install openxr-loader.
32+
exit /b %ERRORLEVEL%
33+
)
1634

1735
echo.
1836
echo OpenXR dependencies installation completed!

0 commit comments

Comments
 (0)