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