Subproject parsing
Does not handle keyboards without subprojects correctly yet.
This commit is contained in:
parent
9ee6d4a23d
commit
1df6498721
49
Makefile
49
Makefile
@ -51,6 +51,7 @@ $(info Keyboards: $(KEYBOARDS))
|
|||||||
# Otherwise the RULE_FOUND variable is set to false
|
# Otherwise the RULE_FOUND variable is set to false
|
||||||
# The function is a bit tricky, since there's no built in $(startswith) function
|
# The function is a bit tricky, since there's no built in $(startswith) function
|
||||||
define COMPARE_AND_REMOVE_FROM_RULE
|
define COMPARE_AND_REMOVE_FROM_RULE
|
||||||
|
RULE_FOUND := false
|
||||||
ifeq ($1,$$(RULE))
|
ifeq ($1,$$(RULE))
|
||||||
RULE:=
|
RULE:=
|
||||||
RULE_FOUND := true
|
RULE_FOUND := true
|
||||||
@ -70,11 +71,13 @@ endef
|
|||||||
# If a match is found, then RULE_FOUND is set to true
|
# If a match is found, then RULE_FOUND is set to true
|
||||||
# and MATCHED_ITEM to the item that was matched
|
# and MATCHED_ITEM to the item that was matched
|
||||||
define TRY_TO_MATCH_RULE_FROM_LIST
|
define TRY_TO_MATCH_RULE_FROM_LIST
|
||||||
$$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)))
|
ifneq ($1,)
|
||||||
ifeq ($$(RULE_FOUND),true)
|
$$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)))
|
||||||
MATCHED_ITEM := $$(firstword $1)
|
ifeq ($$(RULE_FOUND),true)
|
||||||
else ifneq ($1,)
|
MATCHED_ITEM := $$(firstword $1)
|
||||||
$$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(wordlist 2,9999,$1)))
|
else
|
||||||
|
$$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(wordlist 2,9999,$1)))
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -96,10 +99,18 @@ define PARSE_ALL_KEYMAPS
|
|||||||
$$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
|
$$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# $1 = Keyboard
|
define PARSE_ALL_SUBPROJECTS
|
||||||
define PARSE_KEYBOARD
|
ifeq ($$(SUBPROJECTS),)
|
||||||
CURRENT_KB := $1
|
$$(eval $$(call PARSE_SUBPROJECT,))
|
||||||
KEYMAPS := $(notdir $(patsubst %/.,%,$(wildcard $(ROOT_DIR)/keyboards/$1/keymaps/*/.)))
|
else
|
||||||
|
$$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$$(SUBPROJECTS)))
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
|
# $1 Subproject
|
||||||
|
define PARSE_SUBPROJECT
|
||||||
|
CURRENT_SP := $1
|
||||||
|
KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
|
||||||
$$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allkm))
|
$$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allkm))
|
||||||
ifeq ($$(RULE_FOUND),true)
|
ifeq ($$(RULE_FOUND),true)
|
||||||
$$(eval $$(call PARSE_ALL_KEYMAPS))
|
$$(eval $$(call PARSE_ALL_KEYMAPS))
|
||||||
@ -111,11 +122,27 @@ define PARSE_KEYBOARD
|
|||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# $1 = Keyboard
|
||||||
|
define PARSE_KEYBOARD
|
||||||
|
CURRENT_KB := $1
|
||||||
|
# A subproject is any keyboard subfolder with a makefile
|
||||||
|
SUBPROJECTS := $$(notdir $$(patsubst %/Makefile,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/*/Makefile)))
|
||||||
|
$$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allsp))
|
||||||
|
ifeq ($$(RULE_FOUND),true)
|
||||||
|
$$(eval $$(call PARSE_ALL_SUBPROJECTS))
|
||||||
|
else
|
||||||
|
$$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(SUBPROJECTS)))
|
||||||
|
ifeq ($$(RULE_FOUND),true)
|
||||||
|
$$(eval $$(call PARSE_SUBPROJECT,$$(MATCHED_ITEM)))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
# $1 Keymap
|
# $1 Keymap
|
||||||
define PARSE_KEYMAP
|
define PARSE_KEYMAP
|
||||||
CURRENT_KM = $1
|
CURRENT_KM = $1
|
||||||
COMMANDS += KEYBOARD_$$(CURRENT_KB)_KEYMAP_$$(CURRENT_KM)
|
COMMANDS += KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
|
||||||
COMMAND_KEYBOARD_$$(CURRENT_KB)_KEYMAP_$$(CURRENT_KM) := Keyboard $$(CURRENT_KB), Keymap $$(CURRENT_KM)
|
COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM) := Keyboard $$(CURRENT_KB), Subproject $$(CURRENT_SP), Keymap $$(CURRENT_KM)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define PARSE_RULE
|
define PARSE_RULE
|
||||||
|
Loading…
Reference in New Issue
Block a user