Skip to content

Commit 22d8a8e

Browse files
Add ccache option to CMakeLists.txt and build.sh
1 parent 2a7e52c commit 22d8a8e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ unset(CC_TARGETS_ARM_SH CACHE)
5151
unset(CC_TARGETS_X86_SH CACHE)
5252
unset(CC_TARGETS_AMD64_SH CACHE)
5353

54+
if(CCACHE_PROGRAM_NAME_SH)
55+
find_program(CCACHE_PROGRAM ${CCACHE_PROGRAM_NAME_SH})
56+
if (CCACHE_PROGRAM)
57+
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
58+
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
59+
endif()
60+
unset(CCACHE_PROGRAM_NAME_SH CACHE)
61+
endif()
62+
5463
if(ENABLE_VALGRIND_SH)
5564
unset(ENABLE_VALGRIND_SH CACHE)
5665
if(NOT CC_TARGETS_X86)

build.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ PRINT_USAGE() {
7171
echo " Disable FEATUREs from JSRT experimental features."
7272
echo " --valgrind Enable Valgrind support"
7373
echo " !!! Disables Concurrent GC (lower performance)"
74+
echo " --ccache[=NAME] Enable ccache, optionally with a custom binary name."
75+
echo " Default: ccache"
7476
echo " -v, --verbose Display verbose output including all options"
7577
echo " --wb-check CPPFILE"
7678
echo " Write-barrier check given CPPFILE (git path)"
@@ -124,6 +126,7 @@ VALGRIND=0
124126
CMAKE_EXPORT_COMPILE_COMMANDS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
125127
LIBS_ONLY_BUILD=
126128
ALWAYS_YES=
129+
CCACHE_NAME=
127130
PYTHON2_BINARY=$(which python2.7 || which python2 || which python 2> /dev/null)
128131

129132
UNAME_S=`uname -s`
@@ -336,6 +339,16 @@ while [[ $# -gt 0 ]]; do
336339
TARGET_PATH=${TARGET_PATH:14}
337340
;;
338341

342+
--ccache=*)
343+
CCACHE_NAME="$1"
344+
CCACHE_NAME=${CCACHE_NAME:9}
345+
CCACHE_NAME="-DCCACHE_PROGRAM_NAME_SH=${CCACHE_NAME}"
346+
;;
347+
348+
--ccache)
349+
CCACHE_NAME="-DCCACHE_PROGRAM_NAME_SH=ccache"
350+
;;
351+
339352
--without=*)
340353
FEATURES=$1
341354
FEATURES=${FEATURES:10} # value after --without=
@@ -655,7 +668,7 @@ echo $EXTRA_DEFINES
655668
cmake $CMAKE_GEN $CC_PREFIX $CMAKE_ICU $LTO $LTTNG $STATIC_LIBRARY $ARCH $TARGET_OS \
656669
$ENABLE_CC_XPLAT_TRACE $EXTRA_DEFINES -DCMAKE_BUILD_TYPE=$BUILD_TYPE $SANITIZE $NO_JIT $CMAKE_INTL \
657670
$WITHOUT_FEATURES $WB_FLAG $WB_ARGS $CMAKE_EXPORT_COMPILE_COMMANDS $LIBS_ONLY_BUILD\
658-
$VALGRIND $BUILD_RELATIVE_DIRECTORY
671+
$VALGRIND $BUILD_RELATIVE_DIRECTORY $CCACHE_NAME
659672

660673
_RET=$?
661674
if [[ $? == 0 ]]; then

0 commit comments

Comments
 (0)