@@ -320,8 +320,9 @@ jobs:
320320 uses : actions/cache@v3
321321 with :
322322 path : ~/.ccache
323- key : android-ccache-${{ github.sha }}
323+ key : android-ccache-${{ hashFiles('attachments/android/app/src/main/cpp/CMakeLists.txt', 'attachments/34_android.cpp', 'attachments/35_gltf_ktx.cpp') }}
324324 restore-keys : |
325+ android-ccache-${{ hashFiles('attachments/android/app/src/main/cpp/CMakeLists.txt') }}
325326 android-ccache-
326327
327328 - name : Cache KTX and tinygltf
@@ -331,7 +332,7 @@ jobs:
331332 /usr/local/include/ktx
332333 /usr/local/lib/libktx*
333334 /usr/local/include/tinygltf
334- key : android-libs-${{ hashFiles('**/workflow.yml ') }}
335+ key : android-libs-${{ hashFiles('attachments/android/app/src/main/cpp/CMakeLists.txt ') }}
335336 restore-keys : |
336337 android-libs-
337338
@@ -342,21 +343,32 @@ jobs:
342343 ~/.gradle/caches
343344 ~/.gradle/wrapper
344345 ${{github.workspace}}/attachments/android/.gradle
346+ ${{github.workspace}}/attachments/android/app/.cxx
345347 ${{github.workspace}}/attachments/android/app/build/intermediates
346348 ${{github.workspace}}/attachments/android/app/build/outputs
347- key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-${{ hashFiles('**/*.cpp', '**/*.h') }}
349+ ${{github.workspace}}/attachments/android/app/build/generated
350+ key : ${{ runner.os }}-gradle-${{ hashFiles('attachments/android/app/src/main/cpp/CMakeLists.txt', 'attachments/34_android.cpp', 'attachments/35_gltf_ktx.cpp', 'attachments/android/app/build.gradle') }}
348351 restore-keys : |
349- ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties ') }}-
352+ ${{ runner.os }}-gradle-${{ hashFiles('attachments/android/app/src/main/cpp/CMakeLists.txt ') }}
350353 ${{ runner.os }}-gradle-
351354
352- - name : Install ccache
355+ - name : Install and configure ccache
353356 run : |
354357 sudo apt-get update
355358 sudo apt-get install -y ccache
356- ccache --max-size=2G
359+ # Configure ccache for optimal performance
360+ ccache --max-size=4G
361+ ccache --set-config=compression=true
362+ ccache --set-config=compression_level=9
363+ ccache --set-config=sloppiness=file_macro,time_macros,include_file_mtime,include_file_ctime
364+ ccache --set-config=hash_dir=false
357365 ccache -z
358366 echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
359367 echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
368+ # Set environment variables for better ccache performance
369+ echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
370+ echo "CCACHE_COMPRESSLEVEL=9" >> $GITHUB_ENV
371+ echo "CCACHE_MAXSIZE=4G" >> $GITHUB_ENV
360372
361373 - name : Set up Android SDK and NDK
362374 run : |
@@ -374,46 +386,42 @@ jobs:
374386 - name : Install Vulkan SDK and glslangValidator
375387 run : |
376388 echo "Installing Vulkan SDK for Android build..."
377- VULKAN_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/linux.txt)
378- echo "Using Vulkan SDK version: $VULKAN_VERSION"
379-
380- mkdir -p vulkan-sdk
381- cd vulkan-sdk
382-
383- curl -O "https://sdk.lunarg.com/sdk/download/$VULKAN_VERSION/linux/vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz"
384- tar -xJf vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz
385389
386- echo "VULKAN_SDK=$PWD/$VULKAN_VERSION/x86_64" >> $GITHUB_ENV
387- echo "PATH=$PWD/$VULKAN_VERSION/x86_64/bin:$PATH" >> $GITHUB_ENV
388- echo "LD_LIBRARY_PATH=$PWD/$VULKAN_VERSION/x86_64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
389- echo "VK_LAYER_PATH=$PWD/$VULKAN_VERSION/x86_64/etc/vulkan/explicit_layer.d" >> $GITHUB_ENV
390-
391- # Verify glslangValidator is available
392- if [ -f "$PWD/$VULKAN_VERSION/x86_64/bin/glslangValidator" ]; then
393- echo "glslangValidator found at: $PWD/$VULKAN_VERSION/x86_64/bin/glslangValidator"
394- $PWD/$VULKAN_VERSION/x86_64/bin/glslangValidator --version
390+ # Check if glslangValidator is already installed from cache
391+ if command -v glslangValidator &> /dev/null; then
392+ echo "glslangValidator already installed:"
393+ glslangValidator --version
395394 else
396- echo "glslangValidator not found in Vulkan SDK, installing separately..."
395+ # Install only glslang-tools instead of full Vulkan SDK
396+ echo "Installing glslang-tools package..."
397397 sudo apt-get update
398398 sudo apt-get install -y glslang-tools
399399 which glslangValidator
400400 glslangValidator --version
401401 fi
402402
403- cd ..
403+ # Set minimal Vulkan environment variables needed for the build
404+ echo "VULKAN_SDK=/usr" >> $GITHUB_ENV
405+ echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV
404406
405407 - name : Install KTX library
406408 run : |
407409 if [ -d "/usr/local/include/ktx" ] && [ -f "/usr/local/lib/libktx.so" ]; then
408410 echo "KTX library already installed from cache"
409411 else
410412 echo "Installing KTX library..."
411- git clone https://github.com/KhronosGroup/KTX-Software.git
413+ git clone --depth 1 --branch v4.1.0 https://github.com/KhronosGroup/KTX-Software.git
412414 cd KTX-Software
413- git checkout v4.1.0
414415 mkdir build && cd build
415- cmake .. -DCMAKE_BUILD_TYPE=Release -DKTX_FEATURE_TOOLS=OFF
416- cmake --build . --config Release
416+ # Configure with minimal features and use ccache
417+ cmake .. -DCMAKE_BUILD_TYPE=Release \
418+ -DKTX_FEATURE_TOOLS=OFF \
419+ -DKTX_FEATURE_DOC=OFF \
420+ -DKTX_FEATURE_LOADTEST_APPS=OFF \
421+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
422+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
423+ # Build with parallel jobs
424+ cmake --build . --config Release --parallel 4
417425 sudo cmake --install .
418426 cd ../..
419427 fi
@@ -424,11 +432,18 @@ jobs:
424432 echo "tinygltf library already installed from cache"
425433 else
426434 echo "Installing tinygltf..."
427- git clone https://github.com/syoyo/tinygltf.git
435+ git clone --depth 1 https://github.com/syoyo/tinygltf.git
428436 cd tinygltf
429437 mkdir build && cd build
430- cmake .. -DCMAKE_BUILD_TYPE=Release -DTINYGLTF_BUILD_LOADER_EXAMPLE=OFF
431- cmake --build . --config Release
438+ # Configure with minimal features and use ccache
439+ cmake .. -DCMAKE_BUILD_TYPE=Release \
440+ -DTINYGLTF_BUILD_LOADER_EXAMPLE=OFF \
441+ -DTINYGLTF_BUILD_GL_EXAMPLES=OFF \
442+ -DTINYGLTF_BUILD_VALIDATOR_EXAMPLE=OFF \
443+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
444+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
445+ # Build with parallel jobs
446+ cmake --build . --config Release --parallel 4
432447 sudo cmake --install .
433448 cd ../..
434449 fi
@@ -447,24 +462,38 @@ jobs:
447462 sed 's/"//g')
448463
449464 readarray -t CHAPTERS <<< "$SUPPORTED_CHAPTERS"
450-
451465 echo "Detected supported Android chapters: ${CHAPTERS[@]}"
452466
453- for chapter in "${CHAPTERS[@]}"; do
467+ # Configure Gradle for optimal performance
468+ echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > gradle.properties
469+ echo "org.gradle.parallel=true" >> gradle.properties
470+ echo "org.gradle.caching=true" >> gradle.properties
471+ echo "org.gradle.configureondemand=true" >> gradle.properties
472+ echo "android.enableBuildCache=true" >> gradle.properties
473+ echo "kotlin.incremental=true" >> gradle.properties
474+
475+ # Create directory for build outputs
476+ mkdir -p build-outputs
477+
478+ # Build each chapter without cleaning between builds
479+ for ((i=0; i<${#CHAPTERS[@]}; i++)); do
480+ chapter="${CHAPTERS[$i]}"
454481 if [ -n "$chapter" ]; then
455482 echo "Building $chapter chapter..."
456483
457- if [ "$chapter" != "${CHAPTERS[0]}" ]; then
458- ./gradlew clean
459- fi
460-
461- ./gradlew assembleDebug -Pchapter=$chapter
484+ # Build with parallel execution and caching
485+ ./gradlew assembleDebug --parallel --max-workers=4 --build-cache -Pchapter=$chapter
462486
463487 if [ -f "app/build/outputs/apk/debug/app-debug.apk" ]; then
464488 echo "$chapter built successfully"
489+ # Rename the APK to avoid overwriting
490+ cp app/build/outputs/apk/debug/app-debug.apk build-outputs/${chapter}.apk
465491 else
466492 echo "$chapter build failed"
467493 exit 1
468494 fi
469495 fi
470496 done
497+
498+ # Print ccache statistics after builds
499+ ccache -s
0 commit comments