aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 25 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 5fcd6bbf0f..f1e3bf856f 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,7 @@ ifeq ($(ROOT_DIR),)
endif
include paths.mk
+include $(BUILDDEFS_PATH)/support.mk
TEST_OUTPUT_DIR := $(BUILD_DIR)/test
ERROR_FILE := $(BUILD_DIR)/error_occurred
@@ -113,6 +114,29 @@ endef
# Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
+# As TRY_TO_MATCH_RULE_FROM_LIST_HELPER, but with additional
+# resolution of DEFAULT_FOLDER and keyboard_aliases.hjson for provided rule
+define TRY_TO_MATCH_RULE_FROM_LIST_HELPER_KB
+ # Split on ":", padding with empty strings to avoid indexing issues
+ TOKEN1:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[0])" $$(RULE))
+ TOKENr:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[1])" $$(RULE))
+
+ TOKEN1:=$$(shell $(QMK_BIN) resolve-alias --allow-unknown $$(TOKEN1))
+
+ FOUNDx:=$$(shell echo $1 | tr " " "\n" | grep -Fx $$(TOKEN1))
+ ifneq ($$(FOUNDx),)
+ RULE := $$(TOKENr)
+ RULE_FOUND := true
+ MATCHED_ITEM := $$(TOKEN1)
+ else
+ RULE_FOUND := false
+ MATCHED_ITEM :=
+ endif
+endef
+
+# Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST_KB
+TRY_TO_MATCH_RULE_FROM_LIST_KB = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER_KB,$1))$(RULE_FOUND)
+
define ALL_IN_LIST_LOOP
OLD_RULE$1 := $$(RULE)
$$(eval $$(call $1,$$(ITEM$1)))
@@ -138,7 +162,7 @@ define PARSE_RULE
$$(eval $$(call PARSE_TEST))
# If the rule starts with the name of a known keyboard, then continue
# the parsing from PARSE_KEYBOARD
- else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell $(QMK_BIN) list-keyboards --no-resolve-defaults)),true)
+ else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST_KB,$$(shell $(QMK_BIN) list-keyboards)),true)
KEYBOARD_RULE=$$(MATCHED_ITEM)
$$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
else
@@ -170,17 +194,6 @@ define PARSE_KEYBOARD
# include the correct makefile to determine the actual name of it
CURRENT_KB := $1
- # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
-
- DEFAULT_FOLDER := $$(CURRENT_KB)
-
- # We assume that every rules.mk will contain the full default value
- $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
- ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
- $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
- endif
- CURRENT_KB := $$(DEFAULT_FOLDER)
-
# 5/4/3/2/1
KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))