From c7cac9abae4930e24bbd4a612217c54cffd6ecc1 Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Fri, 10 Mar 2023 17:44:51 -0700 Subject: [PATCH] waf: Add building DDS client to waf * Had to ignore pre-commit hooks for isort and mypy since there are unrelated broken issues in the file Signed-off-by: Ryan Friedman Co-authored-by: Arsh Pratap Co-authored-by: Andrew Tridgell --- Tools/ardupilotwaf/ap_library.py | 5 +++++ Tools/ardupilotwaf/ardupilotwaf.py | 1 + Tools/ardupilotwaf/boards.py | 14 ++++++++++++++ wscript | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/Tools/ardupilotwaf/ap_library.py b/Tools/ardupilotwaf/ap_library.py index d8fdd4c05c..4ec6774d7b 100644 --- a/Tools/ardupilotwaf/ap_library.py +++ b/Tools/ardupilotwaf/ap_library.py @@ -118,6 +118,11 @@ def ap_library(bld, library, vehicle): for s in bld.env.AP_LIB_EXTRA_SOURCES[library]: src.append(bld.bldnode.find_or_declare(os.path.join('libraries', library, s))) + # include the dependencies for XRCE-DDS + if len(bld.env.XRCE_DEPENDENCIES): + for s in bld.env.XRCE_DEPENDENCIES: + src.append(bld.bldnode.find_or_declare(s)) + if not common_tg: kw = dict(bld.env.AP_LIBRARIES_OBJECTS_KW) kw['features'] = kw.get('features', []) + ['ap_library_object'] diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index 0f9fa3d46e..78ca6aab34 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -134,6 +134,7 @@ def get_legacy_defines(sketch_name, bld): IGNORED_AP_LIBRARIES = [ 'doc', 'AP_Scripting', # this gets explicitly included when it is needed and should otherwise never be globbed in + 'AP_DDS', ] diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index a4e30077fe..f39c31e3fa 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -75,6 +75,20 @@ class Board: if cfg.options.no_gcs: env.CXXFLAGS += ['-DHAL_GCS_ENABLED=0'] + # configurations for XRCE-DDS + if cfg.options.enable_dds: + cfg.recurse('libraries/AP_DDS') + env.ENABLE_DDS = True + env.AP_LIBRARIES += [ + 'AP_DDS' + ] + env.DEFINES.update(AP_DDS_ENABLED = 1) + # check for microxrceddsgen + cfg.find_program('microxrceddsgen',mandatory=True) + else: + env.ENABLE_DDS = False + env.DEFINES.update(AP_DDS_ENABLED = 0) + # setup for supporting onvif cam control if cfg.options.enable_onvif: cfg.recurse('libraries/AP_ONVIF') diff --git a/wscript b/wscript index 29b322ff48..a97013f7fa 100644 --- a/wscript +++ b/wscript @@ -251,6 +251,10 @@ submodules at specific revisions. default=False, help="Enables GPS logging") + g.add_option('--enable-dds', action='store_true', + help="Enable the dds client to connect with ROS2/DDS" + ) + g = opt.ap_groups['linux'] linux_options = ('--prefix', '--destdir', '--bindir', '--libdir') @@ -672,6 +676,9 @@ def _build_dynamic_sources(bld): ] ) + if bld.env.ENABLE_DDS: + bld.recurse("libraries/AP_DDS") + def write_version_header(tsk): bld = tsk.generator.bld return bld.write_version_header(tsk.outputs[0].abspath())