summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.rules39
1 files changed, 39 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 52b215f337..d2a151205b 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -100,6 +100,7 @@ buildall:
@mkdir $(FAILED_BOARDS_DIR)
@for b in $(boards); do echo 'starting' > $(FAILED_BOARDS_DIR)/$$b; done
$(MAKE) try_buildall
+ $(MAKE) build_cts
$(MAKE) runtests
@touch .tests-passed
@echo "$@ completed successfully!"
@@ -175,6 +176,44 @@ $(run-test-targets): run-%: host-%
hosttests: $(host-test-targets)
runtests: $(run-test-targets)
+# Automatically enumerate all suites.
+cts_excludes := common
+cts_suites := $(filter-out $(cts_excludes), \
+ $(shell find cts -maxdepth 1 -mindepth 1 -type d -printf "%f "))
+
+# Add boards below as CTS is expanded.
+cts_boards := stm32l476g-eval nucleo-f072rb
+
+.PHONY: build_cts
+
+# Create CTS rule automatically for given suite and board
+# $1: suite name
+# $2: board name
+# $3: suite name used in the previous loop
+define make-cts =
+ifneq ($$(filter $(1),$$(cts_suites)),)
+ifneq ($$(filter $(3),$$(cts_suites)),)
+# Serialize builds
+cts-$(1)-$(2): cts-$(3)-$(2)
+endif
+build_cts: cts-$(1)-$(2)
+cts-$(1)-$(2):
+ $$(MAKE) CTS_MODULE=$(1) BOARD=$(2)
+endif
+# Do not remove this blank line
+
+endef
+
+# Create rules for all cts-suite-board combinations. Additionally, we serialize
+# targets per board: cts-x-board -> cts-y-board -> ...
+# If we don't serialize targets, parallel make fails because all suites
+# try to produce ec.bin in the same directory (e.g. build/stm32l476g-eval).
+$(foreach b, $(cts_boards), \
+ $(foreach s, $(cts_suites) none, \
+ $(eval $(call make-cts,$(s),$(b),$(prev)) prev:=$(s)) \
+ ) \
+)
+
cov-test-targets=$(foreach t,$(test-list-host),build/host/$(t).info)
bldversion=$(shell (./util/getversion.sh ; echo VERSION) | $(CPP) -P)