diff options
| author | Joel Challis <git@zvecr.com> | 2022-01-24 23:54:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-24 23:54:56 +0000 |
| commit | bf9569db93d9f9ce5e3a0ce7190f09e950b9f85b (patch) | |
| tree | 4928dde824eb0995ee50306b7a7be91cb033c166 /Makefile | |
| parent | c71c0fba9000cb586588da4c6bbf877d21d061b6 (diff) | |
Various Makefile optimisations (#16015)
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 78 |
1 files changed, 27 insertions, 51 deletions
| @@ -19,6 +19,10 @@ endif | |||
| 19 | # Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly | 19 | # Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly |
| 20 | override SILENT := false | 20 | override SILENT := false |
| 21 | 21 | ||
| 22 | ifdef SKIP_VERSION | ||
| 23 | SKIP_GIT := yes | ||
| 24 | endif | ||
| 25 | |||
| 22 | ifndef SUB_IS_SILENT | 26 | ifndef SUB_IS_SILENT |
| 23 | ifndef SKIP_GIT | 27 | ifndef SKIP_GIT |
| 24 | QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null) | 28 | QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null) |
| @@ -50,47 +54,11 @@ ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE)) | |||
| 50 | ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) | 54 | ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) |
| 51 | ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) | 55 | ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) |
| 52 | STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) | 56 | STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) |
| 53 | BUILD_DIR := $(ROOT_DIR)/.build | ||
| 54 | TEST_DIR := $(BUILD_DIR)/test | ||
| 55 | ERROR_FILE := $(BUILD_DIR)/error_occurred | ||
| 56 | |||
| 57 | # Helper function to process the newt element of a space separated path | ||
| 58 | # It works a bit like the traditional functional head tail | ||
| 59 | # so the CURRENT_PATH_ELEMENT will become the new head | ||
| 60 | # and the PATH_ELEMENTS are the rest that are still unprocessed | ||
| 61 | define NEXT_PATH_ELEMENT | ||
| 62 | $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS))) | ||
| 63 | $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS))) | ||
| 64 | endef | ||
| 65 | |||
| 66 | # We change the / to spaces so that we more easily can work with the elements | ||
| 67 | # separately | ||
| 68 | PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR)) | ||
| 69 | # Initialize the path elements list for further processing | ||
| 70 | $(eval $(call NEXT_PATH_ELEMENT)) | ||
| 71 | |||
| 72 | |||
| 73 | # Phony targets to enable a few simple make commands outside the main processing below. | ||
| 74 | .PHONY: list-keyboards | ||
| 75 | list-keyboards: | ||
| 76 | util/list_keyboards.sh | sort -u | tr '\n' ' ' | ||
| 77 | |||
| 78 | .PHONY: generate-keyboards-file | ||
| 79 | generate-keyboards-file: | ||
| 80 | util/list_keyboards.sh | sort -u | ||
| 81 | 57 | ||
| 82 | .PHONY: clean | 58 | include paths.mk |
| 83 | clean: | ||
| 84 | echo -n 'Deleting .build/ ... ' | ||
| 85 | rm -rf $(BUILD_DIR) | ||
| 86 | echo 'done.' | ||
| 87 | |||
| 88 | .PHONY: distclean | ||
| 89 | distclean: clean | ||
| 90 | echo -n 'Deleting *.bin, *.hex, and *.uf2 ... ' | ||
| 91 | rm -f *.bin *.hex *.uf2 | ||
| 92 | echo 'done.' | ||
| 93 | 59 | ||
| 60 | TEST_OUTPUT_DIR := $(BUILD_DIR)/test | ||
| 61 | ERROR_FILE := $(BUILD_DIR)/error_occurred | ||
| 94 | 62 | ||
| 95 | .DEFAULT_GOAL := all:all | 63 | .DEFAULT_GOAL := all:all |
| 96 | 64 | ||
| @@ -387,7 +355,7 @@ define BUILD_TEST | |||
| 387 | MAKE_MSG := $$(MSG_MAKE_TEST) | 355 | MAKE_MSG := $$(MSG_MAKE_TEST) |
| 388 | $$(eval $$(call BUILD)) | 356 | $$(eval $$(call BUILD)) |
| 389 | ifneq ($$(MAKE_TARGET),clean) | 357 | ifneq ($$(MAKE_TARGET),clean) |
| 390 | TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf | 358 | TEST_EXECUTABLE := $$(TEST_OUTPUT_DIR)/$$(TEST_NAME).elf |
| 391 | TESTS += $$(TEST_NAME) | 359 | TESTS += $$(TEST_NAME) |
| 392 | TEST_MSG := $$(MSG_TEST) | 360 | TEST_MSG := $$(MSG_TEST) |
| 393 | $$(TEST_NAME)_COMMAND := \ | 361 | $$(TEST_NAME)_COMMAND := \ |
| @@ -404,6 +372,7 @@ define PARSE_TEST | |||
| 404 | TESTS := | 372 | TESTS := |
| 405 | TEST_NAME := $$(firstword $$(subst :, ,$$(RULE))) | 373 | TEST_NAME := $$(firstword $$(subst :, ,$$(RULE))) |
| 406 | TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE))) | 374 | TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE))) |
| 375 | include $(ROOT_DIR)/testlist.mk | ||
| 407 | ifeq ($$(TEST_NAME),all) | 376 | ifeq ($$(TEST_NAME),all) |
| 408 | MATCHED_TESTS := $$(TEST_LIST) | 377 | MATCHED_TESTS := $$(TEST_LIST) |
| 409 | else | 378 | else |
| @@ -426,7 +395,6 @@ define SET_SILENT_MODE | |||
| 426 | endif | 395 | endif |
| 427 | endef | 396 | endef |
| 428 | 397 | ||
| 429 | include paths.mk | ||
| 430 | include $(BUILDDEFS_PATH)/message.mk | 398 | include $(BUILDDEFS_PATH)/message.mk |
| 431 | 399 | ||
| 432 | ifeq ($(strip $(BREAK_ON_ERRORS)), yes) | 400 | ifeq ($(strip $(BREAK_ON_ERRORS)), yes) |
| @@ -496,14 +464,22 @@ git-submodule: | |||
| 496 | git submodule sync --recursive | 464 | git submodule sync --recursive |
| 497 | git submodule update --init --recursive --progress | 465 | git submodule update --init --recursive --progress |
| 498 | 466 | ||
| 499 | # Generate the version.h file | 467 | .PHONY: list-keyboards |
| 500 | ifdef SKIP_GIT | 468 | list-keyboards: |
| 501 | VERSION_H_FLAGS := --skip-git | 469 | util/list_keyboards.sh | sort -u | tr '\n' ' ' |
| 502 | endif | ||
| 503 | ifdef SKIP_VERSION | ||
| 504 | VERSION_H_FLAGS := --skip-all | ||
| 505 | SKIP_GIT := yes | ||
| 506 | endif | ||
| 507 | $(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o quantum/version.h) | ||
| 508 | 470 | ||
| 509 | include $(ROOT_DIR)/testlist.mk | 471 | .PHONY: generate-keyboards-file |
| 472 | generate-keyboards-file: | ||
| 473 | util/list_keyboards.sh | sort -u | ||
| 474 | |||
| 475 | .PHONY: clean | ||
| 476 | clean: | ||
| 477 | echo -n 'Deleting .build/ ... ' | ||
| 478 | rm -rf $(BUILD_DIR) | ||
| 479 | echo 'done.' | ||
| 480 | |||
| 481 | .PHONY: distclean | ||
| 482 | distclean: clean | ||
| 483 | echo -n 'Deleting *.bin, *.hex, and *.uf2 ... ' | ||
| 484 | rm -f *.bin *.hex *.uf2 | ||
| 485 | echo 'done.' | ||
