You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
import platform
|
|
|
|
CC = 'gcc'
|
|
system = platform.system()
|
|
if system == 'Darwin':
|
|
# gcc installed by homebrew has version suffix (e.g. gcc-12) in order to be
|
|
# distinguishable from system one - which acts as a symlink to clang
|
|
CC += '-13'
|
|
|
|
env = Environment(
|
|
CC=CC,
|
|
CFLAGS=[
|
|
'-Wall',
|
|
"-Wextra",
|
|
'-Werror',
|
|
'-nostdlib',
|
|
'-fno-builtin',
|
|
'-std=gnu11',
|
|
'-Wfatal-errors',
|
|
'-Wno-pointer-to-int-cast',
|
|
],
|
|
CPPPATH=[".", "../../board/", "../../"],
|
|
)
|
|
if system == "Darwin":
|
|
env.PrependENVPath('PATH', '/opt/homebrew/bin')
|
|
|
|
if GetOption('mutation'):
|
|
env['CC'] = 'clang-17'
|
|
flags = [
|
|
'-fprofile-instr-generate',
|
|
'-fcoverage-mapping',
|
|
'-fpass-plugin=/usr/lib/mull-ir-frontend-17',
|
|
'-g',
|
|
'-grecord-command-line',
|
|
]
|
|
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])
|
|
|
|
if GetOption('coverage'):
|
|
env.Append(
|
|
CFLAGS=["-fprofile-arcs", "-ftest-coverage", "-fprofile-abs-path",],
|
|
LIBS=["gcov"],
|
|
)
|
|
# GCC note file is generated by compiler, ensure we build it, and allow scons to clean it up
|
|
AlwaysBuild(safety)
|
|
env.SideEffect("safety.gcno", safety)
|
|
|