mirror of
https://gitee.com/openharmony/third_party_littlefs
synced 2024-11-27 00:50:38 +00:00
eeaf536eca
The idea behind emubd (file per block), was neat, but doesn't add much value over a block device that just operates on a single linear file (other than adding a significant amount of overhead). Initially it helped with debugging, but when the metadata format became more complex in v2, most debugging ends up going through the debug.py script anyways. Aside from being simpler, moving to filebd means it is also possible to mount disk images directly. Also introduced rambd, which keeps the disk contents in RAM. This is very useful for testing where it increases the speed _significantly_. - test_dirs w/ filebd - 0m7.170s - test_dirs w/ rambd - 0m0.966s These follow the emubd model of using the lfs_config for geometry. I'm not convinced this is the best approach, but it gets the job done. I've also added lfs_ramdb_createcfg to add additional config similar to lfs_file_opencfg. This is useful for specifying erase_value, which tells the block device to simulate erases similar to flash devices. Note that the default (-1) meets the minimum block device requirements and is the most performant.
94 lines
1.4 KiB
Makefile
94 lines
1.4 KiB
Makefile
TARGET = lfs.a
|
|
ifneq ($(wildcard test.c main.c),)
|
|
override TARGET = lfs
|
|
endif
|
|
|
|
CC ?= gcc
|
|
AR ?= ar
|
|
SIZE ?= size
|
|
|
|
SRC += $(wildcard *.c rambd/*.c filebd/*.c)
|
|
OBJ := $(SRC:.c=.o)
|
|
DEP := $(SRC:.c=.d)
|
|
ASM := $(SRC:.c=.s)
|
|
|
|
TEST := $(patsubst tests/%.sh,%,$(wildcard tests/test_*))
|
|
|
|
SHELL = /bin/bash -o pipefail
|
|
|
|
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
|
|
# Remove missing-field-initializers because of GCC bug
|
|
override CFLAGS += -Wno-missing-field-initializers
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
asm: $(ASM)
|
|
|
|
size: $(OBJ)
|
|
$(SIZE) -t $^
|
|
|
|
.SUFFIXES:
|
|
test: \
|
|
test_format \
|
|
test_dirs \
|
|
test_files \
|
|
test_seek \
|
|
test_truncate \
|
|
test_entries \
|
|
test_interspersed \
|
|
test_alloc \
|
|
test_paths \
|
|
test_attrs \
|
|
test_move \
|
|
test_orphan \
|
|
test_relocations \
|
|
test_corrupt
|
|
@rm test.c
|
|
test_%: tests/test_%.sh
|
|
ifdef QUIET
|
|
@./$< | sed -nu '/^[-=]/p'
|
|
else
|
|
./$<
|
|
endif
|
|
|
|
test_:
|
|
./scripts/test_.py $(TFLAGS)
|
|
|
|
-include $(DEP)
|
|
|
|
%?:
|
|
@echo '$($*)'
|
|
|
|
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_/test_*.toml.*
|