mirror of
https://github.com/infiniteCable2/opendbc.git
synced 2026-06-08 10:54:51 +08:00
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
import os
|
|
import platform
|
|
|
|
system = platform.system()
|
|
|
|
env = Environment(
|
|
CFLAGS=[
|
|
'-Wall',
|
|
"-Wextra",
|
|
'-Werror',
|
|
'-nostdlib',
|
|
'-fno-builtin',
|
|
'-std=gnu11',
|
|
'-Wfatal-errors',
|
|
'-Wno-pointer-to-int-cast',
|
|
'-g',
|
|
'-O0',
|
|
'-fno-omit-frame-pointer',
|
|
'-DALLOW_DEBUG',
|
|
],
|
|
LINKFLAGS=[
|
|
'-fsanitize=undefined',
|
|
'-fno-sanitize-recover=undefined',
|
|
],
|
|
CPPPATH=["#"],
|
|
tools=["default", "compilation_db"],
|
|
)
|
|
|
|
# add coverage if available
|
|
# Use TryCompile (not TryLink) because -nostdlib in CFLAGS breaks the link probe.
|
|
conf = Configure(env, log_file=os.devnull)
|
|
prev = env['CFLAGS'][:]
|
|
env.Append(CFLAGS=['-fprofile-arcs', '-ftest-coverage'])
|
|
has_coverage = conf.TryCompile('int x;\n', '.c')
|
|
env['CFLAGS'] = prev
|
|
if has_coverage:
|
|
env.Append(CFLAGS=['-fprofile-arcs', '-ftest-coverage'])
|
|
env.Append(LINKFLAGS=['-fprofile-arcs', '-ftest-coverage'])
|
|
env = conf.Finish()
|
|
|
|
safety = env.SharedObject("safety.os", "safety.c")
|
|
libsafety = env.SharedLibrary("libsafety.so", [safety])
|
|
|
|
# GCC-style note file is generated by compiler, allow scons to clean it up
|
|
env.SideEffect("safety.gcno", safety)
|