diff --git a/testing/makefiles/libcommon.mk b/testing/makefiles/libcommon.mk index 5da205be..3dc476a4 100644 --- a/testing/makefiles/libcommon.mk +++ b/testing/makefiles/libcommon.mk @@ -1,8 +1,9 @@ -top_dir := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))../..) -build_dir := ${top_dir}/_build +mkfile_dir := $(dir $(lastword ${MAKEFILE_LIST})) +top_dir := $(abspath $(mkfile_dir)../..) +include $(mkfile_dir)/shared.mk -bundle_path = ${ARDUINO_DIRECTORIES_USER}/hardware/keyboardio/avr/libraries +build_dir := ${top_dir}/_build LIB_DIR := ${build_dir}/lib OBJ_DIR := ${build_dir}/obj @@ -31,24 +32,7 @@ ${LIB_DIR}/${LIB_FILE}: ${OBJ_FILES} ${OBJ_DIR}/%.o: ${top_dir}/testing/%.cpp ${H_FILES} $(info compile $@) @install -d "${OBJ_DIR}" - $(COMPILER_WRAPPER) g++ -o "$@" -c \ - -std=c++14 \ - -I${top_dir} \ - -I${top_dir}/src \ - -I${bundle_path}/../../virtual/cores/arduino \ - -I${bundle_path}/KeyboardioHID/src \ - -I${top_dir}/testing/googletest/googlemock/include \ - -I${top_dir}/testing/googletest/googletest/include \ - -DARDUINO=10607 \ - -DARDUINO_ARCH_VIRTUAL \ - -DARDUINO_AVR_MODEL01 \ - '-DKALEIDOSCOPE_HARDWARE_H="Kaleidoscope-Hardware-Model01.h"' \ - -DKALEIDOSCOPE_VIRTUAL_BUILD=1 \ - -DKEYBOARDIOHID_BUILD_WITHOUT_HID=1 \ - -DUSBCON=dummy \ - -DARDUINO_ARCH_AVR=1 \ - '-DUSB_PRODUCT="Model 01"' \ - $< + $(COMPILER_WRAPPER) g++ -o "$@" -c -std=c++14 ${shared_includes} ${shared_defines} $< clean: rm -rf -- "${build_dir}" diff --git a/testing/makefiles/shared.mk b/testing/makefiles/shared.mk new file mode 100644 index 00000000..9c4b2e32 --- /dev/null +++ b/testing/makefiles/shared.mk @@ -0,0 +1,21 @@ +arduino_platform_path := ${ARDUINO_DIRECTORIES_USER}/hardware/keyboardio/virtual/ + +shared_defines := \ + -DARDUINO=10607 \ + -DARDUINO_ARCH_VIRTUAL \ + -DKALEIDOSCOPE_VIRTUAL_BUILD=1 \ + -DKEYBOARDIOHID_BUILD_WITHOUT_HID=1 \ + -DUSBCON=dummy \ + -DARDUINO_ARCH_AVR=1 \ + -DARDUINO_AVR_MODEL01 \ + '-DKALEIDOSCOPE_HARDWARE_H="Kaleidoscope-Hardware-Model01.h"' \ + '-DUSB_PRODUCT="Model 01"' + +shared_includes := \ + -I${top_dir} \ + -I${top_dir}/src \ + -I${arduino_platform_path}/cores/arduino \ + -I${arduino_platform_path}/libraries/KeyboardioHID/src \ + -I${top_dir}/testing/googletest/googlemock/include \ + -I${top_dir}/testing/googletest/googletest/include \ + diff --git a/testing/makefiles/testcase.mk b/testing/makefiles/testcase.mk index 85b2632a..9e9111d5 100644 --- a/testing/makefiles/testcase.mk +++ b/testing/makefiles/testcase.mk @@ -1,9 +1,10 @@ -top_dir := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))../..) +mkfile_dir := $(dir $(lastword ${MAKEFILE_LIST})) +top_dir := $(abspath $(mkfile_dir)../..) +include $(mkfile_dir)/shared.mk build_dir := ${top_dir}/_build/${testcase} - LIB_DIR := ${build_dir}/lib OBJ_DIR := ${build_dir}/obj BIN_DIR := ${build_dir}/bin @@ -40,8 +41,6 @@ endif TEST_OBJS=$(patsubst $(SRC_DIR)/%.cpp,${OBJ_DIR}/%.o,$(TEST_FILES)) -bundle_path = ${ARDUINO_DIRECTORIES_USER}/hardware/keyboardio/avr/libraries - build: ${BIN_DIR}/${BIN_FILE} compile-sketch all: run @@ -93,24 +92,8 @@ endif ${OBJ_DIR}/%.o: ${SRC_DIR}/%.cpp @echo "compile $@" install -d "${OBJ_DIR}" - $(COMPILER_WRAPPER) $(call _arduino_prop,compiler.cpp.cmd) -o "$@" -c \ - -std=c++14 \ - -I${top_dir} \ - -I${top_dir}/src \ - -I${bundle_path}/../../virtual/cores/arduino \ - -I${bundle_path}/KeyboardioHID/src \ - -I${top_dir}/testing/googletest/googlemock/include \ - -I${top_dir}/testing/googletest/googletest/include \ - -DARDUINO=10607 \ - -DARDUINO_ARCH_VIRTUAL \ - -DARDUINO_AVR_MODEL01 \ - '-DKALEIDOSCOPE_HARDWARE_H="Kaleidoscope-Hardware-Model01.h"' \ - -DKALEIDOSCOPE_VIRTUAL_BUILD=1 \ - -DKEYBOARDIOHID_BUILD_WITHOUT_HID=1 \ - -DUSBCON=dummy \ - -DARDUINO_ARCH_AVR=1 \ - '-DUSB_PRODUCT="Model 01"' \ - $< + $(COMPILER_WRAPPER) $(call _arduino_prop,compiler.cpp.cmd) \ + -o "$@" -c -std=c++14 ${shared_includes} ${shared_defines} $< clean: rm -f -- "${SRC_DIR}/generated-testcase.cpp"