Skip to content

Commit

Permalink
cmake [KILL 3-STATE]: Switch WITH_CCACHE to boolean
Browse files Browse the repository at this point in the history
`WITH_CCACHE` is an opportunistic option now and its default is `ON`.
  • Loading branch information
hebasto committed Jun 17, 2024
1 parent ba26fe6 commit 7198a46
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 107 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ jobs:
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'

env:
CCACHE_MAXSIZE: '200M'
PYTHONUTF8: 1
TEST_RUNNER_TIMEOUT_FACTOR: 40

Expand Down Expand Up @@ -163,10 +162,6 @@ jobs:
py -3 --version
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
- name: Install Ccache
run: |
choco install --yes --no-progress ccache
- name: Using vcpkg with MSBuild
run: |
Set-Location "$env:VCPKG_INSTALLATION_ROOT"
Expand Down Expand Up @@ -197,32 +192,12 @@ jobs:
path: ~/AppData/Local/vcpkg/archives
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}

- name: Restore Ccache cache
id: ccache-cache
uses: actions/cache/restore@v4
with:
path: ~/AppData/Local/ccache
key: ${{ github.job }}-ccache-

- name: Build
working-directory: build
run: |
ccache --zero-stats
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
- name: Ccache stats
run: |
ccache --version | head -n 1
ccache --show-stats --verbose
- name: Save Ccache cache
uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
with:
path: ~/AppData/Local/ccache
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ github.job }}-ccache-${{ github.run_id }}

- name: Run test suite
working-directory: build
run: |
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ jobs:
path: ~/AppData/Local/vcpkg/archives
key: ${{ matrix.conf.triplet }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}

- name: Install Ccache
run: |
choco install --yes --no-progress ccache
- name: Generate build system
run: |
cmake -B build --preset ${{ matrix.conf.preset }} -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON
Expand All @@ -471,32 +467,12 @@ jobs:
path: ~/AppData/Local/vcpkg/archives
key: ${{ matrix.conf.triplet }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}

- name: Restore Ccache cache
id: ccache-cache
uses: actions/cache/restore@v4
with:
path: ~/AppData/Local/ccache
key: ${{ matrix.conf.triplet }}-ccache-${{ github.run_id }}
restore-keys: ${{ matrix.conf.triplet }}-ccache-

- name: Build Release configuration
working-directory: build
run: |
ccache --zero-stats
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
- name: Ccache stats
run: |
ccache --version | head -n 1
ccache --show-stats --verbose
- name: Save Ccache cache
uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
with:
path: ~/AppData/Local/ccache
key: ${{ matrix.conf.triplet }}-ccache-${{ github.run_id }}

- name: Inspect build artifacts
working-directory: build
run: |
Expand Down
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TE
option(ENABLE_HARDENING "Attempt to harden the resulting executables." ON)
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
option(WERROR "Treat compiler warnings as errors." OFF)

# TODO: These tri-state options will be removed and most features
# will become opt-in by default before merging into master.
include(TristateOption)
tristate_option(WITH_CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
option(WITH_CCACHE "Attempt to use ccache for compiling." ON)

option(WITH_NATPMP "Enable NAT-PMP." OFF)
if(WITH_NATPMP)
Expand Down Expand Up @@ -365,6 +361,8 @@ endif()

include(cmake/introspection.cmake)

include(cmake/ccache.cmake)

include(cmake/crc32c.cmake)
include(cmake/leveldb.cmake)
include(cmake/minisketch.cmake)
Expand Down Expand Up @@ -498,8 +496,6 @@ configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake COPYONLY)
configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake @ONLY)
configure_file(contrib/filter-lcov.py filter-lcov.py COPYONLY)

include(cmake/optional.cmake)

# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_base_interface SKIP_LINK)

Expand Down
25 changes: 25 additions & 0 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

if(NOT MSVC)
find_program(CCACHE_EXECUTABLE ccache)
if(CCACHE_EXECUTABLE)
execute_process(
COMMAND readlink -f ${CMAKE_CXX_COMPILER}
OUTPUT_VARIABLE compiler_resolved_link
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(CCACHE_EXECUTABLE STREQUAL compiler_resolved_link)
set(WITH_CCACHE "ccache masquerades as the compiler")
elseif(WITH_CCACHE)
list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
endif()
else()
set(WITH_CCACHE OFF)
endif()
endif()

mark_as_advanced(CCACHE_EXECUTABLE)
51 changes: 0 additions & 51 deletions cmake/optional.cmake

This file was deleted.

0 comments on commit 7198a46

Please sign in to comment.