Skip to content

Commit f64678f

Browse files
Use sccache for caching Windows builds
1 parent d1079b3 commit f64678f

5 files changed

Lines changed: 51 additions & 7 deletions

File tree

.github/actions/restore-ccache/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
id: ccache-restore
1919
uses: actions/cache/restore@v6
2020
with:
21-
path: .ccache
21+
path: ${{ runner.os == 'Windows' && '.sccache' || '.ccache' }}
2222
key: ${{ github.workflow }}-${{ inputs.arch }}-${{ hashFiles('**/version.txt') }}
2323
restore-keys: |
2424
${{ github.workflow }}-${{ inputs.arch }}-

.github/actions/save-ccache/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ runs:
1515
if: inputs.cache-hit != 'true'
1616
uses: actions/cache/save@v6
1717
with:
18-
path: .ccache
19-
key: ${{ inputs.primary-key }}
18+
key: ${{ inputs.primary-key }}
19+
path: ${{ runner.os == 'Windows' && '.sccache' || '.ccache' }}

.github/workflows/windows-build.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,26 @@ jobs:
2626
- name: Setup Node Version
2727
uses: ./.github/actions/setup-version
2828

29-
- name: Setup Ninja
30-
run: choco install -y python nasm ninja
29+
- name: Restore ccache
30+
id: ccache
31+
uses: ./.github/actions/restore-ccache
32+
with:
33+
arch: ${{ matrix.arch }}
34+
35+
- name: Setup Scoop
36+
shell: pwsh
37+
run: |
38+
choco install -y 7zip
39+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
40+
irm get.scoop.sh | iex
41+
echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
42+
scoop config use_external_7zip true
43+
44+
- name: Install building tools
45+
shell: pwsh
46+
run: |
47+
scoop install sccache
48+
choco install -y python nasm ninja
3149
3250
- name: Build NodeJS
3351
env:
@@ -53,4 +71,11 @@ jobs:
5371
job_status: ${{ job.status }}
5472
node_version: ${{ env.NODE_VERSION }}
5573
github_token: ${{ secrets.GITHUB_TOKEN }}
56-
archive_path: node\out\Release\libnode-${{ matrix.arch }}-windows.zip
74+
archive_path: node\out\Release\libnode-${{ matrix.arch }}-windows.zip
75+
76+
- name: Save ccache
77+
if: always()
78+
uses: ./.github/actions/save-ccache
79+
with:
80+
cache-hit: ${{ steps.ccache.outputs.cache-hit }}
81+
primary-key: ${{ steps.ccache.outputs.cache-primary-key }}

scripts/build.bat

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,27 @@ if "%ARCH%"=="amd64" (
1313
set NODE_ARCH=x64
1414
)
1515

16+
set "SCCACHE_DIR=%GITHUB_WORKSPACE%\.sccache"
17+
if not exist "%SCCACHE_DIR%" mkdir "%SCCACHE_DIR%"
18+
set CC_WRAPPER=sccache
19+
set CXX_WRAPPER=sccache
20+
21+
REM libffi performs atomic operations using legacy macros.
22+
REM Its macros expect volatile long * for atomic variables,
23+
REM but they are being passed int *.
24+
REM On modern versions of Visual Studio (like 2026)
25+
REM -Wincompatible-pointer-types is triggered.
26+
REM https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4047
27+
REM https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4133
28+
set "CFLAGS=/wd4047 /wd4133"
29+
set "CXXFLAGS=/wd4047 /wd4133"
30+
1631
if not exist "node\" (
1732
git clone https://github.com/nodejs/node --branch %NODE_VERSION% --depth=1
1833
)
1934

2035
cd node
2136
call .\vcbuild.bat %NODE_ARCH% dll
22-
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
37+
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
38+
39+
sccache --show-stats

scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ fi
4848
cd node
4949
./configure --shared --dest-cpu "$NODE_ARCH" --dest-os "$OS"
5050
make -j$CORES
51+
52+
ccache --show-stats

0 commit comments

Comments
 (0)