diff --git a/.gitignore b/.gitignore index a4b386d072b558..fde716ac78ef42 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ __pycache__ .*.swp .*.swo libcereal*.a -libmessaging.a +libmessaging.* services.h diff --git a/SConscript b/SConscript index 8971cf10918bac..dae850f9dc2d13 100644 --- a/SConscript +++ b/SConscript @@ -18,17 +18,29 @@ env.Library('cereal', [ 'gen/cpp/log.capnp.c++', ]) -env.Library('messaging', [ - 'messaging/messaging.cc', - 'messaging/impl_zmq.cc', - 'messaging/impl_msgq.cc', - 'messaging/msgq.cc', - ]) - -env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=['messaging', 'zmq']) - env.Command( ['services.h'], ['service_list.yaml', 'services.py'], 'python3 cereal/services.py > $TARGET') +messaging_deps = [ + 'messaging/messaging.cc', + 'messaging/impl_zmq.cc', + 'messaging/impl_msgq.cc', + 'messaging/msgq.cc', +] + +messaging_lib = env.Library('messaging', messaging_deps) + +# note, this rebuilds the deps shared +env.SharedLibrary('messaging', messaging_deps) + +env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=['messaging', 'zmq']) + +# different target? +#env.Program('messaging/demo', ['messaging/demo.cc'], LIBS=['messaging', 'zmq']) + +env.Command(['messaging/messaging_pyx.so'], + [messaging_lib, 'messaging/messaging_pyx_setup.py', 'messaging/messaging_pyx.pyx', 'messaging/messaging.pxd'], + "cd cereal/messaging && python3 messaging_pyx_setup.py build_ext --inplace") + diff --git a/messaging/.gitignore b/messaging/.gitignore index f35c26e8208ce5..0ddca76dd01300 100644 --- a/messaging/.gitignore +++ b/messaging/.gitignore @@ -2,6 +2,8 @@ demo bridge test_runner *.o +*.os *.d *.a *.so +messaging_pyx.cpp diff --git a/messaging/__init__.py b/messaging/__init__.py index 57b592dc2fe12b..9327f5079f8e08 100644 --- a/messaging/__init__.py +++ b/messaging/__init__.py @@ -1,8 +1,7 @@ import os import subprocess -can_dir = os.path.dirname(os.path.abspath(__file__)) -subprocess.check_call(["make", "-j3"], cwd=can_dir) +# must be build with scons from .messaging_pyx import Context, Poller, SubSocket, PubSocket # pylint: disable=no-name-in-module, import-error from cereal import log