Skip to content

Commit e3571a7

Browse files
chore optimized: ccache support
1 parent 7538b5d commit e3571a7

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/build-examples.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,24 @@ jobs:
2727
- name: Install build tools
2828
run: |
2929
sudo apt-get update
30-
sudo apt-get install -y cmake g++-14 ninja-build
30+
sudo apt-get install -y cmake g++-14 ninja-build ccache
3131
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
3232
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
3333
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 100
3434
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100
3535
36+
- name: Cache ccache
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.cache/ccache
40+
key: ccache-host-${{ github.run_id }}
41+
restore-keys: |
42+
ccache-host-
43+
3644
- name: Build host examples
3745
run: python3 scripts/build_examples.py --host
46+
env:
47+
CCACHE_DIR: ~/.cache/ccache
3848

3949
build-stm32:
4050
name: STM32 Examples

scripts/build_examples.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def build_project(project_dir: Path) -> BuildResult:
105105
all_output = []
106106

107107
# Configure
108-
configure_cmd = ['cmake', '-B', str(build_dir), '-G', 'Ninja']
108+
configure_cmd = ['cmake', '-B', str(build_dir), '-G', 'Ninja',
109+
'-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']
109110
try:
110111
result = subprocess.run(
111112
configure_cmd,

0 commit comments

Comments
 (0)