port _arduino_prop to make

This is kind of criminal, but I'm very proud of it.
tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent 6ada3ab98d
commit 834d3d1d7d
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -2,6 +2,15 @@ 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
@ -28,6 +37,24 @@ 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

Loading…
Cancel
Save