Skip to content

Commit

Permalink
Added CCache
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucionisaau committed Apr 12, 2024
1 parent 896e71a commit b9becbe
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 11 deletions.
86 changes: 75 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
env:
CCACHE_DIR: ${{ github.workspace }}/CCACHE
BUILD_DIR: build-linux64-gcc10
CTEST_OUTPUT_ON_FAILURE: 1
CMAKE_BUILD_TYPE: Debug
Expand All @@ -64,7 +65,28 @@ jobs:
echo 'DPkg::Use-Pty "false";' | sudo tee -a /etc/apt/apt.conf.d/98-quiet
echo 'DPkg::Progress-Fancy "false";' | sudo tee -a /etc/apt/apt.conf.d/98-quiet
sudo apt-get -qq update
sudo apt-get -qq install bison curl wget unzip xz-utils cmake ninja-build flex g++-10
sudo apt-get -qq install bison curl wget unzip xz-utils cmake ninja-build flex ccache g++-10
- name: Compute CCache keys
id: linux64-keys
run: |
key2=ccache-linux64-
key1="${key2}$(date +%W)"
echo "key1=${key1}" >> $GITHUB_OUTPUT
echo "key2=${key2}" >> $GITHUB_OUTPUT
- name: Restore CCache
id: ccache-restore
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ steps.linux64-keys.outputs.key1 }}
restore-keys: ${{ steps.linux64-keys.outputs.key2 }}
- name: CCache limits and stats
run: |
ccache -M120M
ccache --show-stats
- name: Restore Libs
id: restore-libs
uses: actions/cache/restore@v4
Expand All @@ -74,10 +96,7 @@ jobs:
restore-keys: libs-linux64-
- name: Get library dependencies
if: steps.restore-libs.outputs.cache-hit != 'true'
run: |
echo "steps.restore-libs.outputs.cache-primary-key: ${{ steps.restore-libs.outputs.cache-primary-key }}"
echo "steps.restore-libs.outputs.cache-matched-key: ${{ steps.restore-libs.outputs.cache-matched-key }}"
./getlibs/getlibs.sh linux64-gcc10
run: ./getlibs/getlibs.sh linux64-gcc10
- name: Save Libs
if: steps.restore-libs.outputs.cache-hit != 'true'
id: save-libs
Expand All @@ -91,13 +110,16 @@ jobs:
run: cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE
- name: Test
run: ctest --test-dir "$BUILD_DIR" -C $CMAKE_BUILD_TYPE
- name: CCache Statistics
run: ccache --show-stats

windows-x86_64:
needs: [ formatting ]
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
CCACHE_DIR: ${{ github.workspace }}/CCACHE
BUILD_DIR: build-win64
CTEST_OUTPUT_ON_FAILURE: 1
CROSSCOMPILING_EMULATOR: wine
Expand All @@ -113,7 +135,7 @@ jobs:
echo 'DPkg::Use-Pty "false";' | sudo tee -a /etc/apt/apt.conf.d/98-quiet
echo 'DPkg::Progress-Fancy "false";' | sudo tee -a /etc/apt/apt.conf.d/98-quiet
sudo apt-get -qq update
sudo apt-get -qq install bison curl wget unzip xz-utils cmake ninja-build flex g++-mingw-w64-x86-64-posix wine
sudo apt-get -qq install bison curl wget unzip xz-utils cmake ninja-build flex ccache g++-mingw-w64-x86-64-posix wine
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
- name: Setup Wine
Expand All @@ -125,6 +147,26 @@ jobs:
echo "WINEDEBUG=fixme-all,-all" >> $GITHUB_ENV
echo "WINEPATH=\"$(./winepath-for x86_64-w64-mingw32)\"" >> $GITHUB_ENV
- name: Compute CCache keys
id: win64-keys
run: |
key2=ccache-win64-
key1="${key2}$(date +%W)"
echo "key1=${key1}" >> $GITHUB_OUTPUT
echo "key2=${key2}" >> $GITHUB_OUTPUT
- name: Restore CCache
id: ccache-restore
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ steps.win64-keys.outputs.key1 }}
restore-keys: ${{ steps.win64-keys.outputs.key2 }}
- name: CCache limits and stats
run: |
ccache -M120M
ccache --show-stats
- name: Restore Libs
id: restore-libs
uses: actions/cache/restore@v4
Expand All @@ -151,13 +193,16 @@ jobs:
run: cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE
- name: Test
run: ctest --test-dir "$BUILD_DIR" -C $CMAKE_BUILD_TYPE
- name: CCache Statistics
run: ccache --show-stats

