Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion test/mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,17 @@ endif
# Include retained variables #
##############################

RETAINED_VARS := CROSS_PREFIX CYCLES OPT AUTO

# Capture values of environment variables before setting defaults,
# this ensures we can detect when they change in order to trigger a rebuild.
define CAPTURE_VAR
$(1)_FROM_ENV := $$($(1))
endef
$(foreach var,$(RETAINED_VARS),$(eval $(call CAPTURE_VAR,$(var))))

CYCLES ?=
OPT ?= 1
RETAINED_VARS := CROSS_PREFIX CYCLES OPT AUTO

BUILD_DIR ?= test/build

Expand All @@ -91,6 +99,14 @@ CONFIG := $(BUILD_DIR)/config.mk

-include $(CONFIG)

# After including the cached config, restore environment/command-line values if they were set
define RESTORE_VAR
ifneq ($$($(1)_FROM_ENV),)
$(1) := $$($(1)_FROM_ENV)
endif
endef
$(foreach var,$(RETAINED_VARS),$(eval $(call RESTORE_VAR,$(var))))

$(CONFIG):
@echo " GEN $@"
$(Q)[ -d $(@D) ] || mkdir -p $(@D)
Expand Down
Loading