summaryrefslogtreecommitdiffstats
path: root/builddefs/build_keyboard.mk
diff options
context:
space:
mode:
Diffstat (limited to 'builddefs/build_keyboard.mk')
-rw-r--r--builddefs/build_keyboard.mk33
1 files changed, 32 insertions, 1 deletions
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
index dc86b232df..b5616a438f 100644
--- a/builddefs/build_keyboard.mk
+++ b/builddefs/build_keyboard.mk
@@ -13,6 +13,14 @@ endif
include paths.mk
include $(BUILDDEFS_PATH)/message.mk
+# Helper to add defines with a 'QMK_' prefix
+define add_qmk_prefix_defs
+ ifdef $1
+ # Need to cater for 'STM32L4xx+'
+ OPT_DEFS += -DQMK_$(2)="$($1)" -DQMK_$(2)_$(shell echo $($1) | sed -e 's@+@Plus@g' -e 's@[^a-zA-Z0-9]@_@g' | tr '[:lower:]' '[:upper:]')
+ endif
+endef
+
# Set the qmk cli to use
QMK_BIN ?= qmk
@@ -390,10 +398,12 @@ ifneq ("$(KEYMAP_H)","")
CONFIG_H += $(KEYMAP_H)
endif
+OPT_DEFS += -DKEYMAP_C=\"$(KEYMAP_C)\"
+
# project specific files
SRC += \
$(KEYBOARD_SRC) \
- $(KEYMAP_C) \
+ $(QUANTUM_DIR)/keymap_introspection.c \
$(QUANTUM_SRC) \
$(QUANTUM_DIR)/main.c \
@@ -436,6 +446,14 @@ else
include $(TMK_PATH)/protocol/$(PLATFORM_KEY).mk
endif
+# Setup definitions based on the selected MCU
+$(eval $(call add_qmk_prefix_defs,MCU_ORIG,MCU))
+$(eval $(call add_qmk_prefix_defs,MCU_ARCH,MCU_ARCH))
+$(eval $(call add_qmk_prefix_defs,MCU_PORT_NAME,MCU_PORT_NAME))
+$(eval $(call add_qmk_prefix_defs,MCU_FAMILY,MCU_FAMILY))
+$(eval $(call add_qmk_prefix_defs,MCU_SERIES,MCU_SERIES))
+$(eval $(call add_qmk_prefix_defs,BOARD,BOARD))
+
# TODO: remove this bodge?
PROJECT_DEFS := $(OPT_DEFS)
PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
@@ -469,6 +487,19 @@ check-size: build
check-md5: build
objs-size: build
+ifeq ($(strip $(TOP_SYMBOLS)),yes)
+all: top-symbols
+check-size: top-symbols
+top-symbols: build
+ echo "###########################################"
+ echo "# Highest flash usage:"
+ $(NM) -Crtd --size-sort $(BUILD_DIR)/$(TARGET).elf | grep -i ' [t] ' | head -n10 | sed -e 's#^0000000# #g' -e 's#^000000# #g' -e 's#^00000# #g' -e 's#^0000# #g' -e 's#^000# #g' -e 's#^00# #g' -e 's#^0# #g'
+ echo "###########################################"
+ echo "# Highest RAM usage:"
+ $(NM) -Crtd --size-sort $(BUILD_DIR)/$(TARGET).elf | grep -i ' [dbv] ' | head -n10 | sed -e 's#^0000000# #g' -e 's#^000000# #g' -e 's#^00000# #g' -e 's#^0000# #g' -e 's#^000# #g' -e 's#^00# #g' -e 's#^0# #g'
+ echo "###########################################"
+endif
+
include $(BUILDDEFS_PATH)/show_options.mk
include $(BUILDDEFS_PATH)/common_rules.mk