Added scripts/code_size.py, for more in-depth code-size reporting

Inspired by Linux's Bloat-O-Meter, code_size.py wraps nm to provide
function-level code size, and supports detailed comparison between
different builds.

One difference is that code_size.py invokes littlefs's build system
similarly to test.py, creating a duplicate build in the "sizes"
directory. This makes it easy to monitor a cross-compiled build size
while simultaneously testing on the host machine.
This commit is contained in:
Christopher Haster
2020-12-13 08:35:31 -06:00
parent 1a59954ec6
commit d804c2d3b7
2 changed files with 334 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ endif
CC ?= gcc
AR ?= ar
SIZE ?= size
NM ?= nm
SRC += $(wildcard *.c bd/*.c)
OBJ := $(SRC:.c=.o)
@@ -29,6 +30,7 @@ override CFLAGS += -Wextra -Wshadow -Wjump-misses-init -Wundef
ifdef VERBOSE
override TFLAGS += -v
override SFLAGS += -v
endif
@@ -39,6 +41,9 @@ asm: $(ASM)
size: $(OBJ)
$(SIZE) -t $^
code_size:
./scripts/code_size.py $(SFLAGS)
test:
./scripts/test.py $(TFLAGS)
.SECONDEXPANSION:
@@ -65,3 +70,4 @@ clean:
rm -f $(DEP)
rm -f $(ASM)
rm -f tests/*.toml.*
rm -f sizes/*