2021-07-29 16:32:29 +08:00
|
|
|
Import('env', 'envCython', 'arch', 'common')
|
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
|
|
|
|
|
2023-05-24 02:44:17 +08:00
|
|
|
schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp', 'custom.capnp']
|
2021-09-22 05:48:35 +08:00
|
|
|
env.Command(["gen/c/include/c++.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS")
|
2021-02-04 11:56:19 +08:00
|
|
|
env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files],
|
2021-02-03 04:20:18 +08:00
|
|
|
schema_files,
|
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 09:48:01 +08:00
|
|
|
# TODO: remove non shared cereal and messaging
|
2021-02-03 04:20:18 +08:00
|
|
|
cereal_objects = env.SharedObject([f'gen/cpp/{s}.c++' for s in schema_files])
|
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
|
|
|
|
|
2021-02-12 09:27:15 +08:00
|
|
|
services_h = env.Command(['services.h'], ['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',
|
2023-05-24 01:38:52 +08:00
|
|
|
'messaging/event.cc',
|
2019-11-21 01:44:47 +08:00
|
|
|
'messaging/impl_zmq.cc',
|
|
|
|
'messaging/impl_msgq.cc',
|
2023-05-24 01:38:52 +08:00
|
|
|
'messaging/impl_fake.cc',
|
2019-11-21 01:44:47 +08:00
|
|
|
'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
|
|
|
|
2021-07-29 16:32:29 +08:00
|
|
|
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq', common])
|
2019-12-04 01:46:14 +08:00
|
|
|
Depends('messaging/bridge.cc', services_h)
|
2019-11-21 01:44:47 +08:00
|
|
|
|
2021-07-29 16:32:29 +08:00
|
|
|
envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq", common])
|
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',
|
|
|
|
]
|
|
|
|
|
2022-04-20 01:58:17 +08:00
|
|
|
if arch == "larch64":
|
2021-01-08 21:54:41 +08:00
|
|
|
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)
|
|
|
|
|
2021-02-10 00:39:33 +08:00
|
|
|
|
2022-03-06 06:56:15 +08:00
|
|
|
vipc_frameworks = []
|
2022-03-07 18:50:17 +08:00
|
|
|
vipc_libs = envCython["LIBS"] + [vipc, messaging_lib, common, "zmq"]
|
2021-02-10 00:39:33 +08:00
|
|
|
if arch == "Darwin":
|
2022-03-06 06:56:15 +08:00
|
|
|
vipc_frameworks.append('OpenCL')
|
|
|
|
else:
|
|
|
|
vipc_libs.append('OpenCL')
|
|
|
|
envCython.Program('visionipc/visionipc_pyx.so', 'visionipc/visionipc_pyx.pyx',
|
|
|
|
LIBS=vipc_libs, FRAMEWORKS=vipc_frameworks)
|
2021-02-10 00:15:18 +08:00
|
|
|
|
2023-08-25 05:00:32 +08:00
|
|
|
if GetOption('extras'):
|
2021-07-29 16:32:29 +08:00
|
|
|
env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib, common])
|
2022-03-06 06:56:15 +08:00
|
|
|
|
|
|
|
env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'],
|
|
|
|
LIBS=['pthread'] + vipc_libs, FRAMEWORKS=vipc_frameworks)
|