mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
[Feature] Compilation warning if both keymap.json
and keymap.c
exist (#19939)
Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
parent
2563c9ba7f
commit
9b0887359b
|
@ -1,17 +1,17 @@
|
||||||
# Look for a json keymap file
|
# Look for a json keymap file
|
||||||
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.json)","")
|
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.json)","")
|
||||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_5)/keymap.json
|
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_5)/keymap.json
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
KEYMAP_JSON_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.json)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.json)","")
|
||||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_4)/keymap.json
|
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_4)/keymap.json
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
KEYMAP_JSON_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.json)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.json)","")
|
||||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_3)/keymap.json
|
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_3)/keymap.json
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
KEYMAP_JSON_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.json)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.json)","")
|
||||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_2)/keymap.json
|
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_2)/keymap.json
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
KEYMAP_JSON_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.json)","")
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.json)","")
|
||||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_1)/keymap.json
|
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_1)/keymap.json
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
KEYMAP_JSON_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -127,39 +127,44 @@ include $(INFO_RULES_MK)
|
||||||
include $(BUILDDEFS_PATH)/build_json.mk
|
include $(BUILDDEFS_PATH)/build_json.mk
|
||||||
|
|
||||||
# Pull in keymap level rules.mk
|
# Pull in keymap level rules.mk
|
||||||
ifeq ("$(wildcard $(KEYMAP_PATH))", "")
|
# Look through the possible keymap folders until we find a matching keymap.c
|
||||||
# Look through the possible keymap folders until we find a matching keymap.c
|
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
||||||
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
-include $(MAIN_KEYMAP_PATH_1)/rules.mk
|
||||||
-include $(MAIN_KEYMAP_PATH_1)/rules.mk
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
-include $(MAIN_KEYMAP_PATH_2)/rules.mk
|
||||||
-include $(MAIN_KEYMAP_PATH_2)/rules.mk
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
-include $(MAIN_KEYMAP_PATH_3)/rules.mk
|
||||||
-include $(MAIN_KEYMAP_PATH_3)/rules.mk
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
-include $(MAIN_KEYMAP_PATH_4)/rules.mk
|
||||||
-include $(MAIN_KEYMAP_PATH_4)/rules.mk
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
||||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
-include $(MAIN_KEYMAP_PATH_5)/rules.mk
|
||||||
-include $(MAIN_KEYMAP_PATH_5)/rules.mk
|
KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
|
||||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
|
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
else ifneq ($(LAYOUTS),)
|
||||||
else ifneq ($(LAYOUTS),)
|
# If we haven't found a keymap yet fall back to community layouts
|
||||||
# If we haven't found a keymap yet fall back to community layouts
|
include $(BUILDDEFS_PATH)/build_layout.mk
|
||||||
include $(BUILDDEFS_PATH)/build_layout.mk
|
# Not finding keymap.c is fine if we found a keymap.json
|
||||||
else
|
else ifeq ("$(wildcard $(KEYMAP_JSON_PATH))", "")
|
||||||
$(call CATASTROPHIC_ERROR,Invalid keymap,Could not find keymap)
|
$(call CATASTROPHIC_ERROR,Invalid keymap,Could not find keymap)
|
||||||
# this state should never be reached
|
# this state should never be reached
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Have we found a keymap.json?
|
# Have we found a keymap.json?
|
||||||
ifneq ("$(wildcard $(KEYMAP_JSON))", "")
|
ifneq ("$(wildcard $(KEYMAP_JSON))", "")
|
||||||
|
ifneq ("$(wildcard $(KEYMAP_C))", "")
|
||||||
|
$(call WARNING_MESSAGE,Keymap is specified as both keymap.json and keymap.c -- keymap.json file wins.)
|
||||||
|
endif
|
||||||
|
|
||||||
|
KEYMAP_PATH := $(KEYMAP_JSON_PATH)
|
||||||
|
|
||||||
KEYMAP_C := $(INTERMEDIATE_OUTPUT)/src/keymap.c
|
KEYMAP_C := $(INTERMEDIATE_OUTPUT)/src/keymap.c
|
||||||
KEYMAP_H := $(INTERMEDIATE_OUTPUT)/src/config.h
|
KEYMAP_H := $(INTERMEDIATE_OUTPUT)/src/config.h
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,10 @@ MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) $(MSG_BOOTLOADER_NOT_
|
||||||
BOOTLOADER_RETRY_TIME ?= 0.5
|
BOOTLOADER_RETRY_TIME ?= 0.5
|
||||||
MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again every $(BOOTLOADER_RETRY_TIME)s (Ctrl+C to cancel)
|
MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again every $(BOOTLOADER_RETRY_TIME)s (Ctrl+C to cancel)
|
||||||
|
|
||||||
|
define WARNING_MESSAGE
|
||||||
|
$(shell printf "\n %-99s $(WARN_STRING)\n" "$1" >&2)
|
||||||
|
endef
|
||||||
|
|
||||||
define CATASTROPHIC_ERROR
|
define CATASTROPHIC_ERROR
|
||||||
$(shell printf "\n * %-99s $(ERROR_STRING)\n" "$2" >&2)
|
$(shell printf "\n * %-99s $(ERROR_STRING)\n" "$2" >&2)
|
||||||
$(error $1)
|
$(error $1)
|
||||||
|
|
Loading…
Reference in a new issue