Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 3d150be

Browse files
committed
unit-test-app: new targets for building different configurations
1 parent 6cc8099 commit 3d150be

File tree

8 files changed

+124
-486
lines changed

8 files changed

+124
-486
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ docs/man/
3535
tools/unit-test-app/sdkconfig
3636
tools/unit-test-app/sdkconfig.old
3737
tools/unit-test-app/build
38+
tools/unit-test-app/builds
39+
tools/unit-test-app/output
3840

3941
# AWS IoT Examples require device-specific certs/keys
4042
examples/protocols/aws_iot/*/main/certs/*.pem.*

.gitlab-ci.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,15 @@ build_esp_idf_tests:
113113
<<: *build_template
114114
artifacts:
115115
paths:
116-
- tools/unit-test-app/build/*.bin
117-
- tools/unit-test-app/build/*.elf
118-
- tools/unit-test-app/build/*.map
119-
- tools/unit-test-app/build/download.config
120-
- tools/unit-test-app/build/bootloader/*.bin
116+
- tools/unit-test-app/output
121117
- components/idf_test/unit_test/TestCaseAll.yml
122118
- components/idf_test/unit_test/CIConfigs/*.yml
123119
expire_in: 6 mos
124120
script:
125121
- cd tools/unit-test-app
126-
- make TESTS_ALL=1
127-
# cut last line in case make V=0/1 is set by default
128-
- make print_flash_cmd | tail -n 1 > build/download.config
122+
- make help # make sure kconfig tools are built in single process
123+
- make ut-clean-all-configs
124+
- make ut-build-all-configs TESTS_ALL=1
129125
- python tools/UnitTestParser.py
130126

131127
.build_examples_template: &build_examples_template

tools/unit-test-app/Makefile

+93
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,96 @@ include $(IDF_PATH)/make/project.mk
99

1010
print_flash_cmd:
1111
echo $(ESPTOOL_WRITE_FLASH_OPTIONS) $(ESPTOOL_ALL_FLASH_ARGS) | sed -e 's:'$(PWD)/build/'::g'
12+
13+
# List of unit-test-app configurations.
14+
# Each file in configs/ directory defines a configuration. The format is the
15+
# same as sdkconfig file. Configuration is applied on top of sdkconfig.defaults
16+
# file from the project directory
17+
CONFIG_NAMES := $(notdir $(wildcard configs/*))
18+
19+
# Per-config targets
20+
CONFIG_BUILD_TARGETS := $(addprefix ut-build-,$(CONFIG_NAMES))
21+
CONFIG_CLEAN_TARGETS := $(addprefix ut-clean-,$(CONFIG_NAMES))
22+
CONFIG_APPLY_TARGETS := $(addprefix ut-apply-config-,$(CONFIG_NAMES))
23+
24+
# Build (intermediate) and output (artifact) directories
25+
BUILDS_DIR := $(PROJECT_PATH)/builds
26+
BINARIES_DIR := $(PROJECT_PATH)/output
27+
28+
# This generates per-config targets (clean, build, apply-config).
29+
define GenerateConfigTargets
30+
# $(1) - configuration name
31+
ut-clean-$(1):
32+
rm -rf $$(BUILDS_DIR)/$(1) $$(BINARIES_DIR)/$(1)
33+
34+
ut-build-$(1): $$(BINARIES_DIR)/$(1)/$$(PROJECT_NAME).bin
35+
36+
ut-apply-config-$(1):
37+
cat sdkconfig.defaults > sdkconfig
38+
echo "" >> sdkconfig
39+
cat configs/$(1) >> sdkconfig
40+
$(call RunConf,conf --olddefconfig)
41+
endef
42+
43+
$(foreach config_name,$(CONFIG_NAMES), $(eval $(call GenerateConfigTargets,$(config_name))))
44+
45+
ut-build-all-configs: $(CONFIG_BUILD_TARGETS)
46+
ut-clean-all-configs: $(CONFIG_CLEAN_TARGETS)
47+
48+
# This target builds the configuration. It does not currently track dependencies,
49+
# but is good enough for CI builds if used together with clean-all-configs.
50+
# For local builds, use 'apply-config-NAME' target and then use normal 'all'
51+
# and 'flash' targets.
52+
$(BINARIES_DIR)/%/bootloader.bin \
53+
$(BINARIES_DIR)/%/$(PROJECT_NAME).elf \
54+
$(BINARIES_DIR)/%/$(PROJECT_NAME).map \
55+
$(BINARIES_DIR)/%/$(PROJECT_NAME).bin: configs/%
56+
# Create build and output directories
57+
mkdir -p $(BINARIES_DIR)/$*/bootloader
58+
mkdir -p $(BUILDS_DIR)/$*
59+
# Prepare configuration: top-level sdkconfig.defaults file plus the current configuration (configs/$*)
60+
$(summary) CONFIG $(BUILDS_DIR)/$*/sdkconfig
61+
rm -f $(BUILDS_DIR)/$*/sdkconfig
62+
cat sdkconfig.defaults > $(BUILDS_DIR)/$*/sdkconfig.defaults
63+
echo "" >> $(BUILDS_DIR)/$*/sdkconfig.defaults # in case there is no trailing newline in sdkconfig.defaults
64+
cat configs/$* >> $(BUILDS_DIR)/$*/sdkconfig.defaults
65+
# Build, tweaking paths to sdkconfig and sdkconfig.defaults
66+
$(summary) BUILD_CONFIG $(BUILDS_DIR)/$*
67+
$(MAKE) defconfig all \
68+
BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
69+
SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
70+
SDKCONFIG_DEFAULTS=$(BUILDS_DIR)/$*/sdkconfig.defaults
71+
$(MAKE) print_flash_cmd \
72+
BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
73+
SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
74+
| sed -e 's:'$(BUILDS_DIR)/$*/'::g' \
75+
| tail -n 1 > $(BINARIES_DIR)/$*/download.config
76+
# Copy files of interest to the output directory
77+
cp $(BUILDS_DIR)/$*/bootloader/bootloader.bin $(BINARIES_DIR)/$*/bootloader/
78+
cp $(BUILDS_DIR)/$*/$(PROJECT_NAME).elf $(BINARIES_DIR)/$*/
79+
cp $(BUILDS_DIR)/$*/$(PROJECT_NAME).bin $(BINARIES_DIR)/$*/
80+
cp $(BUILDS_DIR)/$*/$(PROJECT_NAME).map $(BINARIES_DIR)/$*/
81+
cp $(BUILDS_DIR)/$*/partition_table*.bin $(BINARIES_DIR)/$*/
82+
cp $(BUILDS_DIR)/$*/sdkconfig $(BINARIES_DIR)/$*/
83+
84+
85+
ut-help:
86+
@echo "Additional unit-test-app specific targets:"
87+
@echo ""
88+
@echo "make ut-build-NAME - Build unit-test-app with configuration provided in configs/NAME."
89+
@echo " Build directory will be builds/NAME/, output binaries will be"
90+
@echo " under output/NAME/"
91+
@echo "make ut-clean-NAME - Remove build and output directories for configuration NAME."
92+
@echo ""
93+
@echo "make ut-build-all-configs - Build all configurations defined in configs/ directory."
94+
@echo ""
95+
@echo "make ut-apply-config-NAME - Generates configuration based on configs/NAME in sdkconfig"
96+
@echo " file. After this, normal all/flash targets can be used."
97+
@echo " Useful for development/debugging."
98+
@echo ""
99+
100+
help: ut-help
101+
102+
.PHONY: ut-build-all-configs ut-clean-all-configs \
103+
$(CONFIG_BUILD_TARGETS) $(CONFIG_CLEAN_TARGETS) $(CONFIG_APPLY_TARGETS) \
104+
ut-help

tools/unit-test-app/configs/default

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# default config — nothing to set here

tools/unit-test-app/configs/release

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_OPTIMIZATION_LEVEL_RELEASE=y
2+
CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_MEMMAP_SMP=n
2+
CONFIG_FREERTOS_UNICORE=y

0 commit comments

Comments
 (0)