From f87d7bce64927746d64e0bd8903fe29e433a55a1 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 28 Feb 2019 18:51:34 -0800 Subject: [PATCH] Initial implementation of ccache caching for builds Signed-off-by: Jesse Vincent --- bin/kaleidoscope-builder | 22 ++++++++++++++++++++++ etc/kaleidoscope-builder.conf | 1 + 2 files changed, 23 insertions(+) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 51ead4ed..4b049ba5 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -29,6 +29,7 @@ build_paths() { OUTPUT_DIR="${OUTPUT_DIR:-output/${LIBRARY}}" OUTPUT_PATH="${OUTPUT_PATH:-${SOURCEDIR}/${OUTPUT_DIR}}" STABLE_TEMP_DIR="${STABLE_TEMP_DIR:-/tmp/kaleidoscope-${USER}}" + CCACHE_WRAPPER_DIR="${CCACHE_WRAPPER_DIR:-${STABLE_TEMP_DIR}/ccache/bin}" CORE_CACHE_PATH="${CORE_CACHE_PATH:-${STABLE_TEMP_DIR}/arduino-cores}" @@ -45,6 +46,24 @@ build_filenames () { ELF_FILE_PATH="${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.elf" } + +enable_ccache () { + if [ `which ccache` ]; then + if ! [ -d $CCACHE_WRAPPER_DIR ]; then + mkdir -p $CCACHE_WRAPPER_DIR + ln -s `which ccache` ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}gcc + ln -s `which ccache` ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}g++ + ln -s ${AVR_NM} ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}nm + ln -s ${AVR_OBJCOPY} ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}objcopy + ln -s ${AVR_AR} ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}ar + ln -s ${AVR_SIZE} ${CCACHE_WRAPPER_DIR}/${COMPILER_PREFIX}size + fi + export CCACHE_PATH=${COMPILER_PATH}/ + CCACHE_ENABLE="-prefs compiler.path=${CCACHE_WRAPPER_DIR}/" + fi +} + + firmware_size () { if [ "${BOARD}" = "virtual" ]; then echo "[Size not computed for virtual build]" @@ -193,6 +212,8 @@ compile () { build_version build_paths build_filenames + enable_ccache + install -d "${OUTPUT_PATH}" echo "Building ${OUTPUT_DIR}/${SKETCH} (${LIB_VERSION}) ..." @@ -247,6 +268,7 @@ compile () { -build-path "${BUILD_PATH}" \ -ide-version "${ARDUINO_IDE_VERSION}" \ -prefs "compiler.cpp.extra_flags=-std=c++11 -Woverloaded-virtual -Wno-unused-parameter -Wno-unused-variable -Wno-ignored-qualifiers ${ARDUINO_CFLAGS} ${LOCAL_CFLAGS}" \ + $CCACHE_ENABLE \ -warnings all \ ${ARDUINO_VERBOSE} \ ${ARDUINO_AVR_GCC_PREFIX_PARAM} \ diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index a30b0153..dc69c04c 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -147,6 +147,7 @@ COMPILER_PREFIX="${COMPILER_PREFIX:-avr-}" AVR_SIZE="${AVR_SIZE:-${COMPILER_PATH}/${COMPILER_PREFIX}size}" AVR_SIZE_FLAGS="${AVR_SIZE_FLAGS:--C --mcu=${MCU}}" AVR_OBJDUMP="${AVR_OBJDUMP:-${COMPILER_PATH}/${COMPILER_PREFIX}objdump}" +AVR_OBJCOPY="${AVR_OBJCOPY:-${COMPILER_PATH}/${COMPILER_PREFIX}objcopy}" AVR_NM="${AVR_NM:-${COMPILER_PATH}/${COMPILER_PREFIX}nm}" AVR_AR="${AVR_AR:-${COMPILER_PATH}/${COMPILER_PREFIX}ar}" AVR_GCC="${AVR_GCC:-${COMPILER_PATH}/${COMPILER_PREFIX}gcc}"