build libpandasafety with scons (#639)

* build libpandasafety with scons

* remove makefile

* fix that
master
Adeeb Shihadeh 2021-03-31 18:35:47 -07:00 committed by GitHub
parent f146aa367b
commit 596344e48b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 19 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
.*.swo
*.o
*.so
*.os
*.d
*.dump
a.out

View File

@ -1 +1,8 @@
AddOption('--test',
action='store_true',
help='build test files')
SConscript('board/SConscript')
if GetOption('test'):
SConscript('tests/safety/SConscript')

View File

@ -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

View File

@ -0,0 +1,7 @@
env = Environment(
CC='clang',
CXX='clang++',
CPPPATH=[".", "../../board"],
)
env.SharedLibrary("libpandasafety.so", ["test.c"])

View File

@ -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("""