aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 23 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 0aaf58578..66c0ff30f 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,9 @@ ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
32ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) 32ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
33ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) 33ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
34STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) 34STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
35TEST_DIR := $(ROOT_DIR)/.build/test 35BUILD_DIR := $(ROOT_DIR)/.build
36TEST_DIR := $(BUILD_DIR)/test
37ERROR_FILE := $(BUILD_DIR)/error_occured
36 38
37MAKEFILE_INCLUDED=yes 39MAKEFILE_INCLUDED=yes
38 40
@@ -460,8 +462,21 @@ endef
460 462
461include $(ROOT_DIR)/message.mk 463include $(ROOT_DIR)/message.mk
462 464
463RUN_COMMAND = \ 465# The empty line is important here, as it will force a new shell to be created for each command
464$(COMMAND_$(SILENT_MODE)_$(COMMAND)) 466# Otherwise the command line will become too long with a lot of keyboards and keymaps
467define RUN_COMMAND
468+error_occured=0;\
469$(COMMAND_$(SILENT_MODE)_$(COMMAND))\
470if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi;
471
472
473endef
474define RUN_TEST
475+error_occured=0;\
476$($(TEST)_COMMAND))\
477if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi;
478
479endef
465 480
466# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps 481# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
467SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile))) 482SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
@@ -481,17 +496,17 @@ $(SUBPROJECTS): %: %-allkm
481 *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \ 496 *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
482 esac \ 497 esac \
483 done 498 done
499 rm -f $(ERROR_FILE) > /dev/null 2>&1
484 $(eval $(call PARSE_RULE,$@)) 500 $(eval $(call PARSE_RULE,$@))
485 $(eval $(call SET_SILENT_MODE)) 501 $(eval $(call SET_SILENT_MODE))
486 # Run all the commands in the same shell, notice the + at the first line 502 # Run all the commands in the same shell, notice the + at the first line
487 # it has to be there to allow parallel execution of the submake 503 # it has to be there to allow parallel execution of the submake
488 # This always tries to compile everything, even if error occurs in the middle 504 # This always tries to compile everything, even if error occurs in the middle
489 # But we return the error code at the end, to trigger travis failures 505 # But we return the error code at the end, to trigger travis failures
490 +error_occured=0; \ 506 $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND))
491 $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) \ 507 if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
492 if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\ 508 $(foreach TEST,$(TESTS),$(RUN_TEST))
493 $(foreach TEST,$(TESTS),$($(TEST)_COMMAND)) \ 509 if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
494 if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\
495 510
496# All should compile everything 511# All should compile everything
497.PHONY: all 512.PHONY: all