diff --git a/SConscript b/SConscript index 86c47fb3..6e191d71 100644 --- a/SConscript +++ b/SConscript @@ -1,6 +1,4 @@ -Import("env") - -SConscript(['opendbc/dbc/SConscript'], exports={'env': env}) +SConscript(['opendbc/dbc/SConscript']) # test files if GetOption('extras'): diff --git a/SConstruct b/SConstruct index c43351a6..ac0fe1dc 100644 --- a/SConstruct +++ b/SConstruct @@ -1,27 +1,9 @@ -import os -import subprocess -import platform - -arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() -if platform.system() == "Darwin": - arch = "Darwin" - -cpppath = [ - '#', - '/usr/lib/include', -] - AddOption('--minimal', action='store_false', dest='extras', default=True, help='the minimum build. no tests, tools, etc.') -AddOption('--asan', - action='store_true', - help='turn on ASAN') - -# safety options AddOption('--ubsan', action='store_true', help='turn on UBSan') @@ -30,35 +12,4 @@ AddOption('--mutation', action='store_true', help='generate mutation-ready code') -ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else [] -ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else [] - -env = Environment( - ENV=os.environ, - CC='gcc', - CXX='g++', - CCFLAGS=[ - "-g", - "-fPIC", - "-O2", - "-Wunused", - "-Werror", - "-Wshadow", - "-Wno-vla-cxx-extension", - "-Wno-unknown-warning-option", # for compatibility across compiler versions - ] + ccflags_asan, - LDFLAGS=ldflags_asan, - LINKFLAGS=ldflags_asan, - CFLAGS="-std=gnu11", - CXXFLAGS=["-std=c++1z"], - CPPPATH=cpppath, - tools=["default", "compilation_db"] -) -if arch != "Darwin": - env.Append(CCFLAGS=["-fmax-errors=1", ]) - -env.CompilationDatabase('compile_commands.json') - -Export('env', 'arch') - SConscript(['SConscript']) diff --git a/opendbc/dbc/SConscript b/opendbc/dbc/SConscript index 9a929120..481e024b 100644 --- a/opendbc/dbc/SConscript +++ b/opendbc/dbc/SConscript @@ -1,7 +1,8 @@ -Import("env") - +import os from pathlib import Path +env = Environment(ENV=os.environ) + generator = File("generator/generator.py") source_files = [ diff --git a/opendbc/safety/tests/libsafety/SConscript b/opendbc/safety/tests/libsafety/SConscript index c02a703a..a27a38a7 100644 --- a/opendbc/safety/tests/libsafety/SConscript +++ b/opendbc/safety/tests/libsafety/SConscript @@ -24,13 +24,24 @@ env = Environment( '-Wno-pointer-to-int-cast', '-g', '-O0', - "-fno-omit-frame-pointer" + '-fno-omit-frame-pointer', + '-fprofile-arcs', + '-ftest-coverage', + ], + LINKFLAGS=[ + '-fprofile-arcs', + '-ftest-coverage', ], CPPPATH=["#", "../../board/"], tools=["default", "compilation_db"], ) if system == "Darwin": env.PrependENVPath('PATH', '/opt/homebrew/bin') +if GetOption('ubsan'): + env.Prepend(LINKFLAGS=[ + "-fsanitize=undefined", + "-fno-sanitize-recover=undefined", + ]) if GetOption('mutation'): env['CC'] = 'clang-17' @@ -44,26 +55,8 @@ if GetOption('mutation'): env['CFLAGS'] += flags env['LINKFLAGS'] += flags -if GetOption('ubsan'): - flags = [ - "-fsanitize=undefined", - "-fno-sanitize-recover=undefined", - ] - env['CFLAGS'] += flags - env['LINKFLAGS'] += flags - safety = env.SharedObject("safety.os", "safety.c") libsafety = env.SharedLibrary("libsafety.so", [safety]) -coverage_flags = [ - # GCC coverage flags - '-fprofile-arcs', - '-ftest-coverage', -] -env.Append( - CFLAGS=coverage_flags, - LINKFLAGS=coverage_flags, -) - # GCC note file is generated by compiler, allow scons to clean it up env.SideEffect("safety.gcno", safety)