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.
93 lines
2.1 KiB
93 lines
2.1 KiB
11 months ago
|
import os
|
||
|
import subprocess
|
||
|
import sysconfig
|
||
1 month ago
|
import platform
|
||
11 months ago
|
import numpy as np
|
||
|
|
||
|
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
||
1 month ago
|
if platform.system() == "Darwin":
|
||
|
arch = "Darwin"
|
||
11 months ago
|
|
||
|
python_path = sysconfig.get_paths()['include']
|
||
|
cpppath = [
|
||
|
'#',
|
||
|
'/usr/lib/include',
|
||
|
python_path
|
||
|
]
|
||
|
|
||
|
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')
|
||
|
|
||
1 month ago
|
# safety options
|
||
|
AddOption('--ubsan',
|
||
|
action='store_true',
|
||
|
help='turn on UBSan')
|
||
|
|
||
|
AddOption('--coverage',
|
||
|
action='store_true',
|
||
|
help='build with test coverage options')
|
||
|
|
||
|
AddOption('--mutation',
|
||
|
action='store_true',
|
||
|
help='generate mutation-ready code')
|
||
|
|
||
11 months ago
|
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,
|
||
1 month ago
|
CC='gcc',
|
||
|
CXX='g++',
|
||
11 months ago
|
CCFLAGS=[
|
||
|
"-g",
|
||
|
"-fPIC",
|
||
|
"-O2",
|
||
|
"-Wunused",
|
||
|
"-Werror",
|
||
|
"-Wshadow",
|
||
|
"-Wno-vla-cxx-extension",
|
||
1 month ago
|
"-Wno-unknown-warning-option", # for compatibility across compiler versions
|
||
11 months ago
|
] + ccflags_asan,
|
||
|
LDFLAGS=ldflags_asan,
|
||
|
LINKFLAGS=ldflags_asan,
|
||
|
LIBPATH=[
|
||
|
"#opendbc/can/",
|
||
|
],
|
||
|
CFLAGS="-std=gnu11",
|
||
|
CXXFLAGS=["-std=c++1z"],
|
||
|
CPPPATH=cpppath,
|
||
|
CYTHONCFILESUFFIX=".cpp",
|
||
|
tools=["default", "cython"]
|
||
|
)
|
||
|
|
||
|
common = ''
|
||
1 month ago
|
Export('env', 'arch', 'common')
|
||
11 months ago
|
|
||
|
envCython = env.Clone()
|
||
|
envCython["CPPPATH"] += [np.get_include()]
|
||
|
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
|
||
|
envCython["CCFLAGS"].remove("-Werror")
|
||
|
|
||
|
python_libs = []
|
||
|
if arch == "Darwin":
|
||
|
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
|
||
|
elif arch == "aarch64":
|
||
|
envCython["LINKFLAGS"] = ["-shared"]
|
||
|
|
||
|
python_libs.append(os.path.basename(python_path))
|
||
|
else:
|
||
|
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
||
|
|
||
|
envCython["LIBS"] = python_libs
|
||
|
|
||
|
Export('envCython')
|
||
|
|
||
1 month ago
|
SConscript(['SConscript'])
|