mirror of https://github.com/ArduPilot/ardupilot
waf: add CANManager library and use uavcan agnostic names CAN vars
This commit is contained in:
parent
6fad42b6fd
commit
4e17f8a23e
|
@ -26,6 +26,7 @@ COMMON_VEHICLE_DEPENDENT_LIBRARIES = [
|
|||
'AP_BattMonitor',
|
||||
'AP_BoardConfig',
|
||||
'AP_Camera',
|
||||
'AP_CANManager',
|
||||
'AP_Common',
|
||||
'AP_Compass',
|
||||
'AP_Declination',
|
||||
|
|
|
@ -32,7 +32,7 @@ class Board:
|
|||
abstract = True
|
||||
|
||||
def __init__(self):
|
||||
self.with_uavcan = False
|
||||
self.with_can = False
|
||||
|
||||
def configure(self, cfg):
|
||||
cfg.env.TOOLCHAIN = cfg.options.toolchain or self.toolchain
|
||||
|
@ -61,7 +61,7 @@ class Board:
|
|||
]
|
||||
|
||||
else:
|
||||
cfg.options.disable_scripting = True;
|
||||
cfg.options.disable_scripting = True
|
||||
|
||||
d = env.get_merged_dict()
|
||||
# Always prepend so that arguments passed in the command line get
|
||||
|
@ -278,7 +278,7 @@ class Board:
|
|||
'-Wl,--gc-sections',
|
||||
]
|
||||
|
||||
if self.with_uavcan:
|
||||
if self.with_can:
|
||||
env.AP_LIBRARIES += [
|
||||
'AP_UAVCAN',
|
||||
'modules/uavcan/libuavcan/src/**/*.cpp'
|
||||
|
@ -381,15 +381,26 @@ Please use a replacement build as follows:
|
|||
# be worthy to keep board definitions in files of their own.
|
||||
|
||||
class sitl(Board):
|
||||
|
||||
def __init__(self):
|
||||
if Utils.unversioned_sys_platform().startswith("linux"):
|
||||
self.with_can = True
|
||||
else:
|
||||
self.with_can = False
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(sitl, self).configure_env(cfg, env)
|
||||
|
||||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD = 'HAL_BOARD_SITL',
|
||||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_NONE',
|
||||
AP_SCRIPTING_CHECKS = 1, # SITL should always do runtime scripting checks
|
||||
)
|
||||
|
||||
|
||||
if self.with_can:
|
||||
cfg.define('HAL_NUM_CAN_IFACES', 2)
|
||||
cfg.define('UAVCAN_EXCEPTIONS', 0)
|
||||
|
||||
env.CXXFLAGS += [
|
||||
'-Werror=float-equal'
|
||||
]
|
||||
|
@ -653,7 +664,7 @@ class linux(Board):
|
|||
'AP_HAL_Linux',
|
||||
]
|
||||
|
||||
if self.with_uavcan:
|
||||
if self.with_can:
|
||||
cfg.define('UAVCAN_EXCEPTIONS', 0)
|
||||
|
||||
if cfg.options.apstatedir:
|
||||
|
@ -710,7 +721,7 @@ class edge(linux):
|
|||
toolchain = 'arm-linux-gnueabihf'
|
||||
|
||||
def __init__(self):
|
||||
self.with_uavcan = True
|
||||
self.with_can = True
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(edge, self).configure_env(cfg, env)
|
||||
|
@ -743,7 +754,7 @@ class bbbmini(linux):
|
|||
toolchain = 'arm-linux-gnueabihf'
|
||||
|
||||
def __init__(self):
|
||||
self.with_uavcan = True
|
||||
self.with_can = True
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(bbbmini, self).configure_env(cfg, env)
|
||||
|
@ -756,7 +767,7 @@ class blue(linux):
|
|||
toolchain = 'arm-linux-gnueabihf'
|
||||
|
||||
def __init__(self):
|
||||
self.with_uavcan = True
|
||||
self.with_can = True
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(blue, self).configure_env(cfg, env)
|
||||
|
@ -769,7 +780,7 @@ class pocket(linux):
|
|||
toolchain = 'arm-linux-gnueabihf'
|
||||
|
||||
def __init__(self):
|
||||
self.with_uavcan = True
|
||||
self.with_can = True
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(pocket, self).configure_env(cfg, env)
|
||||
|
@ -850,7 +861,7 @@ class pxfmini(linux):
|
|||
|
||||
class aero(linux):
|
||||
def __init__(self):
|
||||
self.with_uavcan = True
|
||||
self.with_can = True
|
||||
|
||||
def configure_env(self, cfg, env):
|
||||
super(aero, self).configure_env(cfg, env)
|
||||
|
|
|
@ -244,13 +244,10 @@ def setup_can_build(cfg):
|
|||
'modules/uavcan/libuavcan/src/**/*.cpp',
|
||||
]
|
||||
|
||||
env.CFLAGS += ['-DUAVCAN_STM32_CHIBIOS=1',
|
||||
'-DUAVCAN_STM32_NUM_IFACES=2']
|
||||
env.CFLAGS += ['-DHAL_CAN_IFACES=2']
|
||||
|
||||
env.CXXFLAGS += [
|
||||
'-Wno-error=cast-align',
|
||||
'-DUAVCAN_STM32_CHIBIOS=1',
|
||||
'-DUAVCAN_STM32_NUM_IFACES=2'
|
||||
]
|
||||
|
||||
env.DEFINES += [
|
||||
|
@ -262,7 +259,7 @@ def setup_can_build(cfg):
|
|||
env.INCLUDES += [
|
||||
cfg.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath(),
|
||||
]
|
||||
cfg.get_board().with_uavcan = True
|
||||
cfg.get_board().with_can = True
|
||||
|
||||
def load_env_vars(env):
|
||||
'''optionally load extra environment variables from env.py in the build directory'''
|
||||
|
@ -359,7 +356,7 @@ def configure(cfg):
|
|||
if ret != 0:
|
||||
cfg.fatal("Failed to process hwdef.dat ret=%d" % ret)
|
||||
load_env_vars(cfg.env)
|
||||
if env.HAL_WITH_UAVCAN:
|
||||
if env.HAL_NUM_CAN_IFACES:
|
||||
setup_can_build(cfg)
|
||||
setup_optimization(cfg.env)
|
||||
|
||||
|
@ -384,8 +381,8 @@ def generate_hwdef_h(env):
|
|||
def pre_build(bld):
|
||||
'''pre-build hook to change dynamic sources'''
|
||||
load_env_vars(bld.env)
|
||||
if bld.env.HAL_WITH_UAVCAN:
|
||||
bld.get_board().with_uavcan = True
|
||||
if bld.env.HAL_NUM_CAN_IFACES:
|
||||
bld.get_board().with_can = True
|
||||
hwdef_h = os.path.join(bld.env.BUILDROOT, 'hwdef.h')
|
||||
if not os.path.exists(hwdef_h):
|
||||
print("Generating hwdef.h")
|
||||
|
|
4
wscript
4
wscript
|
@ -408,7 +408,7 @@ def _build_dynamic_sources(bld):
|
|||
],
|
||||
)
|
||||
|
||||
if bld.get_board().with_uavcan or bld.env.HAL_WITH_UAVCAN==True:
|
||||
if bld.get_board().with_can or bld.env.HAL_NUM_CAN_IFACES:
|
||||
bld(
|
||||
features='uavcangen',
|
||||
source=bld.srcnode.ant_glob('modules/uavcan/dsdl/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False),
|
||||
|
@ -537,7 +537,7 @@ def build(bld):
|
|||
|
||||
_load_pre_build(bld)
|
||||
|
||||
if bld.get_board().with_uavcan:
|
||||
if bld.get_board().with_can:
|
||||
bld.env.AP_LIBRARIES_OBJECTS_KW['use'] += ['uavcan']
|
||||
|
||||
_build_cmd_tweaks(bld)
|
||||
|
|
Loading…
Reference in New Issue