From f7e7671f691cfd42f322198f04690727f6493d73 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 10 Feb 2022 17:45:51 +0000 Subject: [PATCH] Migrate more makefile utilities to builddefs sub-directory (#16002) --- Makefile | 6 +++--- build_full_test.mk => builddefs/build_full_test.mk | 0 build_json.mk => builddefs/build_json.mk | 0 build_keyboard.mk => builddefs/build_keyboard.mk | 8 ++++---- build_layout.mk => builddefs/build_layout.mk | 0 build_test.mk => builddefs/build_test.mk | 6 +++--- common_features.mk => builddefs/common_features.mk | 0 tmk_core/rules.mk => builddefs/common_rules.mk | 0 testlist.mk => builddefs/testlist.mk | 0 lib/python/qmk/cli/multibuild.py | 2 +- lib/python/qmk/commands.py | 2 +- paths.mk | 4 +++- 12 files changed, 15 insertions(+), 13 deletions(-) rename build_full_test.mk => builddefs/build_full_test.mk (100%) rename build_json.mk => builddefs/build_json.mk (100%) rename build_keyboard.mk => builddefs/build_keyboard.mk (98%) rename build_layout.mk => builddefs/build_layout.mk (100%) rename build_test.mk => builddefs/build_test.mk (93%) rename common_features.mk => builddefs/common_features.mk (100%) rename tmk_core/rules.mk => builddefs/common_rules.mk (100%) rename testlist.mk => builddefs/testlist.mk (100%) diff --git a/Makefile b/Makefile index 22c79880a32..4c2e6a04dc0 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ define PARSE_KEYMAP # Specify the variables that we are passing forward to submake MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY) QMK_BIN=$$(QMK_BIN) # And the first part of the make command - MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET) + MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_keyboard.mk $$(MAKE_TARGET) # The message to display MAKE_MSG := $$(MSG_MAKE_KB) # We run the command differently, depending on if we want more output or not @@ -317,7 +317,7 @@ define BUILD_TEST TEST_NAME := $$(notdir $$(TEST_PATH)) MAKE_TARGET := $2 COMMAND := $1 - MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET) + MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_test.mk $$(MAKE_TARGET) MAKE_VARS := TEST=$$(TEST_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)" MAKE_MSG := $$(MSG_MAKE_TEST) $$(eval $$(call BUILD)) @@ -339,7 +339,7 @@ define PARSE_TEST TESTS := TEST_NAME := $$(firstword $$(subst :, ,$$(RULE))) TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE))) - include $(ROOT_DIR)/testlist.mk + include $(BUILDDEFS_PATH)/testlist.mk ifeq ($$(TEST_NAME),all) MATCHED_TESTS := $$(TEST_LIST) else diff --git a/build_full_test.mk b/builddefs/build_full_test.mk similarity index 100% rename from build_full_test.mk rename to builddefs/build_full_test.mk diff --git a/build_json.mk b/builddefs/build_json.mk similarity index 100% rename from build_json.mk rename to builddefs/build_json.mk diff --git a/build_keyboard.mk b/builddefs/build_keyboard.mk similarity index 98% rename from build_keyboard.mk rename to builddefs/build_keyboard.mk index f727760465e..d5efcb4193a 100644 --- a/build_keyboard.mk +++ b/builddefs/build_keyboard.mk @@ -111,7 +111,7 @@ INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard include $(INFO_RULES_MK) # Check for keymap.json first, so we can regenerate keymap.c -include build_json.mk +include $(BUILDDEFS_PATH)/build_json.mk # Pull in keymap level rules.mk ifeq ("$(wildcard $(KEYMAP_PATH))", "") @@ -138,7 +138,7 @@ ifeq ("$(wildcard $(KEYMAP_PATH))", "") KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1) else ifneq ($(LAYOUTS),) # If we haven't found a keymap yet fall back to community layouts - include build_layout.mk + include $(BUILDDEFS_PATH)/build_layout.mk else $(call CATASTROPHIC_ERROR,Invalid keymap,Could not find keymap) # this state should never be reached @@ -398,7 +398,7 @@ VPATH += $(COMMON_VPATH) VPATH += $(KEYBOARD_OUTPUT)/src VPATH += $(KEYMAP_OUTPUT)/src -include common_features.mk +include $(BUILDDEFS_PATH)/common_features.mk include $(BUILDDEFS_PATH)/generic_features.mk include $(TMK_PATH)/protocol.mk include $(PLATFORM_PATH)/common.mk @@ -460,7 +460,7 @@ check-md5: build objs-size: build include $(BUILDDEFS_PATH)/show_options.mk -include $(TMK_PATH)/rules.mk +include $(BUILDDEFS_PATH)/common_rules.mk # Ensure we have generated files available for each of the objects define GEN_FILES diff --git a/build_layout.mk b/builddefs/build_layout.mk similarity index 100% rename from build_layout.mk rename to builddefs/build_layout.mk diff --git a/build_test.mk b/builddefs/build_test.mk similarity index 93% rename from build_test.mk rename to builddefs/build_test.mk index ec6699b4ea6..7226004aabc 100644 --- a/build_test.mk +++ b/builddefs/build_test.mk @@ -54,7 +54,7 @@ include tests/test_common/build.mk include $(TEST_PATH)/test.mk endif -include common_features.mk +include $(BUILDDEFS_PATH)/common_features.mk include $(BUILDDEFS_PATH)/generic_features.mk include $(PLATFORM_PATH)/common.mk include $(TMK_PATH)/protocol.mk @@ -63,7 +63,7 @@ include $(QUANTUM_PATH)/encoder/tests/rules.mk include $(QUANTUM_PATH)/sequencer/tests/rules.mk include $(PLATFORM_PATH)/test/rules.mk ifneq ($(filter $(FULL_TESTS),$(TEST)),) -include build_full_test.mk +include $(BUILDDEFS_PATH)/build_full_test.mk endif $(TEST)_SRC += \ @@ -77,7 +77,7 @@ $(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS) $(TEST_OBJ)/$(TEST)_CONFIG := $($(TEST)_CONFIG) include $(PLATFORM_PATH)/$(PLATFORM_KEY)/platform.mk -include $(TMK_PATH)/rules.mk +include $(BUILDDEFS_PATH)/common_rules.mk $(shell mkdir -p $(BUILD_DIR)/test 2>/dev/null) diff --git a/common_features.mk b/builddefs/common_features.mk similarity index 100% rename from common_features.mk rename to builddefs/common_features.mk diff --git a/tmk_core/rules.mk b/builddefs/common_rules.mk similarity index 100% rename from tmk_core/rules.mk rename to builddefs/common_rules.mk diff --git a/testlist.mk b/builddefs/testlist.mk similarity index 100% rename from testlist.mk rename to builddefs/testlist.mk diff --git a/lib/python/qmk/cli/multibuild.py b/lib/python/qmk/cli/multibuild.py index ad059edff38..dff8c884221 100755 --- a/lib/python/qmk/cli/multibuild.py +++ b/lib/python/qmk/cli/multibuild.py @@ -69,7 +69,7 @@ def multibuild(cli): all: {keyboard_safe}_binary {keyboard_safe}_binary: @rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true - +@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false {' '.join(cli.args.env)} \\ + +@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false {' '.join(cli.args.env)} \\ >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" 2>&1 \\ || cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}" @{{ grep '\[ERRORS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\ diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 90a68ca3cd4..275cd72e5cd 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -213,7 +213,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va '-r', '-R', '-f', - 'build_keyboard.mk', + 'builddefs/build_keyboard.mk', ]) if bootloader: diff --git a/paths.mk b/paths.mk index 5a39d00ecd7..85ccfa07964 100644 --- a/paths.mk +++ b/paths.mk @@ -2,7 +2,9 @@ TOP_DIR = . TMK_DIR = tmk_core TMK_PATH = $(TMK_DIR) -LIB_PATH = lib + +LIB_DIR = lib +LIB_PATH = $(LIB_DIR) QUANTUM_DIR = quantum QUANTUM_PATH = $(QUANTUM_DIR)