mirror of
https://gitee.com/openharmony/third_party_littlefs
synced 2025-03-01 04:07:34 +00:00

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.
74 lines
1.1 KiB
Makefile
74 lines
1.1 KiB
Makefile
TARGET = lfs.a
|
|
ifneq ($(wildcard test.c main.c),)
|
|
override TARGET = lfs
|
|
endif
|
|
|
|
CC ?= gcc
|
|
AR ?= ar
|
|
SIZE ?= size
|
|
NM ?= nm
|
|
|
|
SRC += $(wildcard *.c bd/*.c)
|
|
OBJ := $(SRC:.c=.o)
|
|
DEP := $(SRC:.c=.d)
|
|
ASM := $(SRC:.c=.s)
|
|
|
|
ifdef DEBUG
|
|
override CFLAGS += -O0 -g3
|
|
else
|
|
override CFLAGS += -Os
|
|
endif
|
|
ifdef WORD
|
|
override CFLAGS += -m$(WORD)
|
|
endif
|
|
ifdef TRACE
|
|
override CFLAGS += -DLFS_YES_TRACE
|
|
endif
|
|
override CFLAGS += -I.
|
|
override CFLAGS += -std=c99 -Wall -pedantic
|
|
override CFLAGS += -Wextra -Wshadow -Wjump-misses-init -Wundef
|
|
|
|
ifdef VERBOSE
|
|
override TFLAGS += -v
|
|
override SFLAGS += -v
|
|
endif
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
asm: $(ASM)
|
|
|
|
size: $(OBJ)
|
|
$(SIZE) -t $^
|
|
|
|
code_size:
|
|
./scripts/code_size.py $(SFLAGS)
|
|
|
|
test:
|
|
./scripts/test.py $(TFLAGS)
|
|
.SECONDEXPANSION:
|
|
test%: tests/test$$(firstword $$(subst \#, ,%)).toml
|
|
./scripts/test.py $@ $(TFLAGS)
|
|
|
|
-include $(DEP)
|
|
|
|
lfs: $(OBJ)
|
|
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
|
|
|
|
%.a: $(OBJ)
|
|
$(AR) rcs $@ $^
|
|
|
|
%.o: %.c
|
|
$(CC) -c -MMD $(CFLAGS) $< -o $@
|
|
|
|
%.s: %.c
|
|
$(CC) -S $(CFLAGS) $< -o $@
|
|
|
|
clean:
|
|
rm -f $(TARGET)
|
|
rm -f $(OBJ)
|
|
rm -f $(DEP)
|
|
rm -f $(ASM)
|
|
rm -f tests/*.toml.*
|
|
rm -f sizes/*
|