Skip to content

Apache DataFusion SQL Query Engine

ARROW-7293: [Dev] [C++] Persist ccache in docker-compose build volumes

Antoine Pitrou48840e75f371
diff --git a/ci/scripts/cpp_build.sh b/ci/scripts/cpp_build.sh
index 41e8b58e57..7c2ab1ec20 100755
--- a/ci/scripts/cpp_build.sh
+++ b/ci/scripts/cpp_build.sh
@@ -31,11 +31,28 @@ elif [ -x "$(command -v xcrun)" ]; then
export ARROW_GANDIVA_PC_CXX_FLAGS="-isysroot;$(xcrun --show-sdk-path)"
fi
-# export CCACHE_COMPRESS=1
-# export CCACHE_COMPRESSLEVEL=5
-# export CCACHE_COMPILERCHECK=content
-# export CCACHE_DIR=/build/ccache
-# export PATH=/usr/lib/ccache/:$PATH
+# We know ccache is installed by default in most Linux development builds
+# (and docker containers)
+uname=$(uname -s)
+case "${uname}" in
+ Linux*) ccache_default=ON;;
+ *) ccache_default=OFF;;
+esac
+
+export ARROW_USE_CCACHE=${ARROW_USE_CCACHE:-$ccache_default}
+
+if [ "${ARROW_USE_CCACHE}" == "ON" ]; then
+ export CCACHE_COMPILERCHECK=content
+ export CCACHE_COMPRESS=1
+ export CCACHE_COMPRESSLEVEL=5
+ # Typically /build/ccache
+ export CCACHE_DIR=${build_dir}/../ccache
+ export CCACHE_MAXSIZE=500M
+ export PATH=/usr/lib/ccache/:$PATH
+
+ echo -e "===\n=== ccache statistics before build\n==="
+ ccache -s
+fi
mkdir -p ${build_dir}
pushd ${build_dir}
@@ -118,6 +135,11 @@ cmake --build . --target install
popd
+if [ "${ARROW_USE_CCACHE}" == "ON" ]; then
+ echo -e "===\n=== ccache statistics after build\n==="
+ ccache -s
+fi
+
if [ "${with_docs}" == "true" ]; then
pushd ${source_dir}/apidoc
doxygen