summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-01-24 23:54:56 +0000
committerGitHub <noreply@github.com>2022-01-24 23:54:56 +0000
commitbf9569db93d9f9ce5e3a0ce7190f09e950b9f85b (patch)
tree4928dde824eb0995ee50306b7a7be91cb033c166 /Makefile
parentc71c0fba9000cb586588da4c6bbf877d21d061b6 (diff)
Various Makefile optimisations (#16015)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile78
1 files changed, 27 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 88f430619e..b435837d30 100644
--- a/Makefile
+++ b/Makefile
@@ -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
20override SILENT := false 20override SILENT := false
21 21
22ifdef SKIP_VERSION
23 SKIP_GIT := yes
24endif
25
22ifndef SUB_IS_SILENT 26ifndef SUB_IS_SILENT
23ifndef SKIP_GIT 27ifndef 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))
50ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) 54ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
51ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE)) 55ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
52STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR)) 56STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
53BUILD_DIR := $(ROOT_DIR)/.build
54TEST_DIR := $(BUILD_DIR)/test
55ERROR_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
61define NEXT_PATH_ELEMENT
62 $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS)))
63 $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS)))
64endef
65
66# We change the / to spaces so that we more easily can work with the elements
67# separately
68PATH_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
75list-keyboards:
76 util/list_keyboards.sh | sort -u | tr '\n' ' '
77
78.PHONY: generate-keyboards-file
79generate-keyboards-file:
80 util/list_keyboards.sh | sort -u
81 57
82.PHONY: clean 58include paths.mk
83clean:
84 echo -n 'Deleting .build/ ... '
85 rm -rf $(BUILD_DIR)
86 echo 'done.'
87
88.PHONY: distclean
89distclean: clean
90 echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
91 rm -f *.bin *.hex *.uf2
92 echo 'done.'
93 59
60TEST_OUTPUT_DIR := $(BUILD_DIR)/test
61ERROR_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
427endef 396endef
428 397
429include paths.mk
430include $(BUILDDEFS_PATH)/message.mk 398include $(BUILDDEFS_PATH)/message.mk
431 399
432ifeq ($(strip $(BREAK_ON_ERRORS)), yes) 400ifeq ($(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
500ifdef SKIP_GIT 468list-keyboards:
501VERSION_H_FLAGS := --skip-git 469 util/list_keyboards.sh | sort -u | tr '\n' ' '
502endif
503ifdef SKIP_VERSION
504VERSION_H_FLAGS := --skip-all
505SKIP_GIT := yes
506endif
507$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o quantum/version.h)
508 470
509include $(ROOT_DIR)/testlist.mk 471.PHONY: generate-keyboards-file
472generate-keyboards-file:
473 util/list_keyboards.sh | sort -u
474
475.PHONY: clean
476clean:
477 echo -n 'Deleting .build/ ... '
478 rm -rf $(BUILD_DIR)
479 echo 'done.'
480
481.PHONY: distclean
482distclean: clean
483 echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
484 rm -f *.bin *.hex *.uf2
485 echo 'done.'