Skip to content

Commit 391bc61

Browse files
committed
ci: Add sccache compiler cache
1 parent 3c6377d commit 391bc61

4 files changed

Lines changed: 40 additions & 7 deletions

File tree

.github/actions/ci/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ runs:
5656
if: inputs.use_curl == 'true' || inputs.install_curl == 'true'
5757
uses: ./.github/actions/install-curl
5858
id: install-curl
59+
- name: Install sccache
60+
uses: mozilla-actions/sccache-action@1583d6b38d7be47f593cb472781bbb21cab4321e # v0.0.10
5961
- name: Build Library
6062
shell: bash
6163
run: ./scripts/build.sh ${{ inputs.cmake_target }} ON ${{ inputs.use_curl }}
@@ -83,6 +85,11 @@ runs:
8385
# has better performance and output.
8486
run: ./build/gtest_${{ inputs.cmake_target }}
8587

88+
- name: sccache stats (after unit-test build)
89+
if: always()
90+
shell: bash
91+
run: sccache --show-stats || true
92+
8693
- name: Simulate Release (Linux/MacOS)
8794
if: inputs.simulate_release == 'true'
8895
shell: bash
@@ -113,3 +120,8 @@ runs:
113120
Boost_DIR: 'C:\local\boost_1_87_0\lib64-msvc-14.3\cmake\Boost-1.87.0'
114121
CURL_ROOT: ${{ steps.install-curl.outputs.CURL_ROOT }}
115122
CMAKE_PREFIX_PATH: ${{ steps.install-curl.outputs.CURL_ROOT }}
123+
124+
- name: sccache stats (final)
125+
if: always()
126+
shell: bash
127+
run: sccache --show-stats || true

scripts/build-release-windows.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ else
3838
suffix=""
3939
fi
4040

41+
sccache_args=()
42+
if command -v sccache >/dev/null 2>&1; then
43+
sccache_args=(-D CMAKE_C_COMPILER_LAUNCHER=sccache -D CMAKE_CXX_COMPILER_LAUNCHER=sccache)
44+
fi
45+
4146
# Build a static release.
4247
mkdir -p "build-static${suffix}" && cd "build-static${suffix}"
4348
mkdir -p release
@@ -46,7 +51,8 @@ cmake -G Ninja -D CMAKE_BUILD_TYPE=Release \
4651
-D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" \
4752
-D LD_CURL_NETWORKING="$build_curl" \
4853
-D BUILD_TESTING=OFF \
49-
-D CMAKE_INSTALL_PREFIX=./release ..
54+
-D CMAKE_INSTALL_PREFIX=./release \
55+
"${sccache_args[@]}" ..
5056

5157
cmake --build . --target "$TARGET"
5258
cmake --install .
@@ -62,7 +68,8 @@ cmake -G Ninja -D CMAKE_BUILD_TYPE=Release \
6268
-D BUILD_TESTING=OFF \
6369
-D LD_BUILD_SHARED_LIBS=ON \
6470
-D LD_DYNAMIC_LINK_BOOST=OFF \
65-
-D CMAKE_INSTALL_PREFIX=./release ..
71+
-D CMAKE_INSTALL_PREFIX=./release \
72+
"${sccache_args[@]}" ..
6673

6774
cmake --build . --target "$TARGET"
6875
cmake --install .
@@ -76,7 +83,8 @@ cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug \
7683
-D LD_BUILD_REDIS_SUPPORT="$build_redis" \
7784
-D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" \
7885
-D LD_CURL_NETWORKING="$build_curl" \
79-
-D CMAKE_INSTALL_PREFIX=./release ..
86+
-D CMAKE_INSTALL_PREFIX=./release \
87+
"${sccache_args[@]}" ..
8088

8189
cmake --build . --target "$TARGET"
8290
cmake --install .
@@ -93,7 +101,8 @@ cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug \
93101
-D LD_CURL_NETWORKING="$build_curl" \
94102
-D LD_BUILD_SHARED_LIBS=ON \
95103
-D LD_DYNAMIC_LINK_BOOST=OFF \
96-
-D CMAKE_INSTALL_PREFIX=./release ..
104+
-D CMAKE_INSTALL_PREFIX=./release \
105+
"${sccache_args[@]}" ..
97106

