Skip to content

Commit 4a86370

Browse files
committed
Added quality of life improvements for main.c/test.c issues
1. Added check for main.c and test.c to decide compilation target 2. Added step to remove test.c after successful test completion The test.c file, which contains the expanded test main, is useful when debugging why tests are failing. However, keeping the test.c file around causes problems when a later attempt is made to compile a larger project containing the littlefs directory. Under (hopefully) normal operation, tests always pass. So it should be ok to remove the test.c file after a successful test run. Hopefully this behaviour doesn't cause too much confusion for contributors using the tests. On the other side of things, compiling the library with no main ends (successfully) with the "main not found" error message. By defaulting to lfs.a if neither test.c/main.c is avoid this in the common cases found by armijnhemel and Sim4n6
1 parent ba4f171 commit 4a86370

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
TARGET = lfs
1+
TARGET = lfs.a
2+
ifneq ($(wildcard test.c main.c),)
3+
override TARGET = lfs
4+
endif
25

36
CC ?= gcc
47
AR ?= ar
@@ -35,7 +38,9 @@ size: $(OBJ)
3538
.SUFFIXES:
3639
test: test_format test_dirs test_files test_seek test_truncate \
3740
test_interspersed test_alloc test_paths test_orphan test_move test_corrupt
41+
@rm test.c
3842
test_%: tests/test_%.sh
43+
3944
ifdef QUIET
4045
@./$< | sed -n '/^[-=]/p'
4146
else
@@ -44,7 +49,7 @@ endif
4449

4550
-include $(DEP)
4651

47-
$(TARGET): $(OBJ)
52+
lfs: $(OBJ)
4853
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
4954

5055
%.a: $(OBJ)

0 commit comments

Comments
 (0)