From 6050ab7add7f362e6c3e820156513a6e9e8c0708 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Fri, 19 Aug 2022 13:52:37 +1000 Subject: [PATCH 1/2] py/Makefile: Add helper to declare variables as dependencies. depend_var is a function that can be used to add a virtual dependency to a target based on the given make variable, eg: $(OBJ): $(call depend_var, MY_VAR) --- py/mkenv.mk | 5 +++++ py/mkrules.mk | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/py/mkenv.mk b/py/mkenv.mk index ea2e34f3b6..b1deaa50b2 100644 --- a/py/mkenv.mk +++ b/py/mkenv.mk @@ -29,6 +29,11 @@ else Q = endif +# depend_var is a function that can be used to add a virtual dependency +# to a target based on the given make variable. +# eg. $(OBJ): $(call depend_var, MY_VAR) +depend_var = $(BUILD)/dependvar/$(strip $(1))+$(shell echo $($(strip $(1))) | md5sum | cut -d ' ' -f 1) + # default settings; can be overridden in main Makefile PY_SRC ?= $(TOP)/py diff --git a/py/mkrules.mk b/py/mkrules.mk index 14f1b953cd..af7e2bff52 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -25,6 +25,14 @@ QSTR_GEN_CFLAGS += $(QSTR_GEN_FLAGS) QSTR_GEN_CXXFLAGS := $(CXXFLAGS) QSTR_GEN_CXXFLAGS += $(QSTR_GEN_FLAGS) +# depend_var is a function that can be used to add a virtual dependency +# to a target based on the given make variable. +# eg. $(OBJ): $(call depend_var, MY_VAR) +$(BUILD)/dependvar/%: + @mkdir -p $(BUILD)/dependvar + @rm -f $(BUILD)/dependvar/$(firstword $(subst +, ,$*))+* + $(Q)echo $($(firstword $(subst +, ,$*))) > $@ + # This file expects that OBJ contains a list of all of the object files. # The directory portion of each object file is used to locate the source # and should not contain any ..'s but rather be relative to the top of the From fb7ba43d8181189a92708f6354e71744a716f5b3 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Fri, 19 Aug 2022 13:53:22 +1000 Subject: [PATCH 2/2] stm32/Makefile: Automatically rebuild if make USE_MBOOT=0/1 changed. --- ports/stm32/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index ee00d77173..b24108327e 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -714,6 +714,9 @@ SRC_QSTR_AUTO_DEPS += $(GEN_CDCINF_HEADER) # which source files might need it. $(OBJ): | $(GEN_PINS_HDR) +# Automatically rebuild if specific settings are changed on command line +$(OBJ): $(call depend_var, USE_MBOOT) + # With conditional pins, we may need to regenerate qstrdefs.h when config # options change. $(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h