2021-01-08 21:54:41 +08:00
|
|
|
Import('env', 'envCython', 'arch', 'zmq', 'QCOM_REPLAY')
|
2019-11-12 08:49:08 +08:00
|
|
|
|
2020-07-30 04:38:36 +08:00
|
|
|
import shutil
|
|
|
|
|
2020-10-24 15:07:24 +08:00
|
|
|
cereal_dir = Dir('.')
|
2019-11-21 08:32:42 +08:00
|
|
|
gen_dir = Dir('gen')
|
|
|
|
messaging_dir = Dir('messaging')
|
|
|
|
|
2021-01-08 21:54:41 +08:00
|
|
|
# Build cereal
|
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS")
|
2020-07-30 04:38:36 +08:00
|
|
|
env.Command(['gen/cpp/car.capnp.c++', 'gen/cpp/log.capnp.c++', 'gen/cpp/car.capnp.h', 'gen/cpp/log.capnp.h'],
|
|
|
|
['car.capnp', 'log.capnp'],
|
2020-10-24 15:07:24 +08:00
|
|
|
f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/")
|
2020-07-30 04:38:36 +08:00
|
|
|
|
2019-11-22 12:34:47 +08:00
|
|
|
if shutil.which('capnpc-java'):
|
2020-07-30 04:38:36 +08:00
|
|
|
env.Command(['gen/java/Car.java', 'gen/java/Log.java'],
|
|
|
|
['car.capnp', 'log.capnp'],
|
2020-10-24 15:07:24 +08:00
|
|
|
f"capnpc $SOURCES --src-prefix={cereal_dir.path} -o java:{gen_dir.path}/java/")
|
2019-11-14 02:01:01 +08:00
|
|
|
|
2019-11-22 09:48:01 +08:00
|
|
|
# TODO: remove non shared cereal and messaging
|
2019-11-22 23:09:46 +08:00
|
|
|
cereal_objects = env.SharedObject([
|
2020-07-30 04:38:36 +08:00
|
|
|
'gen/cpp/car.capnp.c++',
|
|
|
|
'gen/cpp/log.capnp.c++',
|
|
|
|
])
|
2019-11-12 08:49:08 +08:00
|
|
|
|
2019-11-22 23:09:46 +08:00
|
|
|
env.Library('cereal', cereal_objects)
|
2020-05-08 12:06:32 +08:00
|
|
|
env.SharedLibrary('cereal_shared', cereal_objects)
|
2019-11-21 08:32:42 +08:00
|
|
|
|
2021-01-08 21:54:41 +08:00
|
|
|
# Build messaging
|
|
|
|
|
2020-07-30 04:38:36 +08:00
|
|
|
services_h = env.Command(['services.h'],
|
|
|
|
['service_list.yaml', 'services.py'],
|
|
|
|
'python3 ' + cereal_dir.path + '/services.py > $TARGET')
|
2019-11-21 00:33:24 +08:00
|
|
|
|
2019-11-22 23:09:46 +08:00
|
|
|
messaging_objects = env.SharedObject([
|
2019-11-21 01:44:47 +08:00
|
|
|
'messaging/messaging.cc',
|
|
|
|
'messaging/impl_zmq.cc',
|
|
|
|
'messaging/impl_msgq.cc',
|
|
|
|
'messaging/msgq.cc',
|
2020-06-12 08:44:19 +08:00
|
|
|
'messaging/socketmaster.cc',
|
2019-11-22 23:09:46 +08:00
|
|
|
])
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2019-11-22 23:09:46 +08:00
|
|
|
messaging_lib = env.Library('messaging', messaging_objects)
|
2019-12-04 01:46:14 +08:00
|
|
|
Depends('messaging/impl_zmq.cc', services_h)
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2019-11-21 04:06:15 +08:00
|
|
|
# note, this rebuilds the deps shared, zmq is statically linked to make APK happy
|
2019-11-22 23:09:46 +08:00
|
|
|
# TODO: get APK to load system zmq to remove the static link
|
2020-05-13 09:50:24 +08:00
|
|
|
if arch == "aarch64":
|
|
|
|
zmq_static = FindFile("libzmq.a", "/usr/lib")
|
2020-06-12 08:44:19 +08:00
|
|
|
shared_lib_shared_lib = [zmq_static, 'm', 'stdc++', "gnustl_shared", "kj", "capnp"]
|
2020-05-13 09:50:24 +08:00
|
|
|
env.SharedLibrary('messaging_shared', messaging_objects, LIBS=shared_lib_shared_lib)
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq'])
|
2019-12-04 01:46:14 +08:00
|
|
|
Depends('messaging/bridge.cc', services_h)
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2020-11-26 09:14:50 +08:00
|
|
|
envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq"])
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2021-01-08 21:54:41 +08:00
|
|
|
|
|
|
|
# Build Vision IPC
|
|
|
|
vipc_sources = [
|
|
|
|
'visionipc/ipc.cc',
|
|
|
|
'visionipc/visionipc_server.cc',
|
|
|
|
'visionipc/visionipc_client.cc',
|
|
|
|
'visionipc/visionbuf.cc',
|
|
|
|
]
|
|
|
|
|
|
|
|
if arch in ["aarch64", "larch64"] and (not QCOM_REPLAY):
|
|
|
|
vipc_sources += ['visionipc/visionbuf_ion.cc']
|
|
|
|
else:
|
|
|
|
vipc_sources += ['visionipc/visionbuf_cl.cc']
|
|
|
|
|
|
|
|
vipc_objects = env.SharedObject(vipc_sources)
|
|
|
|
vipc = env.Library('visionipc', vipc_objects)
|
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
if GetOption('test'):
|
|
|
|
env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib])
|
2021-01-08 21:54:41 +08:00
|
|
|
env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'], LIBS=[vipc, messaging_lib, 'zmq', 'pthread', 'OpenCL'])
|