This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch feature/614-github-cache-build-deps
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to
refs/heads/feature/614-github-cache-build-deps by this push:
new 92fdfaa7 Add ccache to `conan create` tests.
92fdfaa7 is described below
commit 92fdfaa7492d5195f13a3b16fa686a46e90bbe9e
Author: PengZheng <[email protected]>
AuthorDate: Wed Aug 30 17:35:20 2023 +0800
Add ccache to `conan create` tests.
---
.github/workflows/conan_create.yml | 38 +++++++++++++++++++++++++++++++++-----
CMakeLists.txt | 10 ++++++++++
conanfile.py | 3 +++
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/conan_create.yml
b/.github/workflows/conan_create.yml
index 94a45620..8ab94aec 100644
--- a/.github/workflows/conan_create.yml
+++ b/.github/workflows/conan_create.yml
@@ -11,6 +11,8 @@ env:
CONAN_USER_HOME: "${{ github.workspace }}/release/"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/release/short"
CONAN_HOME: "${{ github.workspace }}/release/"
+ CCACHE_NOHASHDIR: true
+ CCACHE_DIR: "${{ github.workspace }}/.ccache"
jobs:
@@ -37,7 +39,7 @@ jobs:
run: |
# build profile
conan profile detect -f
- - name: Using the builtin GitHub Cache Action for .conan
+ - name: Conan Cache
id: cache-conan
uses: actions/cache@v1
env:
@@ -46,18 +48,31 @@ jobs:
path: ${{ env.CONAN_HOME }}
key: ${{ runner.os }}-builder-${{ env.cache-name }}-${{
matrix.compiler[0] }}-${{ matrix.type }}-${{ hashFiles('conanfile.py') }}
restore-keys: ${{ runner.os }}-builder-${{ env.cache-name }}-${{
matrix.compiler[0] }}-${{ matrix.type }}-
+ - 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}")
+ - name: ccache Cache
+ uses: actions/cache@v1
+ with:
+ path: ${{ env.CCACHE_DIR }}
+ key: ${{ runner.os }}-ccache-${{ matrix.compiler[0] }}-${{
matrix.type }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
+ restore-keys: |
+ ${{ runner.os }}-ccache-${{ matrix.compiler[0] }}-${{ matrix.type
}}-
- name: Create Celix
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
run: |
- conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b
missing -o celix/*:build_all=True -pr:b default -pr:h default -s:h
build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o
celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True
+ conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b
missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -pr:b default
-pr:h default -s:h build_type=${{ matrix.type }} -tf
examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o
celix/*:celix_install_deprecated_api=True
- name: Dependency Deduction Test
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
run: |
- conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ &&
!/build_all/ { if(output) print $1} /^options/ {output=1}
/^options_definitions/ {output=0}' | while read option; do conan build . -c
tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True
-pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -of
${option}_dir -o celix/*:celix_cxx17=True -o
celix/*:celix_install_deprecated_api=True || exit 1; done
+ conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ &&
!/build_all/ { if(output) print $1} /^options/ {output=1}
/^options_definitions/ {output=0}' | while read option; do conan build . -c
tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True
-pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -of
${option}_dir -o celix/*:celix_cxx17=True -o celix/*:enable_ccache=True -o
celix/*:celix_install_deprecated_api=True || exit 1; done
- name: Remove Celix
run: |
conan remove -c celix/*
@@ -85,12 +100,25 @@ jobs:
path: ${{ env.CONAN_USER_HOME }}
key: ${{ runner.os }}-builder-${{ env.cache-name }}-${{
hashFiles('conanfile.py') }}
restore-keys: ${{ runner.os }}-builder-${{ env.cache-name }}-
+ - 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}")
+ - name: ccache Cache
+ uses: actions/cache@v1
+ with:
+ path: ${{ env.CCACHE_DIR }}
+ key: ${{ runner.os }}-ccache-Release-${{
steps.ccache_cache_timestamp.outputs.timestamp }}
+ restore-keys: |
+ ${{ runner.os }}-ccache-Release-
- name: Create Celix
run: |
- conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b
missing -o celix:build_all=True -pr:b default -pr:h default -tf
examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o
celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1
--require-override=openssl/1.1.1s --require-override=zlib/1.2.13
+ conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b
missing -o celix:build_all=True -o celix:enable_ccache=True -pr:b default
-pr:h default -tf examples/conan_test_package -tbf test-build -o
celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True
--require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s
--require-override=zlib/1.2.13
- name: Dependency Deduction Test
run: |
- conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ &&
!/build_all/ { print $1}' | while read option; do conan install . -c
tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix:${option}=True
-pr:b default -pr:h default -if ${option}_dir -o celix:celix_cxx17=True -o
celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1
--require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1;
conan build . -bf ${option}_dir || exit 1; done
+ conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ &&
!/build_all/ { print $1}' | while read option; do conan install . -c
tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix:${option}=True
-pr:b default -pr:h default -if ${option}_dir -o celix:celix_cxx17=True -o
celix:celix_install_deprecated_api=True -o celix:enable_ccache=True
--require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s
--require-override=zlib/1.2.13 || exit 1; conan build . [...]
- name: Remove Celix
run: |
conan remove -f 'celix/*'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5aee5206..f659fb16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,16 @@ if (ENABLE_TESTING)
endif()
endif ()
+
+option(ENABLE_CCACHE "Enabled building with ccache" FALSE)
+if (ENABLE_CCACHE)
+ find_program(CCACHE_EXECUTABLE ccache)
+ if(CCACHE_EXECUTABLE)
+ set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
+ set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
+ endif()
+endif ()
+
# Set C specific flags
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-Wall -Werror -Wformat -Wno-error=deprecated-declarations
${CMAKE_C_FLAGS}")
diff --git a/conanfile.py b/conanfile.py
index 82542172..76ff527b 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -104,6 +104,7 @@ class CelixConan(ConanFile):
"enable_cmake_warning_tests": False,
"enable_testing_on_ci": False,
"framework_curlinit": True,
+ "enable_ccache": False,
}
options = {
"celix_err_buffer_size": ["ANY"],
@@ -155,6 +156,8 @@ class CelixConan(ConanFile):
if self.options.enable_testing:
self.test_requires("gtest/1.10.0")
self.test_requires("cpputest/4.0")
+ if self.options.enable_ccache:
+ self.build_requires("ccache/4.8.2")
def configure(self):
# copy options to options, fill in defaults if not set