From 2f9abe8125fdcc6d5adf8f3fa01d4374ad1f9bb9 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 15 Nov 2023 13:29:24 -0800 Subject: [PATCH] Add a developer affordance, ".kaleidoscope_board" in the sketch directory that contains the name of the KALEIDOSCOPE_HARDWARE_H file. This allows a developer building a sketch for hardware using an arduino core that doesn't "announce" the KALEIDOSCOPE_HARDWARE_H environment variable to actually be able to build a sketch. Unfortunately, this feature doesn't work in the arduino ide because it requires our makefiles to run --- etc/makefiles/sketch.mk | 12 ++++++++++-- .../Devices/Keyboardio/Model101/.kaleidoscope_board | 1 + examples/Devices/Keyboardio/Model101/Model101.ino | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 examples/Devices/Keyboardio/Model101/.kaleidoscope_board diff --git a/etc/makefiles/sketch.mk b/etc/makefiles/sketch.mk index caa2af6c12..16acb7edcc 100644 --- a/etc/makefiles/sketch.mk +++ b/etc/makefiles/sketch.mk @@ -161,12 +161,20 @@ ifneq ($(KALEIDOSCOPE_LOCAL_LIB_DIR),) _arduino_local_libraries_prop = --libraries "${KALEIDOSCOPE_LOCAL_LIB_DIR}" endif -compile: kaleidoscope-hardware-configured +# Check if the .kaleidoscope_board file exists +ifneq ("$(wildcard ${SKETCH_DIR}/.kaleidoscope_board)","") + # Read the content of the file + KALEIDOSCOPE_BOARD_CONTENT := $(shell cat ${SKETCH_DIR}/.kaleidoscope_board) + + # Set the kaleidoscope_board_config variable + kaleidoscope_board_config := --build-property compiler.cpp.extra_flags=-DKALEIDOSCOPE_HARDWARE_H=\"$(KALEIDOSCOPE_BOARD_CONTENT)\" +endif +compile: kaleidoscope-hardware-configured -$(QUIET) install -d "${OUTPUT_PATH}" $(QUIET) $(ARDUINO_CLI) compile --fqbn "${FQBN}" ${ARDUINO_VERBOSE} ${ccache_wrapper_property} ${local_cflags_property} \ - ${_arduino_local_libraries_prop} ${_ARDUINO_CLI_COMPILE_CUSTOM_FLAGS} \ + ${_arduino_local_libraries_prop} ${_ARDUINO_CLI_COMPILE_CUSTOM_FLAGS} ${kaleidoscope_board_config}\ --library "${KALEIDOSCOPE_DIR}" \ --libraries "${KALEIDOSCOPE_DIR}/plugins/" \ --build-path "${BUILD_PATH}" \ diff --git a/examples/Devices/Keyboardio/Model101/.kaleidoscope_board b/examples/Devices/Keyboardio/Model101/.kaleidoscope_board new file mode 100644 index 0000000000..185bbd8b0d --- /dev/null +++ b/examples/Devices/Keyboardio/Model101/.kaleidoscope_board @@ -0,0 +1 @@ +Kaleidoscope-Hardware-Keyboardio-Model101.h diff --git a/examples/Devices/Keyboardio/Model101/Model101.ino b/examples/Devices/Keyboardio/Model101/Model101.ino index 247fe330d0..9129f0bcb2 100644 --- a/examples/Devices/Keyboardio/Model101/Model101.ino +++ b/examples/Devices/Keyboardio/Model101/Model101.ino @@ -7,7 +7,9 @@ * as well as the Kaleidoscope plugins we use in the Model 100's firmware */ + // The Kaleidoscope core + #include "Kaleidoscope.h" // Support for storing the keymap in EEPROM