From 0022b69da167b950f749f5a8f3271529154bd275 Mon Sep 17 00:00:00 2001 From: Dennis Brakhane Date: Tue, 21 Jan 2025 06:47:15 +0100 Subject: [PATCH] Github actions: Add Ccache to Windows build (#1041) --- .github/workflows/build-pr.yml | 38 +++++++++++++++++++++++++++----- .github/workflows/build.yml | 40 +++++++++++++++++++++++++++++----- Directory.Build.props.ghbuild | 18 +++++++++++++++ 3 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 Directory.Build.props.ghbuild diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index ea5a79b45e..0e938e7cd9 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -9,6 +9,9 @@ concurrency: env: UPX_VERSION: 4.2.4 + CCACHE_VERSION: 4.10.2 + # needed because wiRenderer uses conditional include via __hasinclude + CCACHE_NODIRECT: 1 jobs: @@ -17,10 +20,26 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Restore Ccache database + id: restore-ccache + uses: actions/cache/restore@v4 + with: + path: C:\Users\runneradmin\AppData\Local\ccache + key: win-ccache-${{ github.run_id }} + restore-keys: win-ccache- + + - name: Install Ccache + run: | + curl -sOSL https://github.com/ccache/ccache/releases/download/v$Env:CCACHE_VERSION/ccache-$Env:CCACHE_VERSION-windows-x86_64.zip + unzip -qj ccache-$Env:CCACHE_VERSION-windows-x86_64.zip ccache-$Env:CCACHE_VERSION-windows-x86_64/ccache.exe + mv ccache.exe cl.exe + mv Directory.Build.props.ghbuild Directory.Build.props + - name: Initial compile shell: cmd run: | - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:OfflineShaderCompiler /m /p:Configuration=Release /p:Platform=x64 + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + MSBuild WickedEngine.sln /t:OfflineShaderCompiler /m /p:Configuration=Release /p:Platform=x64 - name: Generate shader dump shell: cmd @@ -31,8 +50,17 @@ jobs: - name: Recompile with shader dump shell: cmd run: | - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64 - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64 + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + MSBuild WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64 + MSBuild WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64 + + - name: Save Ccache database + id: save-ccache + if: always() && steps.restore-ccache.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: C:\Users\runneradmin\AppData\Local\ccache + key: ${{ steps.restore-ccache.outputs.cache-primary-key }} - name: Move files shell: cmd @@ -70,13 +98,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Restore CCache database + - name: Restore Ccache database id: restore-ccache uses: actions/cache/restore@v4 with: path: ~/.cache/ccache key: ccache-${{ github.run_id }} - restore-keys: ccache + restore-keys: ccache- - name: Install dependencies run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b24d2afa3f..258bd590eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ on: env: UPX_VERSION: 4.2.4 + CCACHE_VERSION: 4.10.2 + CCACHE_NODIRECT: 1 jobs: @@ -13,20 +15,48 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 + + - name: Restore Ccache database + id: restore-ccache + uses: actions/cache/restore@v4 + with: + path: C:\Users\runneradmin\AppData\Local\ccache + key: win-ccache-${{ github.run_id }} + restore-keys: win-ccache- + + - name: Install Ccache + run: | + curl -sOSL https://github.com/ccache/ccache/releases/download/v$Env:CCACHE_VERSION/ccache-$Env:CCACHE_VERSION-windows-x86_64.zip + unzip -qj ccache-$Env:CCACHE_VERSION-windows-x86_64.zip ccache-$Env:CCACHE_VERSION-windows-x86_64/ccache.exe + mv ccache.exe cl.exe + mv Directory.Build.props.ghbuild Directory.Build.props + - name: Initial compile shell: cmd run: | - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:OfflineShaderCompiler /m /p:Configuration=Release /p:Platform=x64 + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + MSBuild WickedEngine.sln /t:OfflineShaderCompiler /m /p:Configuration=Release /p:Platform=x64 + - name: Generate shader dump shell: cmd run: | cd "WickedEngine" "../BUILD/x64/Release/OfflineShaderCompiler/OfflineShaderCompiler.exe" hlsl6 spirv shaderdump strip_reflection + - name: Recompile with shader dump shell: cmd run: | - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64 - "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64 + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + MSBuild WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64 + MSBuild WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64 + + - name: Save Ccache database + id: save-ccache + if: always() && steps.restore-ccache.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: C:\Users\runneradmin\AppData\Local\ccache + key: ${{ steps.restore-ccache.outputs.cache-primary-key }} - name: Move files shell: cmd @@ -65,13 +95,13 @@ jobs: - uses: actions/checkout@v4 - - name: Restore CCache database + - name: Restore Ccache database id: restore-ccache uses: actions/cache/restore@v4 with: path: ~/.cache/ccache key: ccache-${{ github.run_id }} - restore-keys: ccache + restore-keys: ccache- - name: Install dependencies run: | diff --git a/Directory.Build.props.ghbuild b/Directory.Build.props.ghbuild new file mode 100644 index 0000000000..5dd07a85ff --- /dev/null +++ b/Directory.Build.props.ghbuild @@ -0,0 +1,18 @@ + + + + D:\a\WickedEngine\WickedEngine + + + + true + + + + OldStyle + + $(IntDir)%(FileName).obj + NotUsing + + +