2020-07-16 14:59:32 -06:00
|
|
|
import Cython
|
|
|
|
import distutils
|
2020-01-17 11:22:00 -07:00
|
|
|
import os
|
2020-07-07 13:36:02 -06:00
|
|
|
import shutil
|
2020-01-17 11:22:00 -07:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2020-02-02 00:36:50 -07:00
|
|
|
import platform
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
AddOption('--test',
|
|
|
|
action='store_true',
|
|
|
|
help='build test files')
|
|
|
|
|
|
|
|
AddOption('--asan',
|
|
|
|
action='store_true',
|
|
|
|
help='turn on ASAN')
|
|
|
|
|
2020-07-16 14:59:32 -06:00
|
|
|
# Rebuild cython extensions if python, distutils, or cython change
|
|
|
|
cython_dependencies = [Value(v) for v in (sys.version, distutils.__version__, Cython.__version__)]
|
|
|
|
Export('cython_dependencies')
|
|
|
|
|
2020-08-31 07:02:01 -06:00
|
|
|
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
2020-02-02 00:36:50 -07:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
arch = "Darwin"
|
2020-03-31 17:34:55 -06:00
|
|
|
if arch == "aarch64" and not os.path.isdir("/system"):
|
|
|
|
arch = "larch64"
|
2020-01-17 11:22:00 -07:00
|
|
|
|
2020-03-26 20:19:47 -06:00
|
|
|
webcam = bool(ARGUMENTS.get("use_webcam", 0))
|
2020-06-04 19:57:25 -06:00
|
|
|
QCOM_REPLAY = arch == "aarch64" and os.getenv("QCOM_REPLAY") is not None
|
2020-03-26 20:19:47 -06:00
|
|
|
|
2020-03-31 17:34:55 -06:00
|
|
|
if arch == "aarch64" or arch == "larch64":
|
2020-01-17 11:22:00 -07:00
|
|
|
lenv = {
|
|
|
|
"LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib',
|
|
|
|
"PATH": os.environ['PATH'],
|
|
|
|
}
|
|
|
|
|
2020-03-31 17:34:55 -06:00
|
|
|
if arch == "aarch64":
|
|
|
|
# android
|
|
|
|
lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA']
|
|
|
|
lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT']
|
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
cpppath = [
|
|
|
|
"#phonelibs/opencl/include",
|
|
|
|
]
|
2020-03-31 17:34:55 -06:00
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
libpath = [
|
|
|
|
"/usr/lib",
|
|
|
|
"/data/data/com.termux/files/usr/lib",
|
|
|
|
"/system/vendor/lib64",
|
|
|
|
"/system/comma/usr/lib",
|
|
|
|
"#phonelibs/nanovg",
|
|
|
|
]
|
|
|
|
|
2020-03-31 17:34:55 -06:00
|
|
|
if arch == "larch64":
|
2020-07-10 16:26:16 -06:00
|
|
|
libpath += [
|
|
|
|
"#phonelibs/snpe/larch64",
|
|
|
|
"#phonelibs/libyuv/larch64/lib",
|
|
|
|
"/usr/lib/aarch64-linux-gnu"
|
|
|
|
]
|
2020-03-31 17:34:55 -06:00
|
|
|
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
|
|
|
|
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
|
2020-03-31 19:25:05 -06:00
|
|
|
rpath = ["/usr/local/lib"]
|
2020-03-31 17:34:55 -06:00
|
|
|
else:
|
2020-07-10 16:26:16 -06:00
|
|
|
libpath += [
|
|
|
|
"#phonelibs/snpe/aarch64",
|
|
|
|
"#phonelibs/libyuv/lib"
|
|
|
|
]
|
2020-03-31 17:34:55 -06:00
|
|
|
cflags = ["-DQCOM", "-mcpu=cortex-a57"]
|
|
|
|
cxxflags = ["-DQCOM", "-mcpu=cortex-a57"]
|
2020-03-31 19:25:05 -06:00
|
|
|
rpath = ["/system/vendor/lib64"]
|
2020-01-17 11:22:00 -07:00
|
|
|
|
2020-06-04 19:57:25 -06:00
|
|
|
if QCOM_REPLAY:
|
|
|
|
cflags += ["-DQCOM_REPLAY"]
|
|
|
|
cxxflags += ["-DQCOM_REPLAY"]
|
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
else:
|
2020-06-11 19:21:59 -06:00
|
|
|
cflags = []
|
|
|
|
cxxflags = []
|
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
lenv = {
|
|
|
|
"PATH": "#external/bin:" + os.environ['PATH'],
|
|
|
|
}
|
|
|
|
cpppath = [
|
|
|
|
"#external/tensorflow/include",
|
|
|
|
]
|
2020-02-02 00:36:50 -07:00
|
|
|
|
|
|
|
if arch == "Darwin":
|
|
|
|
libpath = [
|
|
|
|
"#phonelibs/libyuv/mac/lib",
|
|
|
|
"#cereal",
|
|
|
|
"#selfdrive/common",
|
|
|
|
"/usr/local/lib",
|
|
|
|
"/System/Library/Frameworks/OpenGL.framework/Libraries",
|
|
|
|
]
|
2020-07-10 16:26:16 -06:00
|
|
|
cflags += ["-DGL_SILENCE_DEPRECATION"]
|
|
|
|
cxxflags += ["-DGL_SILENCE_DEPRECATION"]
|
2020-02-02 00:36:50 -07:00
|
|
|
else:
|
|
|
|
libpath = [
|
|
|
|
"#phonelibs/snpe/x86_64-linux-clang",
|
|
|
|
"#phonelibs/libyuv/x64/lib",
|
|
|
|
"#external/tensorflow/lib",
|
|
|
|
"#cereal",
|
|
|
|
"#selfdrive/common",
|
|
|
|
"/usr/lib",
|
|
|
|
"/usr/local/lib",
|
|
|
|
]
|
2020-01-17 11:22:00 -07:00
|
|
|
|
2020-05-12 19:50:07 -06:00
|
|
|
rpath = [
|
2020-07-10 16:26:16 -06:00
|
|
|
"external/tensorflow/lib",
|
|
|
|
"cereal",
|
|
|
|
"selfdrive/common"
|
|
|
|
]
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
# allows shared libraries to work globally
|
|
|
|
rpath = [os.path.join(os.getcwd(), x) for x in rpath]
|
|
|
|
|
2020-07-10 16:26:16 -06:00
|
|
|
if GetOption('asan'):
|
|
|
|
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"]
|
|
|
|
ldflags_asan = ["-fsanitize=address"]
|
|
|
|
else:
|
|
|
|
ccflags_asan = []
|
|
|
|
ldflags_asan = []
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
# change pythonpath to this
|
|
|
|
lenv["PYTHONPATH"] = Dir("#").path
|
|
|
|
|
|
|
|
env = Environment(
|
|
|
|
ENV=lenv,
|
|
|
|
CCFLAGS=[
|
|
|
|
"-g",
|
|
|
|
"-fPIC",
|
|
|
|
"-O2",
|
2020-07-09 10:25:32 -06:00
|
|
|
"-Wunused",
|
2020-05-26 14:27:01 -06:00
|
|
|
"-Werror",
|
|
|
|
"-Wno-deprecated-register",
|
|
|
|
"-Wno-inconsistent-missing-override",
|
2020-01-17 11:22:00 -07:00
|
|
|
] + cflags + ccflags_asan,
|
|
|
|
|
|
|
|
CPPPATH=cpppath + [
|
|
|
|
"#",
|
|
|
|
"#selfdrive",
|
|
|
|
"#phonelibs/bzip2",
|
|
|
|
"#phonelibs/libyuv/include",
|
|
|
|
"#phonelibs/openmax/include",
|
|
|
|
"#phonelibs/json11",
|
|
|
|
"#phonelibs/curl/include",
|
|
|
|
"#phonelibs/libgralloc/include",
|
|
|
|
"#phonelibs/android_frameworks_native/include",
|
|
|
|
"#phonelibs/android_hardware_libhardware/include",
|
|
|
|
"#phonelibs/android_system_core/include",
|
|
|
|
"#phonelibs/linux/include",
|
|
|
|
"#phonelibs/snpe/include",
|
|
|
|
"#phonelibs/nanovg",
|
|
|
|
"#selfdrive/common",
|
|
|
|
"#selfdrive/camerad",
|
|
|
|
"#selfdrive/camerad/include",
|
|
|
|
"#selfdrive/loggerd/include",
|
|
|
|
"#selfdrive/modeld",
|
2020-08-26 03:30:30 -06:00
|
|
|
"#selfdrive/sensord",
|
2020-08-20 09:16:44 -06:00
|
|
|
"#selfdrive/ui",
|
2020-01-17 11:22:00 -07:00
|
|
|
"#cereal/messaging",
|
|
|
|
"#cereal",
|
|
|
|
"#opendbc/can",
|
|
|
|
],
|
|
|
|
|
|
|
|
CC='clang',
|
|
|
|
CXX='clang++',
|
|
|
|
LINKFLAGS=ldflags_asan,
|
|
|
|
|
|
|
|
RPATH=rpath,
|
|
|
|
|
|
|
|
CFLAGS=["-std=gnu11"] + cflags,
|
|
|
|
CXXFLAGS=["-std=c++14"] + cxxflags,
|
2020-07-10 16:26:16 -06:00
|
|
|
LIBPATH=libpath + [
|
2020-01-17 11:22:00 -07:00
|
|
|
"#cereal",
|
|
|
|
"#selfdrive/common",
|
|
|
|
"#phonelibs",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2020-08-20 09:16:44 -06:00
|
|
|
qt_env = None
|
|
|
|
if arch in ["x86_64", "Darwin", "larch64"]:
|
|
|
|
qt_env = env.Clone()
|
|
|
|
|
2020-08-31 07:02:01 -06:00
|
|
|
if arch == "Darwin":
|
2020-08-20 09:16:44 -06:00
|
|
|
qt_env['QTDIR'] = "/usr/local/opt/qt"
|
|
|
|
QT_BASE = "/usr/local/opt/qt/"
|
|
|
|
qt_dirs = [
|
|
|
|
QT_BASE + "include/",
|
|
|
|
QT_BASE + "include/QtWidgets",
|
|
|
|
QT_BASE + "include/QtGui",
|
|
|
|
QT_BASE + "include/QtCore",
|
|
|
|
QT_BASE + "include/QtDBus",
|
2020-09-09 11:04:28 -06:00
|
|
|
QT_BASE + "include/QtMultimedia",
|
2020-08-20 09:16:44 -06:00
|
|
|
]
|
|
|
|
qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"]
|
|
|
|
else:
|
|
|
|
qt_dirs = [
|
2020-08-31 07:02:01 -06:00
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5",
|
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5/QtWidgets",
|
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui",
|
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5/QtCore",
|
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5/QtDBus",
|
2020-09-09 11:04:28 -06:00
|
|
|
f"/usr/include/{real_arch}-linux-gnu/qt5/QtMultimedia",
|
2020-08-20 09:16:44 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
qt_env.Tool('qt')
|
|
|
|
qt_env['CPPPATH'] += qt_dirs
|
|
|
|
qt_flags = [
|
|
|
|
"-D_REENTRANT",
|
|
|
|
"-DQT_NO_DEBUG",
|
|
|
|
"-DQT_WIDGETS_LIB",
|
|
|
|
"-DQT_GUI_LIB",
|
|
|
|
"-DQT_CORE_LIB"
|
|
|
|
]
|
|
|
|
qt_env['CXXFLAGS'] += qt_flags
|
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
if os.environ.get('SCONS_CACHE'):
|
2020-07-07 13:36:02 -06:00
|
|
|
cache_dir = '/tmp/scons_cache'
|
|
|
|
|
|
|
|
if os.getenv('CI'):
|
|
|
|
branch = os.getenv('GIT_BRANCH')
|
|
|
|
|
|
|
|
if QCOM_REPLAY:
|
|
|
|
cache_dir = '/tmp/scons_cache_qcom_replay'
|
|
|
|
elif branch is not None and branch != 'master':
|
|
|
|
cache_dir_branch = '/tmp/scons_cache_' + branch
|
|
|
|
if not os.path.isdir(cache_dir_branch) and os.path.isdir(cache_dir):
|
|
|
|
shutil.copytree(cache_dir, cache_dir_branch)
|
|
|
|
cache_dir = cache_dir_branch
|
|
|
|
CacheDir(cache_dir)
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
node_interval = 5
|
|
|
|
node_count = 0
|
|
|
|
def progress_function(node):
|
|
|
|
global node_count
|
|
|
|
node_count += node_interval
|
|
|
|
sys.stderr.write("progress: %d\n" % node_count)
|
|
|
|
|
|
|
|
if os.environ.get('SCONS_PROGRESS'):
|
|
|
|
Progress(progress_function, interval=node_interval)
|
|
|
|
|
|
|
|
SHARED = False
|
|
|
|
|
|
|
|
def abspath(x):
|
|
|
|
if arch == 'aarch64':
|
|
|
|
pth = os.path.join("/data/pythonpath", x[0].path)
|
|
|
|
env.Depends(pth, x)
|
|
|
|
return File(pth)
|
|
|
|
else:
|
|
|
|
# rpath works elsewhere
|
|
|
|
return x[0].path.rsplit("/", 1)[1][:-3]
|
|
|
|
|
|
|
|
# still needed for apks
|
2020-05-12 19:50:07 -06:00
|
|
|
zmq = 'zmq'
|
2020-08-20 09:16:44 -06:00
|
|
|
Export('env', 'qt_env', 'arch', 'zmq', 'SHARED', 'webcam', 'QCOM_REPLAY')
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
# cereal and messaging are shared with the system
|
|
|
|
SConscript(['cereal/SConscript'])
|
|
|
|
if SHARED:
|
|
|
|
cereal = abspath([File('cereal/libcereal_shared.so')])
|
|
|
|
messaging = abspath([File('cereal/libmessaging_shared.so')])
|
|
|
|
else:
|
|
|
|
cereal = [File('#cereal/libcereal.a')]
|
|
|
|
messaging = [File('#cereal/libmessaging.a')]
|
|
|
|
Export('cereal', 'messaging')
|
|
|
|
|
|
|
|
SConscript(['selfdrive/common/SConscript'])
|
|
|
|
Import('_common', '_visionipc', '_gpucommon', '_gpu_libs')
|
|
|
|
|
|
|
|
if SHARED:
|
|
|
|
common, visionipc, gpucommon = abspath(common), abspath(visionipc), abspath(gpucommon)
|
|
|
|
else:
|
2020-05-08 15:46:10 -06:00
|
|
|
common = [_common, 'json11']
|
2020-01-17 11:22:00 -07:00
|
|
|
visionipc = _visionipc
|
|
|
|
gpucommon = [_gpucommon] + _gpu_libs
|
|
|
|
|
|
|
|
Export('common', 'visionipc', 'gpucommon')
|
|
|
|
|
|
|
|
SConscript(['opendbc/can/SConscript'])
|
|
|
|
|
|
|
|
SConscript(['common/SConscript'])
|
|
|
|
SConscript(['common/kalman/SConscript'])
|
2020-06-09 17:44:26 -06:00
|
|
|
SConscript(['common/transformations/SConscript'])
|
2020-01-17 11:22:00 -07:00
|
|
|
SConscript(['phonelibs/SConscript'])
|
|
|
|
|
2020-06-11 19:21:59 -06:00
|
|
|
SConscript(['selfdrive/camerad/SConscript'])
|
|
|
|
SConscript(['selfdrive/modeld/SConscript'])
|
2020-02-02 00:36:50 -07:00
|
|
|
|
2020-01-17 11:22:00 -07:00
|
|
|
SConscript(['selfdrive/controls/lib/cluster/SConscript'])
|
|
|
|
SConscript(['selfdrive/controls/lib/lateral_mpc/SConscript'])
|
|
|
|
SConscript(['selfdrive/controls/lib/longitudinal_mpc/SConscript'])
|
2020-03-26 18:43:11 -06:00
|
|
|
SConscript(['selfdrive/controls/lib/longitudinal_mpc_model/SConscript'])
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
SConscript(['selfdrive/boardd/SConscript'])
|
|
|
|
SConscript(['selfdrive/proclogd/SConscript'])
|
2020-08-25 02:53:04 -06:00
|
|
|
SConscript(['selfdrive/clocksd/SConscript'])
|
2020-01-17 11:22:00 -07:00
|
|
|
|
|
|
|
SConscript(['selfdrive/loggerd/SConscript'])
|
|
|
|
|
2020-05-14 11:53:19 -06:00
|
|
|
SConscript(['selfdrive/locationd/SConscript'])
|
2020-05-14 16:36:56 -06:00
|
|
|
SConscript(['selfdrive/locationd/models/SConscript'])
|
2020-08-26 03:30:30 -06:00
|
|
|
SConscript(['selfdrive/sensord/SConscript'])
|
2020-08-31 07:02:01 -06:00
|
|
|
SConscript(['selfdrive/ui/SConscript'])
|
2020-05-14 11:53:19 -06:00
|
|
|
|
2020-08-26 09:09:23 -06:00
|
|
|
if arch != "Darwin":
|
2020-01-17 11:22:00 -07:00
|
|
|
SConscript(['selfdrive/logcatd/SConscript'])
|
2020-08-20 09:23:58 -06:00
|
|
|
|
2020-08-25 02:53:04 -06:00
|
|
|
|
|
|
|
if arch == "x86_64":
|
|
|
|
SConscript(['tools/lib/index_log/SConscript'])
|