darwin-brew-gcc10:
needs: [ formatting ]
strategy:
fail-fast: false
runs-on: macos-11
env:
CCACHE_DIR: ${{ github.workspace }}/CCACHE
BUILD_DIR: build-darwin-brew-gcc10
CTEST_OUTPUT_ON_FAILURE: 1
CMAKE_BUILD_TYPE: Debug
Expand All @@ -170,7 +215,27 @@ jobs:
with:
xcode-version: '13.2.1'
- name: Get Home Brew dependencies
run: brew install -q cmake ninja gcc@10 flex bison wget curl coreutils automake autoconf libtool gnu-sed gawk
run: brew install -q cmake ninja ccache gcc@10 flex bison wget curl coreutils automake autoconf libtool gnu-sed gawk

- name: Compute CCache keys
id: darwin-keys
run: |
key2=ccache-darwin-brew-gcc10-
key1="${key2}$(date +%W)"
echo "key1=${key1}" >> $GITHUB_OUTPUT
echo "key2=${key2}" >> $GITHUB_OUTPUT
- name: Restore CCache
id: ccache-restore
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ steps.darwin-keys.outputs.key1 }}
restore-keys: ${{ steps.darwin-keys.outputs.key2 }}
- name: CCache Limits and Stats
run: |
ccache -M120M
ccache --show-stats
- name: Restore Libs
id: restore-libs
uses: actions/cache/restore@v4
Expand All @@ -180,10 +245,7 @@ jobs:
restore-keys: libs-darwin-brew-gcc10
- name: Get library dependencies
if: steps.restore-libs.outputs.cache-hit != 'true'
run: |
echo "steps.restore-libs.outputs.cache-primary-key: ${{ steps.restore-libs.outputs.cache-primary-key }}"
echo "steps.restore-libs.outputs.cache-matched-key: ${{ steps.restore-libs.outputs.cache-matched-key }}"
./getlibs/getlibs.sh darwin-brew-gcc10
run: ./getlibs/getlibs.sh darwin-brew-gcc10
- name: Store Libs Cache
if: steps.restore-libs.outputs.cache-hit != 'true'
id: save-libs
Expand All @@ -197,6 +259,8 @@ jobs:
run: cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE
- name: Test
run: ctest --test-dir "$BUILD_DIR" -C $CMAKE_BUILD_TYPE
- name: CCache Statistics
run: ccache --show-stats

# build-nix:
# runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ option(UTAP_WITH_TESTS "UTAP Unit Tests" ${UTAP_WITH_TESTS_DEFAULT})
option(UTAP_STATIC "UTAP Static Linking" ${UTAP_STATIC_DEFAULT})
option(FIND_FATAL "Stop upon find_package errors" OFF)
option(ENABLE_CLANG_TIDY "Enables clang-tidy linting during compilation" ON)
option(ENABLE_CCACHE "Enables ccache for intermediate object file caching" ON)

cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables
include(cmake/stdcpp.cmake)
include(cmake/sanitizers.cmake)
if (ENABLE_CLANG_TIDY)
include(cmake/clang-tidy.cmake)
endif (ENABLE_CLANG_TIDY)
if (ENABLE_CCACHE)
include(cmake/ccache.cmake)
endif (ENABLE_CCACHE)

set(UTAP_PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(UTAP_VERSION "${PACKAGE_VERSION}")
Expand Down
8 changes: 8 additions & 0 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Enabled CCache using: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
# set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) # does not improve, but may mess up
else (CCACHE_PROGRAM)
message(STATUS "Disabled CCache: ccache not found")
endif(CCACHE_PROGRAM)

0 comments on commit b9becbe

Please sign in to comment.