Skip to content

Commit

Permalink
build: manually install ccache to control its version
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Sep 20, 2022
1 parent 3aa9929 commit c228e09
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ env:
CMAKE_VERSION: 3.21.1
NINJA_VERSION: 1.10.2
BUILD_TYPE: Release
CCACHE_VERSION: 4.4

jobs:
build:
Expand Down Expand Up @@ -121,28 +120,35 @@ jobs:
sudo apt-get install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
- name: Download ccache
id: ccache
- name: Install ccache
shell: cmake -P {0}
run: |
set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz)
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
if("${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND "choco install ccache")
elseif("${{ runner.os }}" STREQUAL "macOS")
execute_process(COMMAND "brew install ccache")
elseif("${{ runner.os }}" STREQUAL "Linux")
set(ccache_version "4.6.3")
set(ccache_dist "ccache-${ccache_version}-linux-x86_64")
set(ccache_url "https://github.com/ccache/ccache/releases/download/v${ccache_version}/${ccache_dist}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxvf ./ccache.tar.xz)
# Add to PATH environment variable
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${ccache_dist}" ccache_dir)
set(path_separator ":")
file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${ccache_dir}")
else()
message(FATAL_ERROR, "${{ runner.os }} is not supported")
endif()
- name: ccache cache files
uses: actions/cache@v1.1.0
- name: Setup ccache
if: runner.os != 'Windows'
uses: Chocobo1/setup-ccache-action@v1
with:
path: .ccache
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
install_ccache: false
update_packager_index: false
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required

- name: Configure
shell: cmake -P {0}
Expand Down

0 comments on commit c228e09

Please sign in to comment.