opendbc/SConstruct

81 lines
1.6 KiB
Python
Raw Normal View History

import os
import subprocess
import sysconfig
zmq = 'zmq'
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
cereal_dir = Dir('.')
python_path = sysconfig.get_paths()['include']
cpppath = [
'#',
'#cereal',
"#cereal/messaging",
"#opendbc/can",
'/usr/lib/include',
python_path
]
AddOption('--test',
action='store_true',
help='build test files')
AddOption('--asan',
action='store_true',
help='turn on ASAN')
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='clang',
CXX='clang++',
CCFLAGS=[
"-g",
"-fPIC",
"-O2",
2020-07-08 15:39:35 +08:00
"-Wunused",
2020-06-28 08:43:51 +08:00
"-Werror",
] + ccflags_asan,
LDFLAGS=ldflags_asan,
LINKFLAGS=ldflags_asan,
LIBPATH=[
"#opendbc/can/",
],
CFLAGS="-std=gnu11",
2020-10-18 03:41:35 +08:00
CXXFLAGS="-std=c++1z",
CPPPATH=cpppath,
CYTHONCFILESUFFIX=".cpp",
tools=["default", "cython"]
)
Export('env', 'zmq', 'arch')
cereal = [File('#cereal/libcereal.a')]
messaging = [File('#cereal/libmessaging.a')]
Export('cereal', 'messaging')
envCython = env.Clone()
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"]
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')
SConscript(['cereal/SConscript'])
SConscript(['opendbc/can/SConscript'])