aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/rules.mk
diff options
context:
space:
mode:
authorGravatar Takeshi ISHII <2170248+mtei@users.noreply.github.com>2019-03-28 00:51:56 +0900
committerGravatar Drashna Jaelre <drashna@live.com>2019-03-27 08:51:56 -0700
commitb9f6ff05d09084d624b5736b46b8c8a446fa1892 (patch)
tree3ffcbe9d5e421bc0a475c626733deea58192d3eb /tmk_core/rules.mk
parent6f124b790938e2e74431fc85f2cc1ae04d824f6e (diff)
downloadqmk_firmware-b9f6ff05d09084d624b5736b46b8c8a446fa1892.tar.gz
build size-check enhancement (#5485)
* build size-check enhancement Changed to display a warning when the free size of compilation result is less than 512 bytes. * update message.mk * add SIZE_MARGIN variable, change default margin 512 to 1024 for Example. ``` $ make SIZE_MARGIN=2048 crkbd:all $ make crkbd:all ## mergin is 1024 ``` * Update message.mk change message to ‘approaching the maximum’ Co-Authored-By: mtei <2170248+mtei@users.noreply.github.com>
Diffstat (limited to 'tmk_core/rules.mk')
-rw-r--r--tmk_core/rules.mk12
1 files changed, 11 insertions, 1 deletions
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index c43f14292..3a322cee4 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -383,6 +383,8 @@ show_path:
@echo OBJ=$(OBJ)
ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
+SIZE_MARGIN = 1024
+
check-size:
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi))
@@ -390,7 +392,15 @@ check-size:
$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \
$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \
- if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \
+ if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \
+ printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \
+ else \
+ if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \
+ $(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \
+ else \
+ $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \
+ fi \
+ fi \
fi
else
check-size: