Tease apart sketch and Kaleidoscope makefiles

tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent c6a3e85122
commit ba3721187b
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -21,13 +21,13 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
ifeq ("$(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk","") ifeq ("$(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk","")
# Determine the path of this Makefile # Determine the path of this Makefile
KALEIDOSCOPE_ETC_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/etc KALEIDOSCOPE_ETC_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/etc
endif endif
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/arduino-cli.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
@ -37,10 +37,6 @@ ifneq ($(TEST_PATH),)
TEST_PATH_ARG="TEST_PATH='$(TEST_PATH)'" TEST_PATH_ARG="TEST_PATH='$(TEST_PATH)'"
endif endif
clean:
$(MAKE) -C tests clean
rm -rf testing/googletest/build/*
PLUGIN_TEST_SUPPORT_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/build-tools/ PLUGIN_TEST_SUPPORT_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/build-tools/
PLUGIN_TEST_BIN_DIR ?= $(PLUGIN_TEST_SUPPORT_DIR)/../toolchain/$(shell gcc --print-multiarch)/bin PLUGIN_TEST_BIN_DIR ?= $(PLUGIN_TEST_SUPPORT_DIR)/../toolchain/$(shell gcc --print-multiarch)/bin
@ -111,9 +107,10 @@ smoke-sketches: $(SMOKE_SKETCHES)
.PHONY: force .PHONY: force
clean: clean:
rm -rf -- "testing/googletest/build" $(MAKE) -C tests clean
rm -rf -- "_build" rm -rf -- "testing/googletest/build/*"
@$(KALEIDOSCOPE_BUILDER_DIR)/kaleidoscope-builder clean rm -rf -- "_build/*"
$(SMOKE_SKETCHES): force $(SMOKE_SKETCHES): force
$(MAKE) -C $@ -f $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk compile $(MAKE) -C $@ -f $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk compile

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -0,0 +1,73 @@
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
# Make a variable lazily evaluated at first call
# From https://blog.jgc.org/2016/07/lazy-gnu-make-variables.html
make-lazy = $(eval $1 = $$(eval $1 := $(value $(1)))$$($1))
export KALEIDOSCOPE_DIR ?= $(abspath $(mkfile_dir)/../..)
export KALEIDOSCOPE_BIN_DIR ?= $(KALEIDOSCOPE_DIR)/bin
# Arduino CLI config
export ARDUINO_CONTENT ?= $(KALEIDOSCOPE_DIR)/.arduino
export ARDUINO_DIRECTORIES_DATA ?= $(ARDUINO_CONTENT)/data
export ARDUINO_DIRECTORIES_DOWNLOADS ?= $(ARDUINO_CONTENT)/downloads
export ARDUINO_DIRECTORIES_USER ?= $(ARDUINO_CONTENT)/user
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
system_arduino_cli=$(shell command -v arduino-cli || true)
ifeq ($(system_arduino_cli),)
export ARDUINO_CLI ?= $(KALEIDOSCOPE_BIN_DIR)/arduino-cli
else
export ARDUINO_CLI ?= $(system_arduino_cli)
endif
ifneq ($(VERBOSE),)
export ARDUINO_VERBOSE ?= --verbose
else
export ARDUINO_VERBOSE ?=
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 --show-properties "$${SKETCH_FILE_PATH}"|perl -p -e"s/ /🔥/g")
$(call make-lazy,_arduino_props)
_arduino_prop = $(subst $1=,,$(subst 🔥, ,$(filter $1=%,$(_arduino_props))))
# How to use_arduino_prop
# $(call _arduino_prop,recipe.hooks.sketch.prebuild.2.pattern)
#
.PHONY: configure-arduino-cli install-arduino-core-kaleidoscope install-arduino-core-avr
.DEFAULT_GOAL := all
all:
@echo "Make all target doesn't do anything"
@: ## Do not remove this line, otherwise `make all` will trigger the `%` rule too.
install-arduino-cli:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$(KALEIDOSCOPE_BIN_DIR)" sh
configure-arduino-cli:
$(ARDUINO_CLI) config init
install-arduino-core-kaleidoscope:
$(ARDUINO_CLI) core install "keyboardio:avr"
install-arduino-core-avr:
$(ARDUINO_CLI) core install "arduino:avr"

@ -1,55 +1,7 @@
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path)) mkfile_dir := $(dir $(mkfile_path))
include $(mkfile_dir)/arduino-cli.mk
# Make a variable lazily evaluated at first call
# From https://blog.jgc.org/2016/07/lazy-gnu-make-variables.html
make-lazy = $(eval $1 = $$(eval $1 := $(value $(1)))$$($1))
export KALEIDOSCOPE_DIR ?= $(abspath $(mkfile_dir)/..)
export KALEIDOSCOPE_BIN_DIR ?= $(KALEIDOSCOPE_DIR)/bin
# Arduino CLI config
export ARDUINO_CONTENT ?= $(KALEIDOSCOPE_DIR)/.arduino
export ARDUINO_DIRECTORIES_DATA ?= $(ARDUINO_CONTENT)/data
export ARDUINO_DIRECTORIES_DOWNLOADS ?= $(ARDUINO_CONTENT)/downloads
export ARDUINO_DIRECTORIES_USER ?= $(ARDUINO_CONTENT)/user
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
system_arduino_cli=$(shell command -v arduino-cli || true)
ifeq ($(system_arduino_cli),)
export ARDUINO_CLI ?= $(KALEIDOSCOPE_BIN_DIR)/arduino-cli
else
export ARDUINO_CLI ?= $(system_arduino_cli)
endif
ifneq ($(VERBOSE),)
export ARDUINO_VERBOSE ?= --verbose
else
export ARDUINO_VERBOSE ?=
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 --show-properties "$${SKETCH_FILE_PATH}"|perl -p -e"s/ /🔥/g")
$(call make-lazy,_arduino_props)
_arduino_prop = $(subst $1=,,$(subst 🔥, ,$(filter $1=%,$(_arduino_props))))
# How to use_arduino_prop
# $(call _arduino_prop,recipe.hooks.sketch.prebuild.2.pattern)
#
# Build path config # Build path config
TMPDIR ?= /tmp TMPDIR ?= /tmp
@ -83,12 +35,6 @@ sketch_exists_p = $(realpath $(wildcard $(dir)/$(SKETCH_FILE_NAME)))
export FQBN := $(call _arduino_prop,build.fqbn) export FQBN := $(call _arduino_prop,build.fqbn)
# Flashing related config
port = $(shell $(ARDUINO_CLI) board list --format=text | grep $(FQBN) |cut -d' ' -f 1)
flashing_instructions = $(call _arduino_prop,build.flashing_instructions)
ifeq ($(flashing_instructions),)
flashing_instructions = "If your keyboard needs you to do something to put it in flashing mode, do that now."
endif
export BOOTLOADER_PATH := $(call _arduino_prop,runtime.platform.path)/bootloaders/$(call _arduino_prop,bootloader.file) export BOOTLOADER_PATH := $(call _arduino_prop,runtime.platform.path)/bootloaders/$(call _arduino_prop,bootloader.file)
@ -124,7 +70,7 @@ export LIB_PROPERTIES_PATH := "../.."
# We should use compiler.path instead of appending bin, but we # We should use compiler.path instead of appending bin, but we
# don't have substitution for arduino props yet # don't have substitution for arduino props yet
export COMPILER_PATH := $(call _arduino_prop,runtime.tools.avr-gcc.path)/bin #export COMPILER_PATH := $(call _arduino_prop,runtime.tools.avr-gcc.path)/bin
# Allow the compiler prefix to be empty for virtual builds # Allow the compiler prefix to be empty for virtual builds
COMPILER_PREFIX ?= avr- COMPILER_PREFIX ?= avr-
@ -147,18 +93,6 @@ all:
@: ## Do not remove this line, otherwise `make all` will trigger the `%` rule too. @: ## Do not remove this line, otherwise `make all` will trigger the `%` rule too.
install-arduino-cli:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$(KALEIDOSCOPE_BIN_DIR)" sh
configure-arduino-cli:
$(ARDUINO_CLI) config init
install-arduino-core-kaleidoscope:
$(ARDUINO_CLI) core install "keyboardio:avr"
install-arduino-core-avr:
$(ARDUINO_CLI) core install "arduino:avr"
disassemble: ${ELF_FILE_PATH} disassemble: ${ELF_FILE_PATH}
${AVR_OBJDUMP} -C -d "${ELF_FILE_PATH}" ${AVR_OBJDUMP} -C -d "${ELF_FILE_PATH}"
@ -216,6 +150,11 @@ endif
#but it's short some of the data we kind of need #but it's short some of the data we kind of need
flash: flash:
flashing_instructions := $(call _arduino_prop,build.flashing_instructions)
ifeq ($(flashing_instructions),)
flashing_instructions := "If your keyboard needs you to do something to put it in flashing mode, do that now."
endif
port = $(shell $(ARDUINO_CLI) board list --format=text | grep $(FQBN) |cut -d' ' -f 1)
ifeq ($(port),) ifeq ($(port),)
$(info Unable to detect keyboard serial port.) $(info Unable to detect keyboard serial port.)
#@exit 1 #@exit 1

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

@ -16,4 +16,4 @@ endif
KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/ KALEIDOSCOPE_ETC_DIR ?= $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope/etc/
include $(KALEIDOSCOPE_ETC_DIR)/sketch-arduino-cli.mk include $(KALEIDOSCOPE_ETC_DIR)/makefiles/sketch.mk

Loading…
Cancel
Save