diff options
| author | IBNobody <protospherex@gmail.com> | 2016-11-01 11:52:58 -0500 |
|---|---|---|
| committer | IBNobody <protospherex@gmail.com> | 2016-11-01 11:52:58 -0500 |
| commit | 78976d8f7a7702eb4e94819af40fb3b32ac6825f (patch) | |
| tree | 73122b3f4b52979145896ba6a968fe93b7c6fffd /Makefile | |
| parent | 9e6c57af2a47c7e58c7d7c20d3ccb6cb942eb451 (diff) | |
| download | qmk_firmware-78976d8f7a7702eb4e94819af40fb3b32ac6825f.tar.gz qmk_firmware-78976d8f7a7702eb4e94819af40fb3b32ac6825f.zip | |
Adding SKIP_GIT to speed up compiles.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 57 |
1 files changed, 39 insertions, 18 deletions
| @@ -38,7 +38,7 @@ ERROR_FILE := $(BUILD_DIR)/error_occured | |||
| 38 | 38 | ||
| 39 | MAKEFILE_INCLUDED=yes | 39 | MAKEFILE_INCLUDED=yes |
| 40 | 40 | ||
| 41 | # Helper function to process the newt element of a space separated path | 41 | # Helper function to process the newt element of a space separated path |
| 42 | # It works a bit like the traditional functional head tail | 42 | # It works a bit like the traditional functional head tail |
| 43 | # so the CURRENT_PATH_ELEMENT will beome the new head | 43 | # so the CURRENT_PATH_ELEMENT will beome the new head |
| 44 | # and the PATH_ELEMENTS are the rest that are still unprocessed | 44 | # and the PATH_ELEMENTS are the rest that are still unprocessed |
| @@ -47,16 +47,16 @@ define NEXT_PATH_ELEMENT | |||
| 47 | $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS))) | 47 | $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS))) |
| 48 | endef | 48 | endef |
| 49 | 49 | ||
| 50 | # We change the / to spaces so that we more easily can work with the elements | 50 | # We change the / to spaces so that we more easily can work with the elements |
| 51 | # separately | 51 | # separately |
| 52 | PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR)) | 52 | PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR)) |
| 53 | # Initialize the path elements list for further processing | 53 | # Initialize the path elements list for further processing |
| 54 | $(eval $(call NEXT_PATH_ELEMENT)) | 54 | $(eval $(call NEXT_PATH_ELEMENT)) |
| 55 | 55 | ||
| 56 | # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct | 56 | # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct |
| 57 | # variables depending on which directory you stand in. | 57 | # variables depending on which directory you stand in. |
| 58 | # It's really a very simple if else chain, if you squint enough, | 58 | # It's really a very simple if else chain, if you squint enough, |
| 59 | # but the makefile syntax makes it very verbose. | 59 | # but the makefile syntax makes it very verbose. |
| 60 | # If we are in a subfolder of keyboards | 60 | # If we are in a subfolder of keyboards |
| 61 | ifeq ($(CURRENT_PATH_ELEMENT),keyboards) | 61 | ifeq ($(CURRENT_PATH_ELEMENT),keyboards) |
| 62 | $(eval $(call NEXT_PATH_ELEMENT)) | 62 | $(eval $(call NEXT_PATH_ELEMENT)) |
| @@ -111,7 +111,7 @@ endif | |||
| 111 | .DEFAULT_GOAL := all | 111 | .DEFAULT_GOAL := all |
| 112 | ifneq ($(KEYMAP),) | 112 | ifneq ($(KEYMAP),) |
| 113 | ifeq ($(SUBPROJECT),) | 113 | ifeq ($(SUBPROJECT),) |
| 114 | # Inside a keymap folder, just build the keymap, with the | 114 | # Inside a keymap folder, just build the keymap, with the |
| 115 | # default subproject | 115 | # default subproject |
| 116 | .DEFAULT_GOAL := $(KEYBOARD)-$(KEYMAP) | 116 | .DEFAULT_GOAL := $(KEYBOARD)-$(KEYMAP) |
| 117 | else | 117 | else |
| @@ -163,7 +163,7 @@ define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3 | |||
| 163 | ifneq ($1,) | 163 | ifneq ($1,) |
| 164 | ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true) | 164 | ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true) |
| 165 | MATCHED_ITEM := $$(firstword $1) | 165 | MATCHED_ITEM := $$(firstword $1) |
| 166 | else | 166 | else |
| 167 | $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1))) | 167 | $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1))) |
| 168 | endif | 168 | endif |
| 169 | endif | 169 | endif |
| @@ -171,10 +171,10 @@ endef | |||
| 171 | 171 | ||
| 172 | # A recursive helper function for finding the longest match | 172 | # A recursive helper function for finding the longest match |
| 173 | # $1 The list to be checed | 173 | # $1 The list to be checed |
| 174 | # It works by always removing the currently matched item from the list | 174 | # It works by always removing the currently matched item from the list |
| 175 | # and call itself recursively, until a match is found | 175 | # and call itself recursively, until a match is found |
| 176 | define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2 | 176 | define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2 |
| 177 | # Stop the recursion when the list is empty | 177 | # Stop the recursion when the list is empty |
| 178 | ifneq ($1,) | 178 | ifneq ($1,) |
| 179 | RULE_BEFORE := $$(RULE) | 179 | RULE_BEFORE := $$(RULE) |
| 180 | $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1)) | 180 | $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1)) |
| @@ -270,7 +270,7 @@ define PARSE_KEYBOARD | |||
| 270 | $$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT))) | 270 | $$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT))) |
| 271 | # If there's no matching subproject, we assume it's the default | 271 | # If there's no matching subproject, we assume it's the default |
| 272 | # This will allow you to leave the subproject part of the target out | 272 | # This will allow you to leave the subproject part of the target out |
| 273 | else | 273 | else |
| 274 | $$(eval $$(call PARSE_SUBPROJECT,)) | 274 | $$(eval $$(call PARSE_SUBPROJECT,)) |
| 275 | endif | 275 | endif |
| 276 | endef | 276 | endef |
| @@ -285,7 +285,7 @@ endef | |||
| 285 | # When entering this, the keyboard and subproject are known, so now we need | 285 | # When entering this, the keyboard and subproject are known, so now we need |
| 286 | # to determine which keymaps are going to get compiled | 286 | # to determine which keymaps are going to get compiled |
| 287 | define PARSE_SUBPROJECT | 287 | define PARSE_SUBPROJECT |
| 288 | # If we want to compile the default subproject, then we need to | 288 | # If we want to compile the default subproject, then we need to |
| 289 | # include the correct makefile to determine the actual name of it | 289 | # include the correct makefile to determine the actual name of it |
| 290 | CURRENT_SP := $1 | 290 | CURRENT_SP := $1 |
| 291 | ifeq ($$(CURRENT_SP),) | 291 | ifeq ($$(CURRENT_SP),) |
| @@ -304,7 +304,7 @@ define PARSE_SUBPROJECT | |||
| 304 | endif | 304 | endif |
| 305 | endif | 305 | endif |
| 306 | # The special allsp is handled later | 306 | # The special allsp is handled later |
| 307 | ifneq ($$(CURRENT_SP),allsp) | 307 | ifneq ($$(CURRENT_SP),allsp) |
| 308 | # get a list of all keymaps | 308 | # get a list of all keymaps |
| 309 | KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.))) | 309 | KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.))) |
| 310 | ifneq ($$(CURRENT_SP),) | 310 | ifneq ($$(CURRENT_SP),) |
| @@ -343,7 +343,7 @@ define PARSE_SUBPROJECT | |||
| 343 | endif | 343 | endif |
| 344 | endef | 344 | endef |
| 345 | 345 | ||
| 346 | # If we want to parse all subprojects, but the keyboard doesn't have any, | 346 | # If we want to parse all subprojects, but the keyboard doesn't have any, |
| 347 | # then use defaultsp instead | 347 | # then use defaultsp instead |
| 348 | define PARSE_ALL_SUBPROJECTS | 348 | define PARSE_ALL_SUBPROJECTS |
| 349 | ifeq ($$(SUBPROJECTS),) | 349 | ifeq ($$(SUBPROJECTS),) |
| @@ -448,7 +448,7 @@ endef | |||
| 448 | 448 | ||
| 449 | 449 | ||
| 450 | # Set the silent mode depending on if we are trying to compile multiple keyboards or not | 450 | # Set the silent mode depending on if we are trying to compile multiple keyboards or not |
| 451 | # By default it's on in that case, but it can be overriden by specifying silent=false | 451 | # By default it's on in that case, but it can be overriden by specifying silent=false |
| 452 | # from the command line | 452 | # from the command line |
| 453 | define SET_SILENT_MODE | 453 | define SET_SILENT_MODE |
| 454 | ifdef SUB_IS_SILENT | 454 | ifdef SUB_IS_SILENT |
| @@ -481,11 +481,12 @@ endef | |||
| 481 | # 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 |
| 482 | SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile))) | 482 | SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile))) |
| 483 | .PHONY: $(SUBPROJECTS) | 483 | .PHONY: $(SUBPROJECTS) |
| 484 | $(SUBPROJECTS): %: %-allkm | 484 | $(SUBPROJECTS): %: %-allkm |
| 485 | 485 | ||
| 486 | # Let's match everything, we handle all the rule parsing ourselves | 486 | # Let's match everything, we handle all the rule parsing ourselves |
| 487 | .PHONY: % | 487 | .PHONY: % |
| 488 | %: | 488 | ifndef SKIP_GIT |
| 489 | %: | ||
| 489 | # Check if we have the CMP tool installed | 490 | # Check if we have the CMP tool installed |
| 490 | cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi; | 491 | cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi; |
| 491 | # Check if the submodules are dirty, and display a warning if they are | 492 | # Check if the submodules are dirty, and display a warning if they are |
| @@ -505,8 +506,24 @@ $(SUBPROJECTS): %: %-allkm | |||
| 505 | # But we return the error code at the end, to trigger travis failures | 506 | # But we return the error code at the end, to trigger travis failures |
| 506 | $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) | 507 | $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) |
| 507 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; | 508 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; |
| 508 | $(foreach TEST,$(TESTS),$(RUN_TEST)) | 509 | $(foreach TEST,$(TESTS),$(RUN_TEST)) |
| 510 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; | ||
| 511 | else | ||
| 512 | %: | ||
| 513 | # Check if we have the CMP tool installed | ||
| 514 | cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi; | ||
| 515 | rm -f $(ERROR_FILE) > /dev/null 2>&1 | ||
| 516 | $(eval $(call PARSE_RULE,$@)) | ||
| 517 | $(eval $(call SET_SILENT_MODE)) | ||
| 518 | # Run all the commands in the same shell, notice the + at the first line | ||
| 519 | # it has to be there to allow parallel execution of the submake | ||
| 520 | # This always tries to compile everything, even if error occurs in the middle | ||
| 521 | # But we return the error code at the end, to trigger travis failures | ||
| 522 | $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) | ||
| 523 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; | ||
| 524 | $(foreach TEST,$(TESTS),$(RUN_TEST)) | ||
| 509 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; | 525 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; |
| 526 | endif | ||
| 510 | 527 | ||
| 511 | # All should compile everything | 528 | # All should compile everything |
| 512 | .PHONY: all | 529 | .PHONY: all |
| @@ -526,7 +543,11 @@ test: test-all | |||
| 526 | test-clean: test-all-clean | 543 | test-clean: test-all-clean |
| 527 | 544 | ||
| 528 | # Generate the version.h file | 545 | # Generate the version.h file |
| 529 | GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S") | 546 | ifndef SKIP_GIT |
| 547 | GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S") | ||
| 548 | else | ||
| 549 | GIT_VERSION := NA | ||
| 550 | endif | ||
| 530 | BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S") | 551 | BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S") |
| 531 | $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h) | 552 | $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h) |
| 532 | $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h) | 553 | $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h) |
