From 3ec938fae6e0aa90ad73e748f9a620349eb1cd85 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Mon, 24 Oct 2022 08:46:08 +0530 Subject: [PATCH] waf: add dynamic source option to ap_stlib --- Tools/AP_Bootloader/wscript | 19 ++++++------------- Tools/AP_Periph/wscript | 5 +++-- Tools/ardupilotwaf/ap_library.py | 8 ++++++++ wscript | 2 ++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Tools/AP_Bootloader/wscript b/Tools/AP_Bootloader/wscript index 73cd64f011..22887ea9d3 100644 --- a/Tools/AP_Bootloader/wscript +++ b/Tools/AP_Bootloader/wscript @@ -12,27 +12,20 @@ def build(bld): # build external libcanard library bld.stlib(source='../../modules/DroneCAN/libcanard/canard.c', + use='dronecan', target='libcanard') bld.ap_program( - use=['ap','libcanard','AP_Bootloader_libs'], - program_groups='bootloader', - includes=[bld.env.SRCROOT + '/modules/DroneCAN/libcanard', - bld.env.BUILDROOT + '/modules/DroneCAN/libcanard/dsdlc_generated'] - ) + use=['ap','libcanard','AP_Bootloader_libs', 'dronecan'], + program_groups='bootloader' + ) bld.ap_stlib( name= 'AP_Bootloader_libs', + use='dronecan', + dynamic_source='modules/DroneCAN/libcanard/dsdlc_generated/src/**.c', ap_vehicle='AP_Bootloader', ap_libraries= flashiface_lib + [ 'AP_Math', 'AP_CheckFirmware' ]) - - bld( - # build libcanard headers - source=bld.path.ant_glob("modules/DroneCAN/DSDL/**/*.uavcan"), - rule="python3 ${SRCROOT}/modules/DroneCAN/libcanard/dsdl_compiler/libcanard_dsdlc --header_only --outdir ${BUILDROOT}/modules/DroneCAN/libcanard/dsdlc_generated ${SRCROOT}/modules/DroneCAN/DSDL/uavcan ${SRCROOT}/modules/DroneCAN/DSDL/ardupilot ${SRCROOT}/modules/DroneCAN/DSDL/com ${SRCROOT}/modules/DroneCAN/DSDL/dronecan", - group='dynamic_sources', - ) - diff --git a/Tools/AP_Periph/wscript b/Tools/AP_Periph/wscript index cce626760f..bc8e2831f0 100644 --- a/Tools/AP_Periph/wscript +++ b/Tools/AP_Periph/wscript @@ -70,6 +70,7 @@ def build(bld): ] bld.ap_stlib( name= 'AP_Periph_libs', + dynamic_source='modules/DroneCAN/libcanard/dsdlc_generated/src/**.c', ap_vehicle='AP_Periph', ap_libraries= libraries, use='dronecan', @@ -79,8 +80,8 @@ def build(bld): ) # build external libcanard library - bld.stlib(source=['../../modules/DroneCAN/libcanard/canard.c'] + - bld.bldnode.ant_glob('modules/DroneCAN/libcanard/dsdlc_generated/src/**.c'), + bld.stlib(source='../../modules/DroneCAN/libcanard/canard.c', + name='libcanard', use='dronecan', target='libcanard') diff --git a/Tools/ardupilotwaf/ap_library.py b/Tools/ardupilotwaf/ap_library.py index dff91e2015..e6fe07f574 100644 --- a/Tools/ardupilotwaf/ap_library.py +++ b/Tools/ardupilotwaf/ap_library.py @@ -156,6 +156,14 @@ def process_ap_libraries(self): if vehicle: self.use.append(_vehicle_tgen_name(l, vehicle)) +@before_method('process_source') +@feature('cxxstlib') +def dynamic_post(self): + if not getattr(self, 'dynamic_source', None): + return + self.source = Utils.to_list(self.source) + self.source.extend(self.bld.bldnode.ant_glob(self.dynamic_source)) + class ap_library_check_headers(Task.Task): color = 'PINK' before = 'cxx c' diff --git a/wscript b/wscript index 5243bf7569..b72d2a6eb3 100644 --- a/wscript +++ b/wscript @@ -783,6 +783,8 @@ def build(bld): if bld.get_board().with_can: bld.env.AP_LIBRARIES_OBJECTS_KW['use'] += ['uavcan'] + if bld.env.AP_PERIPH: + bld.env.AP_LIBRARIES_OBJECTS_KW['use'] += ['dronecan'] _build_cmd_tweaks(bld)