diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 31 |
1 files changed, 23 insertions, 8 deletions
| @@ -32,7 +32,9 @@ ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE)) | |||
| 32 | ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) | 32 | ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) |
| 33 | ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) | 33 | ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) |
| 34 | STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) | 34 | STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) |
| 35 | TEST_DIR := $(ROOT_DIR)/.build/test | 35 | BUILD_DIR := $(ROOT_DIR)/.build |
| 36 | TEST_DIR := $(BUILD_DIR)/test | ||
| 37 | ERROR_FILE := $(BUILD_DIR)/error_occured | ||
| 36 | 38 | ||
| 37 | MAKEFILE_INCLUDED=yes | 39 | MAKEFILE_INCLUDED=yes |
| 38 | 40 | ||
| @@ -460,8 +462,21 @@ endef | |||
| 460 | 462 | ||
| 461 | include $(ROOT_DIR)/message.mk | 463 | include $(ROOT_DIR)/message.mk |
| 462 | 464 | ||
| 463 | RUN_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 |
| 467 | define RUN_COMMAND | ||
| 468 | +error_occured=0;\ | ||
| 469 | $(COMMAND_$(SILENT_MODE)_$(COMMAND))\ | ||
| 470 | if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi; | ||
| 471 | |||
| 472 | |||
| 473 | endef | ||
| 474 | define RUN_TEST | ||
| 475 | +error_occured=0;\ | ||
| 476 | $($(TEST)_COMMAND))\ | ||
| 477 | if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi; | ||
| 478 | |||
| 479 | endef | ||
| 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 |
| 467 | SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile))) | 482 | SUBPROJECTS := $(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 |
