Replace kaleidoscope-builder with makefiles using arduino-cli

This is a complete rework of how Kaleidoscope is built, but should be largely transparent to most developers and completely invisible to folks using the Arduino IDE.

Some advanced features of kaleidoscope-builder config files have gone away, but it’s likely that @algernon was the only person using them. The tradeoff is that we’re now using a much better maintained build tool under the hood and that we’re no longer as tied to a single specific directory structure.
pull/936/head
Jesse Vincent 4 years ago
parent aaa9603d72
commit d94c3d5234
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -1,75 +1,4 @@
# This stub makefile for a Kaleidoscope plugin pulls in include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/etc/makefiles/arduino-cli.mk
# all targets from the Kaleidoscope-Plugin library
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino
PACKAGE_DIR ?= $(HOME)/Library/Arduino15
else
SKETCHBOOK_DIR ?= $(HOME)/Arduino
PACKAGE_DIR ?= $(HOME)/.arduino15
endif
ARDUINO_INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr 2>/dev/null |head -n 1)
MANUALLY_INSTALLED_ENV=$(shell ls -dt $(SKETCHBOOK_DIR)/hardware/keyboardio/avr 2>/dev/null |head -n 1)
ifneq ("$(wildcard $(ARDUINO_INSTALLED_ENV)/boards.txt)","")
ifneq ("$(wildcard $(MANUALLY_INSTALLED_ENV)/boards.txt)","")
$(info ***************************************************************************)
$(info It appears that you have installed two copies of Kaleidoscope. One copy was)
$(info installed using Arduino's "Board Manager", while the other was installed by)
$(info hand, probably using "git".)
$(info )
$(info This will likely cause some trouble as you try to build keyboard firmware)
$(info using Kaleidoscope. You may want to remove either: )
$(info )
$(info $(PACKAGE_DIR)/packages/keyboardio/ which was installed using Arduino)
$(info )
$(info or)
$(info )
$(info $(SKETCHBOOK_DIR)/hardware/keyboardio/ which was installed by hand.)
$(info )
$(info ***************************************************************************)
$(info )
endif
BOARD_HARDWARE_PATH = $(ARDUINO_INSTALLED_ENV)
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= build-tools/makefiles/
KALEIDOSCOPE_BUILDER_DIR ?= $(ARDUINO_INSTALLED_ENV)/libraries/Kaleidoscope/bin/
endif
BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/build-tools/makefiles/
# If Kaleidoscope's Arduino libraries cannot be found, e.g. because
# they reside outside of SKETCHBOOK_DIR, we fall back to assuming that
# the hardware directory can be determined in relation to the position of
# this Makefile.
ifeq ("$(wildcard $(BOARD_HARDWARE_PATH)/keyboardio/build-tools/makefiles/rules.mk)","")
# Determine the path of this Makefile
MKFILE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BOARD_HARDWARE_PATH = $(MKFILE_DIR)/../../../..
endif
ifeq ("$(wildcard $(BOARD_HARDWARE_PATH)/keyboardio/build-tools/makefiles/rules.mk)","")
$(info ***************************************************************************)
$(info Unable to autodetect a proper BOARD_HARDWARE_PATH. Please define it manually.)
$(info ***************************************************************************)
$(info )
endif
include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk
# Set up an argument for passing to the simulator tests in docker # Set up an argument for passing to the simulator tests in docker
# but if the var isn't set, don't even pass the definition # but if the var isn't set, don't even pass the definition
@ -80,26 +9,43 @@ ifneq ($(TEST_PATH),)
endif endif
DEFAULT_GOAL: smoke-sketches
clean: PLUGIN_TEST_SUPPORT_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/build-tools/
$(MAKE) -C tests clean PLUGIN_TEST_BIN_DIR ?= $(PLUGIN_TEST_SUPPORT_DIR)/../toolchain/$(shell gcc --print-multiarch)/bin
rm -rf testing/googletest/build/*
setup: $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/boards.txt $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/virtual/boards.txt $(ARDUINO_CLI_PATH) configure-arduino-cli install-arduino-core-avr
@:
prepare-virtual:
$(MAKE) -C $(BOARD_HARDWARE_PATH)/keyboardio prepare-virtual
checkout-platform: $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/boards.txt
@:
simulator-tests: prepare-virtual prepare-virtual: $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/virtual/boards.txt
@:
$(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/virtual/boards.txt:
$(MAKE) -C $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio prepare-virtual
$(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/boards.txt:
git clone -c core.symlinks=true --recurse-submodules=":(exclude)avr/libraries/Kaleidoscope" --recurse-submodules=build-tools --recurse-submodules=toolchain --recurse-submodules=avr/libraries/ git://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio
rm -d $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
ln -s $(KALEIDOSCOPE_DIR) $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
simulator-tests: configure-arduino-cli $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/virtual/boards.txt
$(MAKE) -C tests all $(MAKE) -C tests all
docker-simulator-tests: docker-simulator-tests:
BOARD_HARDWARE_PATH="$(BOARD_HARDWARE_PATH)" ./bin/run-docker "make simulator-tests ${TEST_PATH_ARG}" ARDUINO_DIRECTORIES_USER="$(ARDUINO_DIRECTORIES_USER)" ./bin/run-docker "make simulator-tests $(TEST_PATH_ARG)"
docker-clean:
ARDUINO_DIRECTORIES_USER="$(ARDUINO_DIRECTORIES_USER)" ./bin/run-docker "make clean"
docker-bash: docker-bash:
BOARD_HARDWARE_PATH="$(BOARD_HARDWARE_PATH)" ./bin/run-docker "bash" ARDUINO_DIRECTORIES_USER="$(ARDUINO_DIRECTORIES_USER)" ./bin/run-docker "bash"
run-tests: prepare-virtual build-gtest-gmock run-tests: $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/virtual/boards.txt build-gtest-gmock
$(MAKE) -c tests $(MAKE) -c tests
@: # blah @: # blah
@ -115,20 +61,20 @@ find-filename-conflicts:
bin/find-filename-conflicts; \ bin/find-filename-conflicts; \
fi fi
#.PHONY: astyle test cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts: .PHONY: astyle test cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts prepare-virtual checkout-platform adjust-git-timestamps docker-bash docker-simulator-tests run-tests simulator-tests setup
astyle: astyle:
PATH="$(PLUGIN_TEST_BIN_DIR):$(PATH)" $(PLUGIN_TEST_SUPPORT_DIR)/quality/run-astyle bin/run-astyle
check-astyle: astyle check-astyle: astyle
PATH="$(PLUGIN_TEST_BIN_DIR):$(PATH)" $(PLUGIN_TEST_SUPPORT_DIR)/quality/astyle-check bin/astyle-check
cpplint-noisy: cpplint-noisy:
-$(PLUGIN_TEST_SUPPORT_DIR)/quality/cpplint.py --filter=-legal/copyright,-build/include,-readability/namespace,-whitespace/line_length,-runtime/references --recursive --extensions=cpp,h,ino --exclude=$(BOARD_HARDWARE_PATH) src examples -bin/cpplint.py --filter=-legal/copyright,-build/include,-readability/namespace,-whitespace/line_length,-runtime/references --recursive --extensions=cpp,h,ino src examples
cpplint: cpplint:
$(PLUGIN_TEST_SUPPORT_DIR)/quality/cpplint.py --quiet --filter=-whitespace,-legal/copyright,-build/include,-readability/namespace,-runtime/references --recursive --extensions=cpp,h,ino src examples bin/cpplint.py --quiet --filter=-whitespace,-legal/copyright,-build/include,-readability/namespace,-runtime/references --recursive --extensions=cpp,h,ino src examples
SHELL_FILES = $(shell if [ -d bin ]; then egrep -n -r -l "(env (ba)?sh)|(/bin/(ba)?sh)" bin; fi) SHELL_FILES = $(shell if [ -d bin ]; then egrep -n -r -l "(env (ba)?sh)|(/bin/(ba)?sh)" bin; fi)
@ -144,13 +90,18 @@ check-docs:
python $(PLUGIN_TEST_SUPPORT_DIR)/quality/doxy-coverage.py /tmp/undocced/xml python $(PLUGIN_TEST_SUPPORT_DIR)/quality/doxy-coverage.py /tmp/undocced/xml
SMOKE_SKETCHES=$(shell if [ -d ./examples ]; then find ./examples -type f -name \*ino | xargs -n 1 dirname; fi) SMOKE_SKETCHES=$(sort $(shell if [ -d ./examples ]; then find ./examples -type f -name \*ino | xargs -n 1 dirname; fi))
smoke-sketches: $(SMOKE_SKETCHES) smoke-sketches: $(SMOKE_SKETCHES)
@echo "Smoke-tested all the sketches" @echo "Smoke-tested all the sketches"
.PHONY: force .PHONY: force all clean test
clean:
$(MAKE) -C tests clean
rm -rf -- "testing/googletest/build/*"
rm -rf -- "_build/*"
$(SMOKE_SKETCHES): force $(SMOKE_SKETCHES): force
@BOARD_HARDWARE_PATH="$(BOARD_HARDWARE_PATH)" $(KALEIDOSCOPE_BUILDER_DIR)/kaleidoscope-builder $@ compile $(MAKE) -C $@ -f $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk compile

@ -0,0 +1,7 @@
#!/bin/sh
if ! git diff --exit-code; then
>&2 echo "'make astyle' found code style differences. Please make astyle and commit your changes"
exit 1;
fi
exit 0;

6583
bin/cpplint.py vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,4 @@
#!/bin/sh
ASTYLE_IGNORE_PATTERN='testing/googletest/'
find ./* -type f \( -name '*.h' -o -name '*.cpp' -o -name '*.ino' \) | grep -v "$ASTYLE_IGNORE_PATTERN" | xargs -n 1 astyle -q --style=google --unpad-paren --pad-header --pad-oper --indent-classes --indent=spaces=2 --max-continuation-indent=80

@ -0,0 +1,4 @@
// this is a dummy sketch that's just here so that we can get
// arduino-cli to give us properties for our platform if we
// don't have a sketch, like happens when building parts of the
// simulator test infrastructure

@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:avr:keyboardio_atreus",
"port": ""
}
}

@ -0,0 +1,148 @@
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
ifeq ($(VERBOSE),)
ifeq ($(QUIET),)
$(info Building in quiet mode. For a lot more informatiion, add 'VERBOSE=1' to the beginning of your call to $(MAKE))
export QUIET = @
endif
export ARDUINO_VERBOSE ?=
else
export ARDUINO_VERBOSE ?= --verbose
endif
# Build path config
TMPDIR ?= /tmp
export KALEIDOSCOPE_DIR ?= $(abspath $(mkfile_dir)/../..)
KALEIDOSCOPE_BIN_DIR ?= $(KALEIDOSCOPE_DIR)/bin
KALEIDOSCOPE_ETC_DIR ?= $(KALEIDOSCOPE_DIR)/etc
KALEIDOSCOPE_TEMP_PATH ?= $(TMPDIR)/kaleidoscope-$(USER)
KALEIDOSCOPE_BUILD_PATH ?= $(KALEIDOSCOPE_TEMP_PATH)/build
KALEIDOSCOPE_OUTPUT_PATH ?= $(KALEIDOSCOPE_TEMP_PATH)/output
CORE_CACHE_PATH ?= $(KALEIDOSCOPE_TEMP_PATH)/arduino-cores
ARDUINO_CONTENT ?= $(KALEIDOSCOPE_DIR)/.arduino
export ARDUINO_DIRECTORIES_DATA ?= $(ARDUINO_CONTENT)/data
export ARDUINO_DIRECTORIES_DOWNLOADS ?= $(ARDUINO_CONTENT)/downloads
export ARDUINO_CLI_CONFIG ?= $(ARDUINO_DIRECTORIES_DATA)/arduino-cli.yaml
export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS ?= https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
# If it looks like Kaleidoscope is inside a "traditional" Arduino hardware directory
# in the user's homedir, let's use that.
ifeq ($(shell uname -s),Darwin)
traditional_path = $(HOME)/Documents/Arduino/
else
traditional_path = $(HOME)/Arduino/
endif
# use realpath to compare the real absolute path of the kaleidoscope dir
# and the arduino bundle, even if they're symlinked into the Arudino/hardware dir
ifeq ($(realpath $(traditional_path)/hardware/keyboardio/avr/libraries/Kaleidoscope), $(realpath $(KALEIDOSCOPE_DIR)))
export ARDUINO_DIRECTORIES_USER ?= $(traditional_path)
endif
# Otherwise, use the arduino-cli bundle
export ARDUINO_DIRECTORIES_USER ?= $(ARDUINO_CONTENT)/user
# If we're not calling setup, we should freak out if the hardware
# definitions don't exist
ifneq ($(MAKECMDGOALS),setup)
ifeq ($(wildcard $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/boards.txt),)
$(info Kaleidoscope hardware definitions not found in)
$(info $(ARDUINO_DIRECTORIES_USER))
$(info )
$(info You may be able to resolve this issue by running the following command)
$(info to initialize Kaleidoscope )
$(info )
$(info $(MAKE) -C $(KALEIDOSCOPE_DIR) setup )
$(info )
$(error )
endif
endif
system_arduino_cli=$(shell command -v arduino-cli || true)
arduino_env = ARDUINO_DIRECTORIES_USER=$(ARDUINO_DIRECTORIES_USER) \
ARDUINO_DIRECTORIES_DATA=$(ARDUINO_DIRECTORIES_DATA)
ifeq ($(system_arduino_cli),)
export ARDUINO_CLI_PATH ?= $(KALEIDOSCOPE_BIN_DIR)/arduino-cli
else
export ARDUINO_CLI_PATH ?= $(system_arduino_cli)
endif
export ARDUINO_CLI ?= $(arduino_env) $(ARDUINO_CLI_PATH)
ifneq ($(VERBOSE),)
$(info Using ardino-cli from $(ARDUINO_CLI_PATH))
endif
ifneq ($(FQBN),)
fqbn_arg = --fqbn $(FQBN)
endif
# if we don't have a sketch, make a pretend one so we can run --show properties
# This is because arduino-cli doesn't currently allow us to get props with
# just an FQBN. We've filed a bug with them
ifeq ($(SKETCH_FILE_PATH),)
_arduino_props_sketch_arg = $(KALEIDOSCOPE_ETC_DIR)/dummy-sketch/
else
_arduino_props_sketch_arg = $(SKETCH_FILE_PATH)
endif
# This is horrible. But because make doesn't really support
# multi-line variables and we want to cache the full
# _arduino_props in a variable, which means letting make
# split the properties on space, which is what it converts
# newlines into. To make this go, we we need to replace interior
# spaces in the variables with something. We chose the fire
# emoji, since it accurately represents our feelings on this
# state of affairs. Later, when finding props, we need to reverse
# this process, turning fire into space.
_arduino_props := $(shell ${ARDUINO_CLI} compile $(fqbn_arg) --show-properties "$(_arduino_props_sketch_arg)"|perl -p -e"s/ /🔥/g")
_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
.PHONY: stupid-workaround-for-make-inclusion-semantics
stupid-workaround-for-make-inclusion-semantics: DEFAULT_GOAL
@: # This is here so that the sketch makefile including this file doesn't
@: # default to arduino-cli installation as its priamry target
$(KALEIDOSCOPE_BIN_DIR)/arduino-cli:
$(QUIET) curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$(KALEIDOSCOPE_BIN_DIR)" sh
install-arduino-cli: $(KALEIDOSCOPE_BIN_DIR)/arduino-cli
configure-arduino-cli:
$(QUIET) $(ARDUINO_CLI) config init
install-arduino-core-kaleidoscope:
$(QUIET) $(ARDUINO_CLI) core install "keyboardio:avr"
install-arduino-core-avr:
$(QUIET) $(ARDUINO_CLI) core install "arduino:avr"

@ -0,0 +1,211 @@
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# If the sketch is defined
ifneq ($(SKETCH),)
# If the sketch isn't a directory, we want to get the directory the sketch is in
ifeq ($(wildcard $(SKETCH)/.),)
SKETCH_DIR := $(dir $(SKETCH))
endif
else
# If the sketch wasn't defined as we came in, assume the current directory
# is where we're looking
SKETCH_DIR := $(realpath $(CURDIR))
endif
SKETCH_BASE_NAME := $(notdir $(SKETCH_DIR))
SKETCH_FILE_NAME := $(addsuffix .ino, $(SKETCH_BASE_NAME))
# Find the path of the sketch file
SKETCH_DIR_CANDIDATES = $(sketch_dir) src/ .
sketch_exists_p = $(realpath $(wildcard $(dir)/$(SKETCH_FILE_NAME)))
SKETCH_FILE_PATH := $(firstword $(foreach dir,$(SKETCH_DIR_CANDIDATES),$(sketch_exists_p)))
include $(mkfile_dir)/arduino-cli.mk
ifeq ($(FQBN),)
export FQBN = $(call _arduino_prop,build.fqbn)
ifneq ($(VERBOSE),)
$(info Arduino provided FQBN $(call _arduino_prop,build.fqbn))
endif
endif
# We -could- check to see if sketch-dir is in git before running this command
# but since we'd just return an empty value in that case, why bother?
GIT_VERSION := $(shell git -C "$(SKETCH_DIR)" describe --abbrev=6 --dirty --alway 2>/dev/null || echo 'unknown')
SKETCH_IDENTIFIER ?= $(shell echo "${SKETCH_FILE_PATH}" | cksum | cut -d ' ' -f 1)-$(SKETCH_FILE_NAME)
BUILD_PATH ?= $(KALEIDOSCOPE_BUILD_PATH)/$(SKETCH_IDENTIFIER)
OUTPUT_PATH ?= $(KALEIDOSCOPE_OUTPUT_PATH)/$(SKETCH_IDENTIFIER)
OUTPUT_FILE_PREFIX := $(SKETCH_BASE_NAME)-$(GIT_VERSION)
HEX_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).hex
HEX_FILE_WITH_BOOTLOADER_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX)-with-bootloader.hex
ELF_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).elf
LIB_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).a
KALEIDOSCOPE_PLATFORM_LIB_DIR := $(abspath $(KALEIDOSCOPE_DIR)/..)
ifeq ($(FQBN),)
possible_fqbns = $(shell $(ARDUINO_CLI) board list --format=json |grep FQBN| grep -v "keyboardio:virtual"|cut -d: -f 2-)
possible_fqbn = $(firstword $(possible_fqbns))
$(info *************************************************************** )
$(info )
$(info Arduino couldn't figure out what kind of device this sketch )
$(info is for. Usually, Arduino looks in a file called `sketch.json` )
$(info to figure this out. )
ifneq ($(possible_fqbn),)
fake_var_to_run_shell := $(shell $(ARDUINO_CLI) board attach $(possible_fqbn))
$(info )
$(info I have detected a connected device supported by Kaleidoscope and)
$(info attepted to automatically resolve this issue by running the)
$(info following command:)
$(info )
$(info $(ARDUINO_CLI) board attach $(possible_fqbn))
$(info )
$(info If the build fails or $(possible_fqbn) doesn't)
$(info look like your keyboard, you may need to manually edit your)
$(info `sketch.json` file or run )
$(info )
$(info $(ARDUINO_CLI) board attach )
$(info )
$(info manually, specifying the FQBN for your keyboard. )
$(info )
$(info *************************************************************** )
else
$(info )
$(info I'm unable to detect your keyboard, you may need to manually )
$(info edit your `sketch.json` file or run )
$(info )
$(info $(ARDUINO_CLI) board attach )
$(info )
$(info manually, specifying the FQBN for your keyboard. )
$(info )
$(info *************************************************************** )
$(error )
endif
endif
# Flashing related config
ifneq ($(FQBN),)
KALEIDOSCOPE_DEVICE_PORT ?= $(shell $(ARDUINO_CLI) board list --format=text | grep $(FQBN) |cut -d' ' -f 1)
endif
flashing_instructions := $(shell printf $(call _arduino_prop,build.flashing_instructions))
ifeq ($(flashing_instructions),)
flashing_instruction := "If your keyboard needs you to do something to put it in flashing mode, do that now."
endif
DEFAULT_GOAL: compile
#$(SKETCH_FILE_PATH):
# @: # dummy recipe for the sketch file
.PHONY: compile configure-arduino-cli install-arduino-core-kaleidoscope install-arduino-core-avr
.PHONY: disassemble decompile size-map flash clean all test
all: compile
@: ## Do not remove this line, otherwise `make all` will trigger the `%` rule too.
disassemble: ${ELF_FILE_PATH}
$(call _arduino_prop,compiler.objdump.cmd) \
$(call _arduino_prop,compiler.objdump.flags) \
"${ELF_FILE_PATH}"
size-map: ${ELF_FILE_PATH}
$(call _arduino_prop,compiler.size-map.cmd) \
$(call _arduino_prop,compiler.size-map.flags) \
"${ELF_FILE_PATH}"
flash: ${HEX_FILE_PATH}
${ELF_FILE_PATH}: compile
${HEX_FILE_PATH}: compile
BOOTLOADER_PATH := $(call _arduino_prop,runtime.platform.path)/bootloaders/$(call _arduino_prop,bootloader.file)
hex-with-bootloader: ${HEX_FILE_PATH}
$(QUIET) awk '/^:00000001FF/ == 0' "${HEX_FILE_PATH}" >"${HEX_FILE_WITH_BOOTLOADER_PATH}"
$(QUIET) cat "${BOOTLOADER_PATH}" >>"${HEX_FILE_WITH_BOOTLOADER_PATH}"
$(QUIET) ln -sf -- "${OUTPUT_FILE_PREFIX}-with-bootloader.hex" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest-with-bootloader.hex"
$(info Combined firmware and bootloader are now at)
$(info ${HEX_FILE_WITH_BOOTLOADER_PATH})
$(info )
$(info Make sure you have the bootloader version you expect.)
$(info )
$(info )
$(info And TEST THIS ON REAL HARDWARE BEFORE YOU GIVE IT TO ANYONE.)
clean:
$(QUIET) rm -rf -- "${OUTPUT_PATH}"/*
ifneq ($(LOCAL_CFLAGS),)
local_cflags_property = --build-properties "compiler.cpp.extra_flags=${LOCAL_CFLAGS}"
else
local_cflags_property =
endif
compile:
$(QUIET) install -d "${OUTPUT_PATH}"
$(QUIET) $(ARDUINO_CLI) compile --fqbn "${FQBN}" ${ARDUINO_VERBOSE} --warnings all ${ccache_wrapper_property} ${local_cflags_property} \
--libraries "${KALEIDOSCOPE_PLATFORM_LIB_DIR}" \
--build-path "${BUILD_PATH}" \
--output-dir "${OUTPUT_PATH}" \
--build-cache-path "${CORE_CACHE_PATH}" \
"${SKETCH_FILE_PATH}"
ifeq ($(LIBONLY),)
$(QUIET) cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.hex" "${HEX_FILE_PATH}"
$(QUIET) cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.elf" "${ELF_FILE_PATH}"
$(QUIET) ln -sf "${OUTPUT_FILE_PREFIX}.hex" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.hex"
$(QUIET) ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.elf"
else
$(QUIET) cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.a" "${LIB_FILE_PATH}"
$(QUIET) ln -sf "${OUTPUT_FILE_PREFIX}.a" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.a"
endif
ifneq ($(VERBOSE),)
$(info Build artifacts can be found in ${BUILD_PATH})
endif
#TODO (arduino team) I'd love to do this with their json output
#but it's short some of the data we kind of need
flash:
ifeq ($(KALEIDOSCOPE_DEVICE_PORT),)
$(info ERROR: Unable to detect keyboard serial port.)
$(info )
$(info Arduino should autodetect it, but you could also set )
$(info KALEIDOSCOPE_DEVICE_PORt to your keyboard's serial port.)
$(info )
$(error )
endif
$(info $(flashing_instructions))
$(info )
$(info When you're ready to proceed, press 'Enter'.)
$(info )
@$(shell read)
$(QUIET) $(ARDUINO_CLI) upload --fqbn $(FQBN) \
--input-dir "${OUTPUT_PATH}" \
--port $(KALEIDOSCOPE_DEVICE_PORT) $(ARDUINO_VERBOSE)
Loading…
Cancel
Save