98107
cmake --build . --target "$TARGET"
99108
cmake --install .

scripts/build-release.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ else
3838
suffix=""
3939
fi
4040

41+
sccache_args=()
42+
if command -v sccache >/dev/null 2>&1; then
43+
sccache_args=(-D CMAKE_C_COMPILER_LAUNCHER=sccache -D CMAKE_CXX_COMPILER_LAUNCHER=sccache)
44+
fi
45+
4146
# Build a static release.
4247
mkdir -p "build-static${suffix}" && cd "build-static${suffix}"
4348
mkdir -p release
44-
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D LD_BUILD_REDIS_SUPPORT="$build_redis" -D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" -D LD_CURL_NETWORKING="$build_curl" -D BUILD_TESTING=OFF -D CMAKE_INSTALL_PREFIX=./release ..
49+
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D LD_BUILD_REDIS_SUPPORT="$build_redis" -D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" -D LD_CURL_NETWORKING="$build_curl" -D BUILD_TESTING=OFF -D CMAKE_INSTALL_PREFIX=./release "${sccache_args[@]}" ..
4550

4651
cmake --build . --target "$TARGET"
4752
cmake --install .
@@ -50,7 +55,7 @@ cd ..
5055
# Build a dynamic release.
5156
mkdir -p "build-dynamic${suffix}" && cd "build-dynamic${suffix}"
5257
mkdir -p release
53-
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D LD_BUILD_REDIS_SUPPORT="$build_redis" -D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" -D LD_CURL_NETWORKING="$build_curl" -D BUILD_TESTING=OFF -D LD_BUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=./release ..
58+
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D LD_BUILD_REDIS_SUPPORT="$build_redis" -D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" -D LD_CURL_NETWORKING="$build_curl" -D BUILD_TESTING=OFF -D LD_BUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=./release "${sccache_args[@]}" ..
5459

5560
cmake --build . --target "$TARGET"
5661
cmake --install .

scripts/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ if [ "$1" == "launchdarkly-cpp-server-otel" ] || [ "$1" == "gtest_launchdarkly-c
5252
build_otel_fetch_deps="ON"
5353
fi
5454

55+
sccache_args=()
56+
if command -v sccache >/dev/null 2>&1; then
57+
sccache_args=(-D CMAKE_C_COMPILER_LAUNCHER=sccache -D CMAKE_CXX_COMPILER_LAUNCHER=sccache)
58+
fi
59+
5560
echo "==== Build Configuration ===="
5661
echo "Target: $1"
5762
echo "CMAKE_BUILD_TYPE: $build_type"
@@ -63,6 +68,7 @@ echo "LD_BUILD_DYNAMODB_SUPPORT: $build_dynamodb"
6368
echo "LD_CURL_NETWORKING: $build_curl"
6469
echo "LD_BUILD_OTEL_SUPPORT: $build_otel"
6570
echo "LD_BUILD_OTEL_FETCH_DEPS: $build_otel_fetch_deps"
71+
echo "sccache: ${sccache_args[*]:-not detected}"
6672
echo "============================="
6773

6874
cmake -G Ninja -D CMAKE_BUILD_TYPE="$build_type" \
@@ -74,6 +80,7 @@ cmake -G Ninja -D CMAKE_BUILD_TYPE="$build_type" \
7480
-D LD_BUILD_DYNAMODB_SUPPORT="$build_dynamodb" \
7581
-D LD_CURL_NETWORKING="$build_curl" \
7682
-D LD_BUILD_OTEL_SUPPORT="$build_otel" \
77-
-D LD_BUILD_OTEL_FETCH_DEPS="$build_otel_fetch_deps" ..
83+
-D LD_BUILD_OTEL_FETCH_DEPS="$build_otel_fetch_deps" \
84+
"${sccache_args[@]}" ..
7885

7986
cmake --build . --target "$1"

0 commit comments

Comments
 (0)