Skip to content

Commit

Permalink
Github actions: Add Ccache to Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
brakhane committed Jan 21, 2025
1 parent 03958b5 commit dd1652a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 10 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ concurrency:

env:
UPX_VERSION: 4.2.4
CCACHE_VERSION: 4.10.2

jobs:

Expand All @@ -17,10 +18,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
Expand All @@ -31,8 +48,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
Expand Down Expand Up @@ -70,13 +96,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: |
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,60 @@ on:

env:
UPX_VERSION: 4.2.4
CCACHE_VERSION: 4.10.2
CCACHE_NODIRECT: 1

jobs:

windows:
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
echo %CCACHE_NODIRECT%
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
Expand Down Expand Up @@ -65,13 +98,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: |
Expand Down
18 changes: 18 additions & 0 deletions Directory.Build.props.ghbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- This file is only needed for Ccache compilation in GitHub actions, it can safely be ignored otherwise -->
<Project>
<PropertyGroup>
<CLToolPath>D:\a\WickedEngine\WickedEngine</CLToolPath>
</PropertyGroup>

<PropertyGroup>
<UseMultiToolTask>true</UseMultiToolTask>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<ForcedIncludeFiles />
<ObjectFileName>$(IntDir)%(FileName).obj</ObjectFileName>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
</Project>

0 comments on commit dd1652a

Please sign in to comment.