@@ -17,6 +17,13 @@ ROOT = ../..
1717OBJECT_DIR = ../../obj/test
1818TARGET_DIR = $(USER_DIR ) /target
1919
20+ RUSTEMU_DIR := $(ROOT ) /src/rustemu
21+ RUSTEMU_INCLUDE_DIR := $(RUSTEMU_DIR ) /include/
22+ RUSTEMU_TARGET_DIR := $(RUSTEMU_DIR ) /target/x86_64-unknown-linux-gnu/release
23+ RUSTEMU_HEADER := $(RUSTEMU_INCLUDE_DIR ) /rustemu.h
24+ RUSTEMU_LIBRARY := $(RUSTEMU_TARGET_DIR ) /librustemu.a
25+ RUSTEMU_SRC := $(shell find $(RUSTEMU_DIR ) /src -name '* .rs')
26+
2027include $(ROOT ) /make/system-id.mk
2128include $(ROOT ) /make/targets_list.mk
2229
@@ -130,10 +137,6 @@ common_filter_unittest_SRC := \
130137 $(USER_DIR ) /common/maths.c
131138
132139
133- encoding_unittest_SRC := \
134- $(USER_DIR ) /common/encoding.c
135-
136-
137140flight_failsafe_unittest_SRC := \
138141 $(USER_DIR ) /common/bitarray.c \
139142 $(USER_DIR ) /fc/rc_modes.c \
@@ -511,7 +514,7 @@ ifeq ($(shell $(CC) -v 2>&1 | grep -q "clang version" && echo "clang"),clang)
511514# Travis reports CC_VERSION of 4.2.1
512515CC_VERSION_MAJOR := $(firstword $(subst ., ,$(CC_VERSION ) ) )
513516CC_VERSION_CHECK_MIN := 7
514- CC_VERSION_CHECK_MAX := 13
517+ CC_VERSION_CHECK_MAX := 15
515518
516519# Added flags for clang 11 - 13 are not backwards compatible
517520ifeq ($(shell expr $(CC_VERSION_MAJOR ) \> 10 \& $(CC_VERSION_MAJOR ) \< 14) , 1)
@@ -566,6 +569,7 @@ C_FLAGS += $(COVERAGE_FLAGS)
566569CXX_FLAGS += $(COVERAGE_FLAGS )
567570
568571C_FLAGS += -D_GNU_SOURCE
572+ LD_FLAGS += -L$(RUSTEMU_TARGET_DIR ) -lrustemu
569573
570574# Set up the parameter group linker flags according to OS
571575ifeq ($(OSFAMILY ) , macosx)
@@ -674,10 +678,15 @@ $(OBJECT_DIR)/gtest_main.a : $(OBJECT_DIR)/gtest-all.o $(OBJECT_DIR)/gtest_main.
674678-include $(OBJECT_DIR ) /gtest-all.d \
675679 $(OBJECT_DIR)/gtest_main.d
676680
681+ $(RUSTEMU_LIBRARY ) : $(RUSTEMU_SRC )
682+ cd $(ROOT ) /src/rustemu && cargo build --release
683+
684+ $(RUSTEMU_HEADER ) : $(RUSTEMU_LIBRARY )
685+ cd $(ROOT ) /src/rustemu && cbindgen --lang c -o $(PWD ) /$(RUSTEMU_HEADER )
677686
678687# includes in test dir must override includes in user dir, unless the user
679688# specifies a list of endorsed directories in ${target}_INCLUDE_DIRS.
680- test_include_dirs = $1 $(TEST_DIR ) $(USER_DIR )
689+ test_include_dirs = $1 $(TEST_DIR ) $(USER_DIR ) $( RUSTEMU_INCLUDE_DIR )
681690test_cflags = $(addprefix -I,$(call test_include_dirs,$1) )
682691
683692
@@ -748,7 +757,7 @@ $(OBJECT_DIR)/$1/%.c.o: $(TARGET_DIR)/$(call get_base_target,$(call target,$1))/
748757 -c $$< -o $$@
749758endif
750759
751- $(OBJECT_DIR ) /$1/$(basename $1) .o: $(TEST_DIR ) /$(basename $1) .cc
760+ $(OBJECT_DIR ) /$1/$(basename $1) .o: $(RUSTEMU_HEADER ) $( TEST_DIR ) /$(basename $1) .cc
752761 @echo "compiling $$< " "$(STDOUT ) "
753762 $(V1 ) mkdir -p $$(dir $$@ )
754763 $(V1 ) $(CXX ) $(CXX_FLAGS ) $$(call test_cflags,$$($1_INCLUDE_DIRS ) ) \
0 commit comments