From 596344e48b2db750c88f2167f4d3f11b41de656e Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 31 Mar 2021 18:35:47 -0700 Subject: [PATCH] build libpandasafety with scons (#639) * build libpandasafety with scons * remove makefile * fix that --- .gitignore | 1 + SConstruct | 7 +++++++ tests/safety/Makefile | 18 ------------------ tests/safety/SConscript | 7 +++++++ tests/safety/libpandasafety_py.py | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 tests/safety/Makefile create mode 100644 tests/safety/SConscript diff --git a/.gitignore b/.gitignore index 2cd2eb8..3a8ead1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .*.swo *.o *.so +*.os *.d *.dump a.out diff --git a/SConstruct b/SConstruct index 4c48fe5..1ee5df7 100644 --- a/SConstruct +++ b/SConstruct @@ -1 +1,8 @@ +AddOption('--test', + action='store_true', + help='build test files') + SConscript('board/SConscript') + +if GetOption('test'): + SConscript('tests/safety/SConscript') diff --git a/tests/safety/Makefile b/tests/safety/Makefile deleted file mode 100644 index 334a294..0000000 --- a/tests/safety/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CC = clang -CCFLAGS = -O3 -fPIC -DPANDA -I. - -.PHONY: all -all: libpandasafety.so - -libpandasafety.so: test.o - $(CC) -shared -o '$@' $^ -lm - -test.o: test.c - @echo "[ CC ] $@" - $(CC) $(CCFLAGS) -MMD -c -I../../board -o '$@' '$<' - -.PHONY: clean -clean: - rm -f libpandasafety.so test.o test.d - --include test.d diff --git a/tests/safety/SConscript b/tests/safety/SConscript new file mode 100644 index 0000000..2e2754f --- /dev/null +++ b/tests/safety/SConscript @@ -0,0 +1,7 @@ +env = Environment( + CC='clang', + CXX='clang++', + CPPPATH=[".", "../../board"], +) + +env.SharedLibrary("libpandasafety.so", ["test.c"]) diff --git a/tests/safety/libpandasafety_py.py b/tests/safety/libpandasafety_py.py index e232b89..5349f13 100644 --- a/tests/safety/libpandasafety_py.py +++ b/tests/safety/libpandasafety_py.py @@ -5,7 +5,7 @@ from cffi import FFI can_dir = os.path.dirname(os.path.abspath(__file__)) libpandasafety_fn = os.path.join(can_dir, "libpandasafety.so") -subprocess.check_call(["make"], cwd=can_dir) +subprocess.check_call([f"scons -u -j{os.cpu_count()} --test ."], shell=True, cwd=can_dir) ffi = FFI() ffi.cdef("""