unit-test-app: don’t include project.mk for ut- targets
If project.mk is included twice in recursive invocation of Make, some variables defined on the first pass will not be redefined on the second pass. Rather than cleaning up these variables before calling Make recursively, don’t include IDF project.mk at all, if one of the ut- targets is requested.
This commit is contained in:
parent
fec079cd44
commit
b0af8ad22f
1 changed files with 25 additions and 11 deletions
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
PROJECT_NAME := unit-test-app
|
PROJECT_NAME := unit-test-app
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
|
||||||
|
|
||||||
ifeq ($(MAKELEVEL),0)
|
ifeq ($(MAKELEVEL),0)
|
||||||
|
# Set default target
|
||||||
|
all:
|
||||||
|
|
||||||
# Define helper targets only when not recursing
|
# Define helper targets only when not recursing
|
||||||
|
|
||||||
# List of unit-test-app configurations.
|
# List of unit-test-app configurations.
|
||||||
|
@ -22,8 +23,9 @@ CONFIG_CLEAN_TARGETS := $(addprefix ut-clean-,$(CONFIG_NAMES))
|
||||||
CONFIG_APPLY_TARGETS := $(addprefix ut-apply-config-,$(CONFIG_NAMES))
|
CONFIG_APPLY_TARGETS := $(addprefix ut-apply-config-,$(CONFIG_NAMES))
|
||||||
|
|
||||||
# Build (intermediate) and output (artifact) directories
|
# Build (intermediate) and output (artifact) directories
|
||||||
BUILDS_DIR := $(PROJECT_PATH)/builds
|
PROJECT_DIR := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
|
||||||
BINARIES_DIR := $(PROJECT_PATH)/output
|
BUILDS_DIR := $(PROJECT_DIR)/builds
|
||||||
|
BINARIES_DIR := $(PROJECT_DIR)/output
|
||||||
|
|
||||||
# This generates per-config targets (clean, build, apply-config).
|
# This generates per-config targets (clean, build, apply-config).
|
||||||
define GenerateConfigTargets
|
define GenerateConfigTargets
|
||||||
|
@ -57,14 +59,14 @@ $(BINARIES_DIR)/%/$(PROJECT_NAME).bin: configs/%
|
||||||
mkdir -p $(BINARIES_DIR)/$*/bootloader
|
mkdir -p $(BINARIES_DIR)/$*/bootloader
|
||||||
mkdir -p $(BUILDS_DIR)/$*
|
mkdir -p $(BUILDS_DIR)/$*
|
||||||
# Prepare configuration: top-level sdkconfig.defaults file plus the current configuration (configs/$*)
|
# Prepare configuration: top-level sdkconfig.defaults file plus the current configuration (configs/$*)
|
||||||
$(summary) CONFIG $(BUILDS_DIR)/$*/sdkconfig
|
echo CONFIG $(BUILDS_DIR)/$*/sdkconfig
|
||||||
rm -f $(BUILDS_DIR)/$*/sdkconfig
|
rm -f $(BUILDS_DIR)/$*/sdkconfig
|
||||||
cat sdkconfig.defaults > $(BUILDS_DIR)/$*/sdkconfig.defaults
|
cat sdkconfig.defaults > $(BUILDS_DIR)/$*/sdkconfig.defaults
|
||||||
echo "" >> $(BUILDS_DIR)/$*/sdkconfig.defaults # in case there is no trailing newline in sdkconfig.defaults
|
echo "" >> $(BUILDS_DIR)/$*/sdkconfig.defaults # in case there is no trailing newline in sdkconfig.defaults
|
||||||
cat configs/$* >> $(BUILDS_DIR)/$*/sdkconfig.defaults
|
cat configs/$* >> $(BUILDS_DIR)/$*/sdkconfig.defaults
|
||||||
|
|
||||||
# Build, tweaking paths to sdkconfig and sdkconfig.defaults
|
# Build, tweaking paths to sdkconfig and sdkconfig.defaults
|
||||||
$(summary) BUILD_CONFIG $(BUILDS_DIR)/$*
|
echo BUILD_CONFIG $(BUILDS_DIR)/$*
|
||||||
# 'TEST_COMPONENTS=names' option can be added to configs/$* to limit the set
|
# 'TEST_COMPONENTS=names' option can be added to configs/$* to limit the set
|
||||||
# of tests to build for given configuration.
|
# of tests to build for given configuration.
|
||||||
# Build all tests if this option is not present.
|
# Build all tests if this option is not present.
|
||||||
|
@ -78,7 +80,7 @@ $(BINARIES_DIR)/%/$(PROJECT_NAME).bin: configs/%
|
||||||
TEST_COMPONENTS="$${test_components}" \
|
TEST_COMPONENTS="$${test_components}" \
|
||||||
TESTS_ALL=$${tests_all} \
|
TESTS_ALL=$${tests_all} \
|
||||||
EXCLUDE_COMPONENTS="$${exclude_components}"
|
EXCLUDE_COMPONENTS="$${exclude_components}"
|
||||||
$(MAKE) print_flash_cmd \
|
$(MAKE) --silent print_flash_cmd \
|
||||||
BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
|
BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
|
||||||
SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
|
SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
|
||||||
| sed -e 's:'$(BUILDS_DIR)/$*/'::g' \
|
| sed -e 's:'$(BUILDS_DIR)/$*/'::g' \
|
||||||
|
@ -113,17 +115,29 @@ ut-help:
|
||||||
|
|
||||||
help: ut-help
|
help: ut-help
|
||||||
|
|
||||||
.PHONY: ut-build-all-configs ut-clean-all-configs \
|
LOCAL_TARGETS := ut-build-all-configs ut-clean-all-configs \
|
||||||
$(CONFIG_BUILD_TARGETS) $(CONFIG_CLEAN_TARGETS) $(CONFIG_APPLY_TARGETS) \
|
$(CONFIG_BUILD_TARGETS) $(CONFIG_CLEAN_TARGETS) \
|
||||||
ut-help
|
ut-help
|
||||||
|
|
||||||
|
.PHONY: $(LOCAL_TARGETS)
|
||||||
|
|
||||||
NON_INTERACTIVE_TARGET += ut-apply-config-% ut-clean-% ut-build-% \
|
NON_INTERACTIVE_TARGET += ut-apply-config-% ut-clean-% ut-build-% \
|
||||||
ut-build-all-configs ut-clean-all-configs
|
ut-build-all-configs ut-clean-all-configs
|
||||||
|
|
||||||
else # MAKELEVEL == 0
|
endif # MAKELEVEL == 0
|
||||||
|
|
||||||
|
|
||||||
|
# When targets defined in this makefile are built, don't need to include the main project makefile.
|
||||||
|
# This prevents some variables which depend on build directory from being set erroneously.
|
||||||
|
ifeq ($(filter $(LOCAL_TARGETS),$(MAKECMDGOALS)),)
|
||||||
|
|
||||||
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
# If recursing, print the actual list of tests being built
|
# If recursing, print the actual list of tests being built
|
||||||
|
ifneq ($(MAKELEVEL),0)
|
||||||
|
|
||||||
$(info TESTS $(foreach comp,$(TEST_COMPONENT_NAMES),$(patsubst %_test,%,$(comp))))
|
$(info TESTS $(foreach comp,$(TEST_COMPONENT_NAMES),$(patsubst %_test,%,$(comp))))
|
||||||
|
|
||||||
endif # MAKELEVEL == 0
|
endif # MAKELEVEL != 0
|
||||||
|
|
Loading…
Reference in a new issue