Paul Mathieu
f274749050
All host tests currently pass Some async refactors may not work well on device, will try later
92 lines
2.4 KiB
Makefile
92 lines
2.4 KiB
Makefile
CC = arm-none-eabi-gcc
|
|
LD = arm-none-eabi-g++
|
|
CXX = arm-none-eabi-g++
|
|
OBJCOPY = arm-none-eabi-objcopy
|
|
|
|
linker_script = bootloader.ld
|
|
includes =
|
|
sources =
|
|
|
|
CFLAGS = -march=armv6-m -g -ffunction-sections -fdata-sections -Os -Werror -Wall -flto
|
|
CXXFLAGS = $(CFLAGS) -std=c++20 -fno-exceptions -fcoroutines
|
|
CPPFLAGS = -MD -MP
|
|
LDFLAGS = -march=armv6-m \
|
|
-g --specs=nano.specs --specs=nosys.specs \
|
|
-Wl,--gc-sections -Os \
|
|
-Wl,--print-memory-usage -flto
|
|
|
|
includes += -Ihal/cmsis
|
|
|
|
sources += hal/lib/common/xil_assert.c
|
|
includes += -Ihal/lib/common
|
|
|
|
sources += hal/uart/xuartlite.c hal/uart/xuartlite_stats.c hal/uart/xuartlite_intr.c
|
|
includes += -Ihal/uart
|
|
|
|
bootloader_objects = bootloader.o vector_table.o $(sources:.c=.o)
|
|
app_objects = app_init.o crash.o main.o uart.o stdlib.o async.o trace.o $(sources:.c=.o)
|
|
|
|
CPPFLAGS += $(includes)
|
|
|
|
all: bootloader.elf app.bin
|
|
|
|
%.bin: %.elf
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
bootloader.elf: $(bootloader_objects) bootloader.ld
|
|
$(LD) -Wl,-Tbootloader.ld $(LDFLAGS) -o $@ $(bootloader_objects)
|
|
|
|
app.elf: $(app_objects) app.ld
|
|
$(LD) -Wl,-Tapp.ld $(LDFLAGS) -o $@ $(app_objects)
|
|
|
|
.PHONY: clean test
|
|
|
|
deps = $(app_objects:.o=.d) $(bootloader_objects:.o=.d)
|
|
|
|
HOSTCXX = clang++
|
|
HOSTLDFLAGS = -lgmock -lgtest -lgtest_main -L/usr/local/opt/llvm/lib -L/usr/local/lib
|
|
HOSTCFLAGS = -std=c++20 -g\
|
|
-I/usr/local/opt/llvm/include \
|
|
-I/usr/local/include \
|
|
-I/usr/local/include \
|
|
-MP -MD
|
|
|
|
TSAN_CFLAGS = $(HOSTCFLAGS) -fsanitize=thread
|
|
ASAN_CFLAGS = $(HOSTCFLAGS) -fsanitize=address -fsanitize=leak
|
|
|
|
tests = ring_buffer_test.run async_test_asan.run async_test_tsan.run uart_test_tsan.run
|
|
|
|
test: $(tests)
|
|
|
|
test/async_test_asan: async_test.cc async.host.o lock.host.o
|
|
test/async_test_tsan: async_test.cc async.host.o lock.host.o
|
|
test/ring_buffer_test: ring_buffer_test.cc lock.host.o
|
|
test/uart_test_tsan: uart_test.cc fake_uart.host.o async.host.o lock.host.o
|
|
|
|
%.run: test/%
|
|
TSAN_OPTIONS='suppressions=tsan.suppressions' ASAN_OPTIONS=detect_leaks=1 ./$<
|
|
|
|
%.host.o: %.cc
|
|
$(HOSTCXX) $(HOSTCFLAGS) -c -o $@ $<
|
|
|
|
test/%_test: | mktest
|
|
$(HOSTCXX) $(HOSTCFLAGS) -o $@ $^ $(HOSTLDFLAGS)
|
|
|
|
test/%_asan: | mktest
|
|
$(HOSTCXX) $(ASAN_CFLAGS) -o $@ $^ $(HOSTLDFLAGS)
|
|
|
|
test/%_tsan: | mktest
|
|
$(HOSTCXX) $(TSAN_CFLAGS) -o $@ $^ $(HOSTLDFLAGS)
|
|
|
|
mktest:
|
|
mkdir -p test
|
|
|
|
test_deps = async.host.d
|
|
|
|
|
|
clean:
|
|
rm -rf *.elf *.bin $(app_objects) $(bootloader_objects) $(deps)
|
|
rm -rf test/ *.dSYM $(test_deps) *.o
|
|
|
|
-include $(deps)
|
|
-include $(test_deps) |