X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Makefile;h=0aaf585786cbe28bde3ee2ae9ef51c089928e0e7;hb=74d72c724b149557228a688aa222871c60c07396;hp=67b981d51ebb6e988acb173ca8334d08047d3ec9;hpb=27a673f5cf75747fe73641059aae60e9b53a1c78;p=qmk_firmware.git diff --git a/Makefile b/Makefile index 67b981d51..0aaf58578 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ ifndef VERBOSE .SILENT: endif +# Never run this makefile in parallel, as it could screw things up +# It won't affect the submakes, so you still get the speedup from specifying -jx +.NOTPARALLEL: + # Allow the silent with lower caps to work the same way as upper caps ifdef silent SILENT = $(silent) @@ -28,6 +32,7 @@ ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE)) ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) +TEST_DIR := $(ROOT_DIR)/.build/test MAKEFILE_INCLUDED=yes @@ -394,7 +399,10 @@ define BUILD fi; COMMAND_false_$$(COMMAND) := \ printf "$$(MAKE_MSG)\n\n"; \ - $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; + $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \ + if [ $$$$? -gt 0 ]; \ + then error_occured=1; \ + fi; endef # Just parse all the keymaps for a specifc keyboard @@ -410,12 +418,29 @@ define BUILD_TEST MAKE_VARS := TEST=$$(TEST_NAME) MAKE_MSG := $$(MSG_MAKE_TEST) $$(eval $$(call BUILD)) + ifneq ($$(MAKE_TARGET),clean) + TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf + TESTS += $$(TEST_NAME) + TEST_MSG := $$(MSG_TEST) + $$(TEST_NAME)_COMMAND := \ + printf "$$(TEST_MSG)\n"; \ + $$(TEST_EXECUTABLE); \ + if [ $$$$? -gt 0 ]; \ + then error_occured=1; \ + fi; \ + printf "\n"; + endif endef define PARSE_TEST + TESTS := TEST_NAME := $$(firstword $$(subst -, ,$$(RULE))) TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME)-,,$$(RULE))) - MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),)) + ifeq ($$(TEST_NAME),all) + MATCHED_TESTS := $$(TEST_LIST) + else + MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),)) + endif $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET)))) endef @@ -464,12 +489,13 @@ $(SUBPROJECTS): %: %-allkm # But we return the error code at the end, to trigger travis failures +error_occured=0; \ $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) \ - if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi - + if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\ + $(foreach TEST,$(TESTS),$($(TEST)_COMMAND)) \ + if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\ # All should compile everything .PHONY: all -all: all-keyboards +all: all-keyboards test-all # Define some shortcuts, mostly for compability with the old syntax .PHONY: all-keyboards @@ -478,6 +504,11 @@ all-keyboards: allkb-allsp-allkm .PHONY: all-keyboards-defaults all-keyboards-defaults: allkb-allsp-default +.PHONY: test +test: test-all + +.PHONY: test-clean +test-clean: test-all-clean # Generate the version.h file GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")