mirror of https://github.com/ArduPilot/ardupilot
waf: replace libuavcan with libcanard for vehicle builds
This commit is contained in:
parent
7067e9d917
commit
0e80802f69
|
@ -325,6 +325,9 @@ def ap_stlib(bld, **kw):
|
||||||
for l in kw['ap_libraries']:
|
for l in kw['ap_libraries']:
|
||||||
bld.ap_library(l, kw['ap_vehicle'])
|
bld.ap_library(l, kw['ap_vehicle'])
|
||||||
|
|
||||||
|
if 'dynamic_source' not in kw:
|
||||||
|
kw['dynamic_source'] = 'modules/DroneCAN/libcanard/dsdlc_generated/src/**.c'
|
||||||
|
|
||||||
kw['features'] = kw.get('features', []) + ['cxx', 'cxxstlib']
|
kw['features'] = kw.get('features', []) + ['cxx', 'cxxstlib']
|
||||||
kw['target'] = kw['name']
|
kw['target'] = kw['name']
|
||||||
kw['source'] = []
|
kw['source'] = []
|
||||||
|
|
|
@ -429,15 +429,26 @@ class Board:
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.with_can and not cfg.env.AP_PERIPH:
|
if self.with_can and not cfg.env.AP_PERIPH:
|
||||||
env.AP_LIBRARIES += [
|
if not cfg.env.SITL32BIT and cfg.env.BOARD == 'sitl':
|
||||||
'AP_UAVCAN',
|
env.DEFINES.update(
|
||||||
'modules/uavcan/libuavcan/src/**/*.cpp'
|
HAL_ENABLE_LIBUAVCAN_DRIVERS = 0
|
||||||
]
|
)
|
||||||
|
else:
|
||||||
|
env.AP_LIBRARIES += [
|
||||||
|
'AP_UAVCAN',
|
||||||
|
'modules/DroneCAN/libcanard/*.c',
|
||||||
|
]
|
||||||
|
if cfg.options.enable_dronecan_tests:
|
||||||
|
env.DEFINES.update(
|
||||||
|
AP_TEST_DRONECAN_DRIVERS = 1
|
||||||
|
)
|
||||||
|
|
||||||
env.DEFINES.update(
|
env.DEFINES.update(
|
||||||
UAVCAN_CPP_VERSION = 'UAVCAN_CPP03',
|
UAVCAN_CPP_VERSION = 'UAVCAN_CPP03',
|
||||||
UAVCAN_NO_ASSERTIONS = 1,
|
UAVCAN_NO_ASSERTIONS = 1,
|
||||||
UAVCAN_NULLPTR = 'nullptr'
|
UAVCAN_NULLPTR = 'nullptr',
|
||||||
|
DRONECAN_CXX_WRAPPERS = 1,
|
||||||
|
CANARD_ENABLE_DEADLINE = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -638,6 +649,9 @@ class sitl(Board):
|
||||||
cfg.define('HAL_NUM_CAN_IFACES', 2)
|
cfg.define('HAL_NUM_CAN_IFACES', 2)
|
||||||
cfg.define('UAVCAN_EXCEPTIONS', 0)
|
cfg.define('UAVCAN_EXCEPTIONS', 0)
|
||||||
cfg.define('UAVCAN_SUPPORT_CANFD', 1)
|
cfg.define('UAVCAN_SUPPORT_CANFD', 1)
|
||||||
|
env.DEFINES.update(CANARD_MULTI_IFACE=1,
|
||||||
|
CANARD_IFACE_ALL = 0x3,
|
||||||
|
CANARD_ENABLE_CANFD = 1)
|
||||||
|
|
||||||
env.CXXFLAGS += [
|
env.CXXFLAGS += [
|
||||||
'-Werror=float-equal'
|
'-Werror=float-equal'
|
||||||
|
@ -1069,16 +1083,13 @@ class chibios(Board):
|
||||||
('10','2','1'),
|
('10','2','1'),
|
||||||
]
|
]
|
||||||
|
|
||||||
if cfg.env.AP_PERIPH:
|
if cfg.env.HAL_CANFD_SUPPORTED:
|
||||||
if cfg.env.HAL_CANFD_SUPPORTED:
|
env.DEFINES.update(CANARD_ENABLE_CANFD=1)
|
||||||
env.DEFINES.update(CANARD_ENABLE_CANFD=1)
|
else:
|
||||||
else:
|
env.DEFINES.update(CANARD_ENABLE_TAO_OPTION=1)
|
||||||
env.DEFINES.update(CANARD_ENABLE_TAO_OPTION=1)
|
if not cfg.options.bootloader and cfg.env.HAL_NUM_CAN_IFACES:
|
||||||
if not cfg.options.bootloader:
|
if int(cfg.env.HAL_NUM_CAN_IFACES) >= 1:
|
||||||
if int(cfg.env.HAL_NUM_CAN_IFACES) > 1:
|
env.DEFINES.update(CANARD_IFACE_ALL=(1<<int(cfg.env.HAL_NUM_CAN_IFACES))-1)
|
||||||
env.DEFINES.update(CANARD_MULTI_IFACE=1)
|
|
||||||
else:
|
|
||||||
env.DEFINES.update(CANARD_MULTI_IFACE=0)
|
|
||||||
if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist:
|
if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist:
|
||||||
cfg.msg("Enabling -Werror", "yes")
|
cfg.msg("Enabling -Werror", "yes")
|
||||||
if '-Werror' not in env.CXXFLAGS:
|
if '-Werror' not in env.CXXFLAGS:
|
||||||
|
|
|
@ -443,9 +443,11 @@ def setup_canmgr_build(cfg):
|
||||||
env = cfg.env
|
env = cfg.env
|
||||||
env.AP_LIBRARIES += [
|
env.AP_LIBRARIES += [
|
||||||
'AP_UAVCAN',
|
'AP_UAVCAN',
|
||||||
'modules/uavcan/libuavcan/src/**/*.cpp',
|
'modules/DroneCAN/libcanard/*.c',
|
||||||
|
]
|
||||||
|
env.INCLUDES += [
|
||||||
|
cfg.srcnode.find_dir('modules/DroneCAN/libcanard').abspath(),
|
||||||
]
|
]
|
||||||
|
|
||||||
env.CFLAGS += ['-DHAL_CAN_IFACES=2']
|
env.CFLAGS += ['-DHAL_CAN_IFACES=2']
|
||||||
|
|
||||||
env.DEFINES += [
|
env.DEFINES += [
|
||||||
|
@ -453,6 +455,12 @@ def setup_canmgr_build(cfg):
|
||||||
'UAVCAN_NO_ASSERTIONS=1',
|
'UAVCAN_NO_ASSERTIONS=1',
|
||||||
'UAVCAN_NULLPTR=nullptr'
|
'UAVCAN_NULLPTR=nullptr'
|
||||||
]
|
]
|
||||||
|
if not env.AP_PERIPH:
|
||||||
|
env.DEFINES += [
|
||||||
|
'DRONECAN_CXX_WRAPPERS=1',
|
||||||
|
'CANARD_ENABLE_DEADLINE=1',
|
||||||
|
'CANARD_MULTI_IFACE=1'
|
||||||
|
]
|
||||||
|
|
||||||
if cfg.env.HAL_CANFD_SUPPORTED:
|
if cfg.env.HAL_CANFD_SUPPORTED:
|
||||||
env.DEFINES += ['UAVCAN_SUPPORT_CANFD=1']
|
env.DEFINES += ['UAVCAN_SUPPORT_CANFD=1']
|
||||||
|
|
|
@ -19,7 +19,7 @@ class dronecangen(Task.Task):
|
||||||
python = self.env.get_flat('PYTHON')
|
python = self.env.get_flat('PYTHON')
|
||||||
out = self.env.get_flat('OUTPUT_DIR')
|
out = self.env.get_flat('OUTPUT_DIR')
|
||||||
src = self.env.get_flat('SRC')
|
src = self.env.get_flat('SRC')
|
||||||
dsdlc = self.env.get_flat("DSDL_COMPILER")
|
dsdlc = self.env.get_flat("DC_DSDL_COMPILER")
|
||||||
|
|
||||||
ret = self.exec_command(['{}'.format(python),
|
ret = self.exec_command(['{}'.format(python),
|
||||||
'{}'.format(dsdlc),
|
'{}'.format(dsdlc),
|
||||||
|
@ -70,6 +70,6 @@ def configure(cfg):
|
||||||
cfg.check_python_version(minver=(2,7,0))
|
cfg.check_python_version(minver=(2,7,0))
|
||||||
|
|
||||||
env = cfg.env
|
env = cfg.env
|
||||||
env.DSDL_COMPILER_DIR = cfg.srcnode.make_node('modules/DroneCAN/dronecan_dsdlc/').abspath()
|
env.DC_DSDL_COMPILER_DIR = cfg.srcnode.make_node('modules/DroneCAN/dronecan_dsdlc/').abspath()
|
||||||
env.DSDL_COMPILER = env.DSDL_COMPILER_DIR + '/dronecan_dsdlc.py'
|
env.DC_DSDL_COMPILER = env.DC_DSDL_COMPILER_DIR + '/dronecan_dsdlc.py'
|
||||||
cfg.msg('DSDL compiler', env.DSDL_COMPILER)
|
cfg.msg('DC_DSDL compiler', env.DC_DSDL_COMPILER)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class uavcangen(Task.Task):
|
||||||
python = self.env.get_flat('PYTHON')
|
python = self.env.get_flat('PYTHON')
|
||||||
out = self.env.get_flat('OUTPUT_DIR')
|
out = self.env.get_flat('OUTPUT_DIR')
|
||||||
src = self.env.get_flat('SRC')
|
src = self.env.get_flat('SRC')
|
||||||
dsdlc = self.env.get_flat("DSDL_COMPILER")
|
dsdlc = self.env.get_flat("UC_DSDL_COMPILER")
|
||||||
|
|
||||||
ret = self.exec_command(['{}'.format(python),
|
ret = self.exec_command(['{}'.format(python),
|
||||||
'{}'.format(dsdlc),
|
'{}'.format(dsdlc),
|
||||||
|
@ -71,6 +71,6 @@ def configure(cfg):
|
||||||
cfg.check_python_version(minver=(2,7,0))
|
cfg.check_python_version(minver=(2,7,0))
|
||||||
|
|
||||||
env = cfg.env
|
env = cfg.env
|
||||||
env.DSDL_COMPILER_DIR = cfg.srcnode.make_node('modules/uavcan/libuavcan/dsdl_compiler').abspath()
|
env.UC_DSDL_COMPILER_DIR = cfg.srcnode.make_node('modules/uavcan/libuavcan/dsdl_compiler').abspath()
|
||||||
env.DSDL_COMPILER = env.DSDL_COMPILER_DIR + '/libuavcan_dsdlc'
|
env.UC_DSDL_COMPILER = env.UC_DSDL_COMPILER_DIR + '/libuavcan_dsdlc'
|
||||||
cfg.msg('DSDL compiler', env.DSDL_COMPILER)
|
cfg.msg('UC_DSDL compiler', env.UC_DSDL_COMPILER)
|
||||||
|
|
25
wscript
25
wscript
|
@ -13,6 +13,7 @@ sys.path.insert(0, 'Tools/ardupilotwaf/')
|
||||||
|
|
||||||
import ardupilotwaf
|
import ardupilotwaf
|
||||||
import boards
|
import boards
|
||||||
|
import shutil
|
||||||
|
|
||||||
from waflib import Build, ConfigSet, Configure, Context, Utils
|
from waflib import Build, ConfigSet, Configure, Context, Utils
|
||||||
from waflib.Configure import conf
|
from waflib.Configure import conf
|
||||||
|
@ -255,6 +256,9 @@ submodules at specific revisions.
|
||||||
help="Enable the dds client to connect with ROS2/DDS"
|
help="Enable the dds client to connect with ROS2/DDS"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
g.add_option('--enable-dronecan-tests', action='store_true',
|
||||||
|
default=False,
|
||||||
|
help="Enables DroneCAN tests in sitl")
|
||||||
g = opt.ap_groups['linux']
|
g = opt.ap_groups['linux']
|
||||||
|
|
||||||
linux_options = ('--prefix', '--destdir', '--bindir', '--libdir')
|
linux_options = ('--prefix', '--destdir', '--bindir', '--libdir')
|
||||||
|
@ -478,6 +482,8 @@ def configure(cfg):
|
||||||
cfg.load('dronecangen')
|
cfg.load('dronecangen')
|
||||||
else:
|
else:
|
||||||
cfg.load('uavcangen')
|
cfg.load('uavcangen')
|
||||||
|
if not (cfg.options.sitl_32bit and cfg.options.board != 'sitl'):
|
||||||
|
cfg.load('dronecangen')
|
||||||
|
|
||||||
cfg.env.SUBMODULE_UPDATE = cfg.options.submodule_update
|
cfg.env.SUBMODULE_UPDATE = cfg.options.submodule_update
|
||||||
|
|
||||||
|
@ -674,6 +680,23 @@ def _build_dynamic_sources(bld):
|
||||||
bld.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()
|
bld.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
if (not bld.env.SITL32BIT) and bld.env.BOARD == 'sitl':
|
||||||
|
# remove generated files
|
||||||
|
dronecan_dir = bld.bldnode.make_node('modules/DroneCAN/libcanard/dsdlc_generated/').abspath()
|
||||||
|
if os.path.exists(dronecan_dir):
|
||||||
|
print("Removing DroneCAN generated files")
|
||||||
|
shutil.rmtree(dronecan_dir)
|
||||||
|
else:
|
||||||
|
bld(
|
||||||
|
features='dronecangen',
|
||||||
|
source=bld.srcnode.ant_glob('modules/DroneCAN/DSDL/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False),
|
||||||
|
output_dir='modules/DroneCAN/libcanard/dsdlc_generated/',
|
||||||
|
name='dronecan',
|
||||||
|
export_includes=[
|
||||||
|
bld.bldnode.make_node('modules/DroneCAN/libcanard/dsdlc_generated/include').abspath(),
|
||||||
|
bld.srcnode.find_dir('modules/DroneCAN/libcanard/').abspath(),
|
||||||
|
]
|
||||||
|
)
|
||||||
elif bld.env.AP_PERIPH:
|
elif bld.env.AP_PERIPH:
|
||||||
bld(
|
bld(
|
||||||
features='dronecangen',
|
features='dronecangen',
|
||||||
|
@ -812,8 +835,6 @@ def build(bld):
|
||||||
_load_pre_build(bld)
|
_load_pre_build(bld)
|
||||||
|
|
||||||
if bld.get_board().with_can:
|
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']
|
bld.env.AP_LIBRARIES_OBJECTS_KW['use'] += ['dronecan']
|
||||||
|
|
||||||
_build_cmd_tweaks(bld)
|
_build_cmd_tweaks(bld)
|
||||||
|
|
Loading…
Reference in New Issue