make: set up test framework
This commit is contained in:
parent
e089e2ba4e
commit
82d765bee3
7 changed files with 33 additions and 17 deletions
27
Makefile
27
Makefile
|
@ -22,15 +22,18 @@ CFLAGS += -std=c99
|
|||
CFLAGS += -Os -flto
|
||||
LDFLAGS += -Os -flto
|
||||
|
||||
TEST_LIBS += -lcmocka
|
||||
|
||||
-include source/Makefile
|
||||
|
||||
obj-y += source/bitops.o
|
||||
obj-y += source/main.o
|
||||
|
||||
obj-y += source/core/flash.o
|
||||
|
||||
obj = $(addprefix $(BUILD)/, $(obj-y))
|
||||
|
||||
tbm-obj = $(addprefix $(BUILD)/, $(tbm-obj-y))
|
||||
tbm-obj += $(obj)
|
||||
|
||||
test-obj = $(addprefix $(BUILD)/, $(test-obj-y))
|
||||
test-obj += $(obj)
|
||||
|
||||
# Include the dependencies.
|
||||
-include $(obj:.o=.d)
|
||||
|
||||
|
@ -52,9 +55,17 @@ $(BUILD)/%.o: %.c
|
|||
@mkdir -p $(dir $@)
|
||||
@$(CC) -c $< -o $@ $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d)
|
||||
|
||||
$(BUILD)/tbm: $(obj) $(LDSCRIPT)
|
||||
$(BUILD)/tbm: $(tbm-obj) $(LDSCRIPT)
|
||||
@echo "LD $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@$(LD) -o $@ $(CFLAGS) $(LDFLAGS) $(obj) $(LIBS)
|
||||
@$(LD) -o $@ $(CFLAGS) $(LDFLAGS) $(tbm-obj) $(LIBS)
|
||||
|
||||
.PHONY: clean
|
||||
$(BUILD)/test: $(test-obj)
|
||||
@echo "LD $@"
|
||||
@mkdir -p $(dir $@)
|
||||
@$(LD) -o $@ $(CFLAGS) $(LDFLAGS) $(test-obj) -Wl,--wrap=flash_read $(LIBS) $(TEST_LIBS)
|
||||
|
||||
test: $(BUILD)/test
|
||||
@$(BUILD)/test
|
||||
|
||||
.PHONY: clean test
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CFLAGS += -g
|
||||
|
||||
obj-y += source/drivers/sandbox_flash.o
|
||||
obj-y += source/drivers/stdio_console.o
|
||||
CFLAGS += -DHAVE_SYS_TYPES_H=1
|
||||
|
||||
tools: $(BUILD)/create-image
|
||||
all: tools
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
-include source/core/Makefile
|
||||
-include source/ftl/Makefile
|
||||
-include source/mufs/Makefile
|
||||
-include source/platform/Makefile
|
||||
-include source/shell/Makefile
|
||||
-include source/tests/Makefile
|
||||
|
||||
obj-y += source/bitops.o
|
||||
|
||||
tbm-obj-y += source/main.o
|
||||
|
|
1
source/core/Makefile
Normal file
1
source/core/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
tbm-obj-y += source/core/flash.o
|
|
@ -1,7 +1 @@
|
|||
ifeq ($(TARGET),host)
|
||||
else
|
||||
obj-y += source/platform/spi_flash.o
|
||||
obj-y += source/platform/usart.o
|
||||
endif
|
||||
|
||||
-include source/platform/$(TARGET)/Makefile
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
obj-y += source/platform/spi_flash.o
|
||||
obj-y += source/platform/usart.o
|
||||
|
||||
obj-y += source/platform/stm32f0/gpio.o
|
||||
obj-y += source/platform/stm32f0/rcc.o
|
||||
obj-y += source/platform/stm32f0/rtc.o
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
obj-y += source/platform/spi_flash.o
|
||||
obj-y += source/platform/usart.o
|
||||
|
||||
obj-y += source/platform/stm32f1/gpio.o
|
||||
obj-y += source/platform/stm32f1/rcc.o
|
||||
obj-y += source/platform/stm32f1/rtc.o
|
||||
|
|
Loading…
Add table
Reference in a new issue