@@ -5,6 +5,10 @@ import sysconfig
55import platform
66import shlex
77import numpy as np
8+ import opendbc
9+ import panda as _panda
10+ import rednose
11+ import msgq as _msgq
812
913import SCons .Errors
1014
@@ -65,7 +69,9 @@ env = Environment(
6569 CXXFLAGS = ["-std=c++1z" ],
6670 CPPPATH = [
6771 "#" ,
68- "#msgq" ,
72+ _msgq .INCLUDE_PATH ,
73+ _panda .INCLUDE_PATH ,
74+ rednose .BASEDIR ,
6975 "#third_party" ,
7076 "#third_party/json11" ,
7177 "#third_party/linux/include" ,
@@ -77,19 +83,18 @@ env = Environment(
7783 ],
7884 LIBPATH = [
7985 "#common" ,
80- "#msgq_repo" ,
8186 "#third_party" ,
8287 "#selfdrive/pandad" ,
83- "# rednose/helpers" ,
88+ rednose . HELPERS_PATH ,
8489 f"#third_party/libyuv/{ arch } /lib" ,
8590 f"#third_party/acados/{ arch } /lib" ,
8691 ],
8792 RPATH = [],
8893 CYTHONCFILESUFFIX = ".cpp" ,
8994 COMPILATIONDB_USE_ABSPATH = True ,
90- REDNOSE_ROOT = "#" ,
95+ REDNOSE_ROOT = rednose . INCLUDE_PATH ,
9196 tools = ["default" , "cython" , "compilation_db" , "rednose_filter" ],
92- toolpath = ["#site_scons/site_tools" , "#rednose_repo/site_scons/site_tools" ],
97+ toolpath = ["#site_scons/site_tools" , rednose . SITE_SCONS_TOOLS ],
9398)
9499
95100# Arch-specific flags and paths
@@ -182,21 +187,61 @@ Export('common')
182187# Enable swaglog include in submodules
183188env_swaglog = env .Clone ()
184189env_swaglog ['CXXFLAGS' ].append ('-DSWAGLOG="\\ "common/swaglog.h\\ ""' )
185- SConscript (['msgq_repo/SConscript' ], exports = {'env' : env_swaglog })
186- SConscript (['opendbc_repo/SConscript' ], exports = {'env' : env_swaglog })
190+
191+ # Build msgq from installed package
192+ msgq_dir = _msgq .BASEDIR
193+ vipc_dir = os .path .join (msgq_dir , 'visionipc' )
194+
195+ msgq_sources = [os .path .join (msgq_dir , f ) for f in
196+ ['ipc.cc' , 'event.cc' , 'impl_msgq.cc' , 'impl_fake.cc' , 'msgq.cc' ]]
197+ msgq_objects = env_swaglog .SharedObject (msgq_sources )
198+ msgq_lib = env .Library ('msgq' , msgq_objects )
199+ msgq_python = envCython .Program (os .path .join (msgq_dir , 'ipc_pyx.so' ),
200+ os .path .join (msgq_dir , 'ipc_pyx.pyx' ),
201+ LIBS = envCython ["LIBS" ]+ [msgq_lib , common ])
202+
203+ vipc_files = ['visionipc.cc' , 'visionipc_server.cc' , 'visionipc_client.cc' ]
204+ vipc_files += ['visionbuf_ion.cc' ] if arch == "larch64" else ['visionbuf.cc' ]
205+ vipc_sources = [os .path .join (vipc_dir , f ) for f in vipc_files ]
206+ vipc_objects = env .SharedObject (vipc_sources )
207+ visionipc = env .Library ('visionipc' , vipc_objects )
208+ envCython .Program (os .path .join (vipc_dir , 'visionipc_pyx.so' ),
209+ os .path .join (vipc_dir , 'visionipc_pyx.pyx' ),
210+ LIBS = envCython ["LIBS" ] + [visionipc , msgq_lib , common ])
211+ Export ('visionipc' , 'msgq_lib' , 'msgq_python' )
187212
188213SConscript (['cereal/SConscript' ])
189214
190- Import ('socketmaster' , 'msgq' )
191- messaging = [socketmaster , msgq , 'capnp' , 'kj' ,]
215+ Import ('socketmaster' )
216+ messaging = [socketmaster , msgq_lib , 'capnp' , 'kj' ,]
192217Export ('messaging' )
193218
194219
195- # Build other submodules
196- SConscript (['panda/SConscript' ])
197-
198220# Build rednose library
199- SConscript (['rednose/SConscript' ])
221+ Import ('_common' )
222+ rednose_helpers = rednose .HELPERS_PATH
223+ rednose_cc = [os .path .join (rednose_helpers , f ) for f in ['ekf_load.cc' , 'ekf_sym.cc' ]]
224+ ekf_objects = env .SharedObject (rednose_cc )
225+ rednose_lib = env .Library (os .path .join (rednose_helpers , 'ekf_sym' ), ekf_objects , LIBS = ['dl' , _common , 'zmq' ])
226+ rednose_python = envCython .Program (os .path .join (rednose_helpers , 'ekf_sym_pyx.so' ),
227+ [os .path .join (rednose_helpers , 'ekf_sym_pyx.pyx' ), ekf_objects ],
228+ LIBS = ['dl' ] + envCython ["LIBS" ])
229+ Export ('rednose_lib' , 'rednose_python' )
230+
231+ # Build opendbc libsafety for tests
232+ safety_dir = os .path .join (os .path .dirname (opendbc .__file__ ), 'safety' , 'tests' , 'libsafety' )
233+ if GetOption ('extras' ) and os .path .exists (os .path .join (safety_dir , 'safety.c' )):
234+ safety_env = Environment (
235+ CC = 'clang' ,
236+ CFLAGS = ['-Wall' , '-Wextra' , '-Werror' , '-nostdlib' , '-fno-builtin' , '-std=gnu11' ,
237+ '-Wfatal-errors' , '-Wno-pointer-to-int-cast' , '-g' , '-O0' ,
238+ '-fno-omit-frame-pointer' , '-grecord-command-line' , '-DALLOW_DEBUG' ],
239+ LINKFLAGS = ['-fsanitize=undefined' , '-fno-sanitize-recover=undefined' ],
240+ CPPPATH = [os .path .dirname (opendbc .__file__ ) + "/.." ],
241+ tools = ["default" ],
242+ )
243+ safety = safety_env .SharedObject (os .path .join (safety_dir , "safety.os" ), os .path .join (safety_dir , "safety.c" ))
244+ safety_env .SharedLibrary (os .path .join (safety_dir , "libsafety.so" ), [safety ])
200245
201246# Build system services
202247SConscript ([
0 commit comments