Browse Source

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>
pjones-keymap
Takeshi ISHII 2 months ago
parent
commit
b9f6ff05d0
2 changed files with 12 additions and 1 deletions
  1. 1
    0
      message.mk
  2. 11
    1
      tmk_core/rules.mk

+ 1
- 0
message.mk View File

@@ -80,3 +80,4 @@ MSG_CHECK_FILESIZE = Checking file size of $(TARGET).hex
80 80
 MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n
81 81
 MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
82 82
 MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n
83
+MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n

+ 11
- 1
tmk_core/rules.mk View File

@@ -383,6 +383,8 @@ show_path:
383 383
 	@echo OBJ=$(OBJ)
384 384
 
385 385
 ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
386
+SIZE_MARGIN = 1024
387
+
386 388
 check-size:
387 389
 	$(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))
388 390
 	$(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:
390 392
 	$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
391 393
 	if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \
392 394
 		$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \
393
-		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 \
395
+		if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \
396
+		    printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \
397
+		else \
398
+		    if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \
399
+			$(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \
400
+		    else \
401
+			$(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \
402
+		    fi \
403
+		fi \
394 404
 	fi
395 405
 else
396 406
 check-size:

Loading…
Cancel
Save