build system cleanups (#2810)

* build system cleanups

* fix coverage
This commit is contained in:
Adeeb Shihadeh
2025-09-27 17:45:03 -07:00
committed by GitHub
parent dea1ea5688
commit 0c90bdb434
4 changed files with 16 additions and 73 deletions

View File

@@ -1,6 +1,4 @@
Import("env")
SConscript(['opendbc/dbc/SConscript'], exports={'env': env})
SConscript(['opendbc/dbc/SConscript'])
# test files
if GetOption('extras'):

View File

@@ -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'])

View File

@@ -1,7 +1,8 @@
Import("env")
import os
from pathlib import Path
env = Environment(ENV=os.environ)
generator = File("generator/generator.py")
source_files = [

View File

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