1
0
Fork 0
forked from lthn/blockchain

Add ccache support and update caching paths in build configurations

This commit is contained in:
snider 2025-10-06 16:44:06 +01:00
parent 3fcee22c86
commit 6c35d636b3
9 changed files with 55 additions and 6 deletions

View file

@ -27,7 +27,10 @@ jobs:
- name: Cache SDK Folder
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/sdk
path: |
${{ github.workspace }}/build/.ccache
${{ github.workspace }}/build/sdk
${{ github.workspace }}/build/bin
key: ${{ runner.os }}-${{ runner.arch }}-sdk
- uses: actions/setup-python@v5

View file

@ -27,7 +27,10 @@ jobs:
- name: Cache SDK Folder
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/sdk
path: |
${{ github.workspace }}/build/.ccache
${{ github.workspace }}/build/sdk
${{ github.workspace }}/build/bin
key: ${{ runner.os }}-${{ runner.arch }}-sdk
- uses: actions/setup-python@v5

View file

@ -26,7 +26,10 @@ jobs:
- name: Cache SDK Folder
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/sdk
path: |
${{ github.workspace }}/build/.ccache
${{ github.workspace }}/build/sdk
${{ github.workspace }}/build/bin
key: ${{ runner.os }}-${{ runner.arch }}-sdk
- uses: actions/setup-python@v5

View file

@ -24,7 +24,10 @@ jobs:
- name: Cache SDK Folder
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/sdk
path: |
${{ github.workspace }}/build/.ccache
${{ github.workspace }}/build/sdk
${{ github.workspace }}/build/bin
key: ${{ runner.os }}-${{ runner.arch }}-sdk
- uses: actions/setup-python@v5

View file

@ -24,7 +24,10 @@ jobs:
- name: Cache SDK Folder
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/sdk
path: |
${{ github.workspace }}/build/.ccache
${{ github.workspace }}/build/sdk
${{ github.workspace }}/build/bin
key: ${{ runner.os }}-${{ runner.arch }}-sdk
- uses: actions/setup-python@v5

View file

@ -7,7 +7,6 @@ PROJECT(Lethean)
set(VERSION "1.0" CACHE STRING "Build version")
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
@ -15,6 +14,12 @@ message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(DocBuilder)
option (USE_CCACHE "Use ccache if a usable instance is found" ON)
if (USE_CCACHE)
include(FindCcache)
else()
message(STATUS "ccache deselected")
endif()
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)

View file

@ -21,6 +21,7 @@ function(selective_clean_build_dir)
# List of top-level items in the build directory to keep.
set(golden_items
"${CMAKE_SOURCE_DIR}/build/.ccache"
"${CMAKE_SOURCE_DIR}/build/bin"
"${CMAKE_SOURCE_DIR}/build/docs"
"${CMAKE_SOURCE_DIR}/build/sdk"

26
cmake/FindCcache.cmake Normal file
View file

@ -0,0 +1,26 @@
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
# Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups)
set(TEST_PROJECT "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp")
file(WRITE "${TEST_PROJECT}/CMakeLists.txt" [=[
cmake_minimum_required(VERSION 3.10)
project(test)
option (CCACHE "")
file(WRITE "${CMAKE_SOURCE_DIR}/test.cpp" "int main() { return 0; }")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache")
add_executable(main test.cpp)
]=])
try_compile(RET "${TEST_PROJECT}/build" "${TEST_PROJECT}" "test" CMAKE_FLAGS -DCCACHE="${CCACHE_FOUND}")
unset(TEST_PROJECT)
if (${RET})
# Success
message(STATUS "Found usable ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache")
else()
message(STATUS "Found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
endif()
else()
message(STATUS "ccache NOT found! Please install it for faster rebuilds.")
endif()

View file

@ -18,6 +18,8 @@ class BlockchainConan(ConanFile):
"testnet": False
}
tool_requires = "ccache/4.11"
requires = [
"zlib/1.3.1",
"boost/1.85.0",