11name : CMake CI
22
3- # Optimized workflow for faster builds
4- # Optimizations include:
5- # 1. Improved caching strategy with more specific cache keys
6- # 2. Optimized ccache/sccache configuration for better performance
7- # 3. Minimal Vulkan SDK installation (only necessary components)
8- # 4. Parallel builds for all platforms
9- # 5. Dynamic chapter detection from CMakeLists.txt for future extensibility
10- # 6. Eliminated unnecessary clean steps between builds
11- # 7. Optimized build configuration for better performance
12- # 8. Linux: Using ccache with clang for faster builds
13- # 9. Windows: Using MSVC for better performance and compatibility
14-
153on :
164 push :
175 branches : [ main ]
@@ -72,33 +60,20 @@ jobs:
7260 - os : windows-latest
7361 ccache : sccache
7462 vulkan-install : |
75- # Download the Vulkan SDK installer
7663 Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" -OutFile "$env:TEMP\vulkan-sdk.exe"
77-
78- # Install only the necessary components of Vulkan SDK
79- # --components argument specifies only the components we need:
80- # - VulkanRT: Vulkan Runtime
81- # - VulkanSDK32: Core 32-bit SDK
82- # - VulkanSDK64: Core 64-bit SDK
83- # - VulkanDXC: DirectX Shader Compiler
84- # - VulkanTools: Vulkan Tools (includes glslangValidator)
8564 Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow
8665
87- # Find the installed Vulkan SDK path
8866 $vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName
89-
9067 if (-not $vulkanPath) {
9168 $vulkanPath = "C:\VulkanSDK\latest"
9269 }
9370
94- # Set environment variables
9571 echo "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9672 echo "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
9773 echo "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9874 echo "Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9975 echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
10076
101- # Verify installation
10277 Write-Host "Vulkan SDK path: $vulkanPath"
10378 if (Test-Path "$vulkanPath\Lib") {
10479 Write-Host "Lib directory exists"
@@ -195,47 +170,28 @@ jobs:
195170 ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-
196171 ${{ runner.os }}-vulkan-sdk-
197172
198- - name : Install and configure ccache (Ubuntu)
173+ - name : Install ccache (Ubuntu)
199174 if : runner.os == 'Linux'
200175 run : |
201176 sudo apt-get update
202- sudo apt-get install -y ccache clang clang-18
203-
204- # Configure ccache for optimal performance
205- ccache --max-size=4G
206- ccache --set-config=compression=true
207- ccache --set-config=compression_level=9
208- ccache --set-config=sloppiness=file_macro,time_macros,include_file_mtime,include_file_ctime
209- ccache --set-config=hash_dir=false
177+ sudo apt-get install -y ccache
178+ ccache --max-size=2G
210179 ccache -z
211-
212180 echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
213181 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
214182
215- # Set environment variables for better ccache performance
216- echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
217- echo "CCACHE_COMPRESSLEVEL=9" >> $GITHUB_ENV
218- echo "CCACHE_MAXSIZE=4G" >> $GITHUB_ENV
219-
220- - name : Install and configure sccache (Windows)
183+ - name : Install sccache (Windows)
221184 if : runner.os == 'Windows'
222185 run : |
223- # Download and extract sccache
224186 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"
225187 tar -xzf sccache.tar.gz
226188 $sccachePath = Join-Path -Path (Get-Location) -ChildPath "sccache-v0.5.4-x86_64-pc-windows-msvc"
227189 echo "$sccachePath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
228-
229- # Configure sccache for optimal performance
230190 echo "SCCACHE_DIR=$HOME/.cache/sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
231191 echo "SCCACHE_CACHE_SIZE=4G" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
232192 echo "SCCACHE_ERROR_LOG=$HOME/.cache/sccache/sccache.log" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
233193 echo "SCCACHE_LOG=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
234-
235- # Create cache directory if it doesn't exist
236194 New-Item -ItemType Directory -Force -Path "$HOME/.cache/sccache"
237-
238- # Set environment variables for better sccache performance
239195 echo "RUST_LOG=sccache=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
240196
241197 - name : Install dependencies
@@ -249,7 +205,6 @@ jobs:
249205 run : |
250206 if (Test-Path $env:VULKAN_SDK) {
251207 echo "Vulkan SDK found at: $env:VULKAN_SDK"
252-
253208 $criticalPaths = @(
254209 "$env:VULKAN_SDK\Include",
255210 "$env:VULKAN_SDK\Lib",
@@ -296,7 +251,6 @@ jobs:
296251 working-directory : ${{github.workspace}}/attachments
297252 if : runner.os == 'Windows'
298253 run : |
299- # Configure CMake with MSVC generator for faster builds
300254 cmake -B build -DCMAKE_BUILD_TYPE=Release `
301255 -DVulkan_INCLUDE_DIR="$env:Vulkan_INCLUDE_DIR" `
302256 -DVulkan_LIBRARY="$env:Vulkan_LIBRARY" `
@@ -318,7 +272,6 @@ jobs:
318272 run : |
319273 if [ -d "$VULKAN_SDK" ]; then
320274 echo "Vulkan SDK found at: $VULKAN_SDK"
321- echo "Vulkan SDK installation verified"
322275 else
323276 echo "Vulkan SDK not found!"
324277 exit 1
@@ -328,15 +281,11 @@ jobs:
328281 if : runner.os == 'Linux'
329282 uses : actions/cache@v3
330283 with :
331- path : |
332- ${{github.workspace}}/attachments/build
333- ${{github.workspace}}/attachments/build/.ninja_deps
334- ${{github.workspace}}/attachments/build/.ninja_log
335- key : ${{ runner.os }}-build-ninja-${{ hashFiles('**/CMakeLists.txt', 'scripts/install_dependencies_linux.sh') }}-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.hpp') }}
284+ path : ${{github.workspace}}/attachments/build
285+ key : ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}-${{ hashFiles('**/*.h') }}
336286 restore-keys : |
337- ${{ runner.os }}-build-ninja-${{ hashFiles('**/CMakeLists.txt', 'scripts/install_dependencies_linux.sh') }}-
338- ${{ runner.os }}-build-ninja-${{ hashFiles('**/CMakeLists.txt') }}-
339- ${{ runner.os }}-build-ninja-
287+ ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-
288+ ${{ runner.os }}-build-
340289
341290 - name : Configure CMake (Unix)
342291 working-directory : ${{github.workspace}}/attachments
@@ -351,7 +300,7 @@ jobs:
351300 -DCMAKE_C_COMPILER_LAUNCHER=ccache \
352301 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
353302
354- - name : Build with parallel jobs
303+ - name : Build
355304 working-directory : ${{github.workspace}}/attachments
356305 run : cmake --build build --config Release --parallel 4
357306
@@ -415,7 +364,6 @@ jobs:
415364 run : |
416365 sudo apt-get update
417366 sudo apt-get install -y ccache
418- # Configure ccache for optimal performance
419367 ccache --max-size=4G
420368 ccache --set-config=compression=true
421369 ccache --set-config=compression_level=9
@@ -424,42 +372,31 @@ jobs:
424372 ccache -z
425373 echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
426374 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
427- # Set environment variables for better ccache performance
428375 echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
429376 echo "CCACHE_COMPRESSLEVEL=9" >> $GITHUB_ENV
430377 echo "CCACHE_MAXSIZE=4G" >> $GITHUB_ENV
431378
432379 - name : Set up Android SDK and NDK
433380 run : |
434- echo "Using pre-installed Android SDK and NDK on GitHub runner"
435381 echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
436382 echo "ANDROID_NDK_HOME=$ANDROID_NDK_ROOT" >> $GITHUB_ENV
437383 echo "Android SDK location: $ANDROID_SDK_ROOT"
438384 echo "Android NDK location: $ANDROID_NDK_ROOT"
439385
440- # Install CMake 4.0.2 using sdkmanager
441- echo "Installing CMake 4.0.2 from Android SDK..."
442386 yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "cmake;4.0.2"
443- echo "CMake installation completed"
444387
445388 - name : Install Vulkan SDK and glslangValidator
446389 run : |
447- echo "Installing Vulkan SDK for Android build..."
448-
449- # Check if glslangValidator is already installed from cache
450390 if command -v glslangValidator &> /dev/null; then
451391 echo "glslangValidator already installed:"
452392 glslangValidator --version
453393 else
454- # Install only glslang-tools instead of full Vulkan SDK
455- echo "Installing glslang-tools package..."
456394 sudo apt-get update
457395 sudo apt-get install -y glslang-tools
458396 which glslangValidator
459397 glslangValidator --version
460398 fi
461399
462- # Set minimal Vulkan environment variables needed for the build
463400 echo "VULKAN_SDK=/usr" >> $GITHUB_ENV
464401 echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV
465402
@@ -472,14 +409,12 @@ jobs:
472409 git clone --depth 1 --branch v4.1.0 https://github.com/KhronosGroup/KTX-Software.git
473410 cd KTX-Software
474411 mkdir build && cd build
475- # Configure with minimal features and use ccache
476412 cmake .. -DCMAKE_BUILD_TYPE=Release \
477413 -DKTX_FEATURE_TOOLS=OFF \
478414 -DKTX_FEATURE_DOC=OFF \
479415 -DKTX_FEATURE_LOADTEST_APPS=OFF \
480416 -DCMAKE_C_COMPILER_LAUNCHER=ccache \
481417 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
482- # Build with parallel jobs
483418 cmake --build . --config Release --parallel 4
484419 sudo cmake --install .
485420 cd ../..
@@ -494,14 +429,12 @@ jobs:
494429 git clone --depth 1 https://github.com/syoyo/tinygltf.git
495430 cd tinygltf
496431 mkdir build && cd build
497- # Configure with minimal features and use ccache
498432 cmake .. -DCMAKE_BUILD_TYPE=Release \
499433 -DTINYGLTF_BUILD_LOADER_EXAMPLE=OFF \
500434 -DTINYGLTF_BUILD_GL_EXAMPLES=OFF \
501435 -DTINYGLTF_BUILD_VALIDATOR_EXAMPLE=OFF \
502436 -DCMAKE_C_COMPILER_LAUNCHER=ccache \
503437 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
504- # Build with parallel jobs
505438 cmake --build . --config Release --parallel 4
506439 sudo cmake --install .
507440 cd ../..
@@ -515,41 +448,28 @@ jobs:
515448 gradle wrapper
516449 fi
517450
518- SUPPORTED_CHAPTERS=$(grep -A 20 "set(SUPPORTED_CHAPTERS" app/src/main/cpp/CMakeLists.txt |
519- sed -n '/set(SUPPORTED_CHAPTERS/,/)/p' |
520- grep -o '"[^"]*"' |
521- sed 's/"//g')
451+ SUPPORTED_CHAPTERS=$(grep -A 20 "set(SUPPORTED_CHAPTERS" app/src/main/cpp/CMakeLists.txt | sed -n '/set(SUPPORTED_CHAPTERS/,/)/p' | grep -o '"[^"]*"' | sed 's/"//g')
522452
523453 readarray -t CHAPTERS <<< "$SUPPORTED_CHAPTERS"
524454 echo "Detected supported Android chapters: ${CHAPTERS[@]}"
525455
526- # Configure Gradle for optimal performance
527456 echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > gradle.properties
528457 echo "org.gradle.parallel=true" >> gradle.properties
529458 echo "org.gradle.caching=true" >> gradle.properties
530459 echo "org.gradle.configureondemand=true" >> gradle.properties
531-
532- # Enable AndroidX support (required for androidx.appcompat and other AndroidX dependencies)
533460 echo "android.useAndroidX=true" >> gradle.properties
534461 echo "android.enableJetifier=false" >> gradle.properties
535-
536462 echo "kotlin.incremental=true" >> gradle.properties
537-
538- # Create directory for build outputs
539463 mkdir -p build-outputs
540464
541- # Build each chapter without cleaning between builds
542465 for ((i=0; i<${#CHAPTERS[@]}; i++)); do
543466 chapter="${CHAPTERS[$i]}"
544467 if [ -n "$chapter" ]; then
545468 echo "Building $chapter chapter..."
546-
547- # Build with parallel execution and caching
548- ./gradlew assembleDebug --parallel --max-workers=4 --build-cache -Pchapter=$chapter
469+ ./gradlew assembleDebug --parallel --max-workers=4 --build-cache -Pchapter=$chapter -PabiFilters=x86_64
549470
550471 if [ -f "app/build/outputs/apk/debug/app-debug.apk" ]; then
551472 echo "$chapter built successfully"
552- # Rename the APK to avoid overwriting
553473 cp app/build/outputs/apk/debug/app-debug.apk build-outputs/${chapter}.apk
554474 else
555475 echo "$chapter build failed"
@@ -558,5 +478,4 @@ jobs:
558478 fi
559479 done
560480
561- # Print ccache statistics after builds
562481 ccache -s
0 commit comments