Skip to content

Commit 5357664

Browse files
committed
Optimize CI workflow with improved caching, parallel builds, and minimal Vulkan SDK installation
- Simplified Vulkan SDK installation process with caching and aria2 integration. - Enabled sccache binary caching for Windows builds. - Enhanced vcpkg binary caching and streamlined dependency installation. - Updated Android build to support `abiFilters` configuration.
1 parent ff39c89 commit 5357664

File tree

3 files changed

+52
-39
lines changed

3 files changed

+52
-39
lines changed

.github/workflows/workflow.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ jobs:
6060
- os: windows-latest
6161
ccache: sccache
6262
vulkan-install: |
63-
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" -OutFile "$env:TEMP\vulkan-sdk.exe"
64-
Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow
63+
if (Test-Path "C:\VulkanSDK") {
64+
Write-Host "Using cached Vulkan SDK"
65+
} else {
66+
Write-Host "Downloading Vulkan SDK..."
67+
choco install -y aria2
68+
aria2c --split=16 --max-connection-per-server=16 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe"
69+
70+
Write-Host "Installing minimal Vulkan SDK components..."
71+
Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow
72+
}
6573
6674
$vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName
6775
if (-not $vulkanPath) {
@@ -75,16 +83,6 @@ jobs:
7583
echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
7684
7785
Write-Host "Vulkan SDK path: $vulkanPath"
78-
if (Test-Path "$vulkanPath\Lib") {
79-
Write-Host "Lib directory exists"
80-
} else {
81-
Write-Host "Lib directory does not exist"
82-
}
83-
if (Test-Path "$vulkanPath\Include") {
84-
Write-Host "Include directory exists"
85-
} else {
86-
Write-Host "Include directory does not exist"
87-
}
8886
deps-install: |
8987
.\scripts\install_dependencies_windows.bat
9088
echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV
@@ -124,9 +122,9 @@ jobs:
124122
${{ env.VCPKG_INSTALLATION_ROOT }}/packages
125123
${{ env.VCPKG_INSTALLATION_ROOT }}/buildtrees
126124
${{ env.VCPKG_INSTALLATION_ROOT }}/downloads
127-
key: ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat', '**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp', '**/*.h') }}
125+
${{ runner.temp }}/vcpkg-cache
126+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat', '**/CMakeLists.txt') }}
128127
restore-keys: |
129-
${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat', '**/CMakeLists.txt') }}-
130128
${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat') }}-
131129
${{ runner.os }}-vcpkg-
132130
@@ -180,20 +178,38 @@ jobs:
180178
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
181179
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
182180
181+
- name: Cache sccache binary (Windows)
182+
if: runner.os == 'Windows'
183+
id: cache-sccache
184+
uses: actions/cache@v3
185+
with:
186+
path: ${{ runner.temp }}/sccache
187+
key: ${{ runner.os }}-sccache-0.5.4
188+
183189
- name: Install sccache (Windows)
184190
if: runner.os == 'Windows'
185191
run: |
186-
Invoke-WebRequest -Uri "https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz" -OutFile "sccache.tar.gz"
187-
tar -xzf sccache.tar.gz
188-
$sccachePath = Join-Path -Path (Get-Location) -ChildPath "sccache-v0.5.4-x86_64-pc-windows-msvc"
192+
if (Test-Path "$env:RUNNER_TEMP\sccache\sccache.exe") {
193+
Write-Host "Using cached sccache binary"
194+
$sccachePath = "$env:RUNNER_TEMP\sccache"
195+
} else {
196+
Write-Host "Downloading and installing sccache..."
197+
New-Item -ItemType Directory -Force -Path "$env:RUNNER_TEMP\sccache"
198+
aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:RUNNER_TEMP" --out="sccache.tar.gz" "https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz"
199+
tar -xzf "$env:RUNNER_TEMP\sccache.tar.gz" --strip-components=1 -C "$env:RUNNER_TEMP\sccache" "sccache-v0.5.4-x86_64-pc-windows-msvc/sccache.exe"
200+
$sccachePath = "$env:RUNNER_TEMP\sccache"
201+
}
202+
189203
echo "$sccachePath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
190204
echo "SCCACHE_DIR=$HOME/.cache/sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
191205
echo "SCCACHE_CACHE_SIZE=4G" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
192206
echo "SCCACHE_ERROR_LOG=$HOME/.cache/sccache/sccache.log" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
193207
echo "SCCACHE_LOG=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
194-
New-Item -ItemType Directory -Force -Path "$HOME/.cache/sccache"
195208
echo "RUST_LOG=sccache=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
196209
210+
New-Item -ItemType Directory -Force -Path "$HOME/.cache/sccache"
211+
& "$sccachePath\sccache.exe" --version
212+
197213
- name: Install dependencies
198214
run: ${{ matrix.deps-install }}
199215

attachments/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ android {
1818
externalNativeBuild {
1919
cmake {
2020
arguments "-DCHAPTER=${project.findProperty('chapter') ?: '34_android'}"
21+
abiFilters project.findProperty('abiFilters')?.split(',') ?: ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
2122
}
2223
}
2324
}

scripts/install_dependencies_windows.bat

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,23 @@ if %ERRORLEVEL% neq 0 (
1414
exit /b 1
1515
)
1616

17-
:: Install dependencies using vcpkg
18-
echo Installing GLFW...
19-
vcpkg install glfw3:x64-windows
20-
21-
echo Installing GLM...
22-
vcpkg install glm:x64-windows
23-
24-
echo Installing tinyobjloader...
25-
vcpkg install tinyobjloader:x64-windows
26-
27-
echo Installing stb...
28-
vcpkg install stb:x64-windows
29-
30-
echo Installing tinygltf...
31-
vcpkg install tinygltf:x64-windows
32-
33-
echo Installing nlohmann-json...
34-
vcpkg install nlohmann-json:x64-windows
35-
36-
echo Installing KTX...
37-
vcpkg install ktx:x64-windows
17+
:: Enable binary caching for vcpkg
18+
echo Enabling binary caching for vcpkg...
19+
set VCPKG_BINARY_SOURCES=clear;files,%TEMP%\vcpkg-cache,readwrite
20+
21+
:: Create cache directory if it doesn't exist
22+
if not exist %TEMP%\vcpkg-cache mkdir %TEMP%\vcpkg-cache
23+
24+
:: Install all dependencies at once using vcpkg with parallel installation
25+
echo Installing all dependencies...
26+
vcpkg install --triplet=x64-windows --x-manifest-root=%~dp0 --feature-flags=binarycaching,manifests --x-install-root=%VCPKG_INSTALLATION_ROOT%/installed ^
27+
glfw3 ^
28+
glm ^
29+
tinyobjloader ^
30+
stb ^
31+
tinygltf ^
32+
nlohmann-json ^
33+
ktx
3834

3935
:: Remind about Vulkan SDK
4036
echo.

0 commit comments

Comments
 (0)