From 306a9f45fdc78969de0b590dbb9a0c02cc459759 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 17 Nov 2020 17:11:39 -0800 Subject: [PATCH] get back ccache support --- etc/docker-entrypoint.sh | 2 ++ etc/makefiles/arduino-cli.mk | 4 ++++ etc/makefiles/sketch.mk | 2 +- testing/makefiles/libcommon.mk | 7 ++++++- testing/makefiles/testcase.mk | 8 ++++++-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/etc/docker-entrypoint.sh b/etc/docker-entrypoint.sh index baac3824..a999ece2 100755 --- a/etc/docker-entrypoint.sh +++ b/etc/docker-entrypoint.sh @@ -17,4 +17,6 @@ ln -s /kaleidoscope/hardware/keyboardio/virtual/libraries/Kaleidoscope \ cd /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope export ARDUINO_DIRECTORIES_DATA=/arduino-cli/data +export KALEIDOSCOPE_CCACHE=1 + /bin/bash -c "$*" diff --git a/etc/makefiles/arduino-cli.mk b/etc/makefiles/arduino-cli.mk index 45c662bb..61d568ae 100644 --- a/etc/makefiles/arduino-cli.mk +++ b/etc/makefiles/arduino-cli.mk @@ -61,6 +61,10 @@ _arduino_prop = $(subst $1=,,$(subst 🔥, ,$(filter $1=%,$(_arduino_props)))) # How to use_arduino_prop # $(call _arduino_prop,recipe.hooks.sketch.prebuild.2.pattern) +ifneq ($(KALEIDOSCOPE_CCACHE),) +ccache_wrapper_property := --build-properties "compiler.wrapper.cmd=ccache" +endif + .PHONY: configure-arduino-cli install-arduino-core-kaleidoscope install-arduino-core-avr non-goal: diff --git a/etc/makefiles/sketch.mk b/etc/makefiles/sketch.mk index ae61491f..a3f1a85d 100644 --- a/etc/makefiles/sketch.mk +++ b/etc/makefiles/sketch.mk @@ -134,7 +134,7 @@ compile: --output-dir "${OUTPUT_PATH}" \ --build-cache-path "${CORE_CACHE_PATH}" \ --build-properties "compiler.cpp.extra_flags=${LOCAL_CFLAGS}" \ - --warnings all ${ARDUINO_VERBOSE} \ + --warnings all ${ARDUINO_VERBOSE} ${ccache_wrapper_property} \ "${SKETCH_FILE_PATH}" ifeq ($(LIBONLY),) @cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.hex" "${HEX_FILE_PATH}" diff --git a/testing/makefiles/libcommon.mk b/testing/makefiles/libcommon.mk index 78e0fa94..5da205be 100644 --- a/testing/makefiles/libcommon.mk +++ b/testing/makefiles/libcommon.mk @@ -13,6 +13,11 @@ BARE_CXX_FILES := $(foreach path,${CXX_FILES},$(notdir ${path})) OBJ_FILES := $(patsubst %.cpp,${OBJ_DIR}/%.o,$(BARE_CXX_FILES)) LIB_FILE := libcommon.a +ifneq ($(KALEIDOSCOPE_CCACHE),) +COMPILER_WRAPPER := ccache +endif + + .PHONY: all DEFAULT_GOAL: all @@ -26,7 +31,7 @@ ${LIB_DIR}/${LIB_FILE}: ${OBJ_FILES} ${OBJ_DIR}/%.o: ${top_dir}/testing/%.cpp ${H_FILES} $(info compile $@) @install -d "${OBJ_DIR}" - g++ -o "$@" -c \ + $(COMPILER_WRAPPER) g++ -o "$@" -c \ -std=c++14 \ -I${top_dir} \ -I${top_dir}/src \ diff --git a/testing/makefiles/testcase.mk b/testing/makefiles/testcase.mk index 52c2404a..90025a38 100644 --- a/testing/makefiles/testcase.mk +++ b/testing/makefiles/testcase.mk @@ -12,6 +12,10 @@ COMMON_LIB_DIR := ${top_dir}/_build/lib include $(top_dir)/etc/makefiles/arduino-cli.mk +ifneq ($(KALEIDOSCOPE_CCACHE),) +COMPILER_WRAPPER := ccache +endif + SRC_DIR := test @@ -57,7 +61,7 @@ compile-sketch: OUTPUT_PATH="${LIB_DIR}" \ VERBOSE=${VERBOSE} \ $(MAKE) -f ${top_dir}/testing/makefiles/delegate.mk compile - $(call _arduino_prop,compiler.cpp.cmd) -o "${BIN_DIR}/${BIN_FILE}" \ + $(CCACHE) $(call _arduino_prop,compiler.cpp.cmd) -o "${BIN_DIR}/${BIN_FILE}" \ -lpthread \ -g \ -w \ @@ -89,7 +93,7 @@ endif ${OBJ_DIR}/%.o: ${SRC_DIR}/%.cpp @echo "compile $@" install -d "${OBJ_DIR}" - $(call _arduino_prop,compiler.cpp.cmd) -o "$@" -c \ + $(CCACHE) $(call _arduino_prop,compiler.cpp.cmd) -o "$@" -c \ -std=c++14 \ -I${top_dir} \ -I${top_dir}/src \