2015-10-09 11:03:59 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2015-10-30 13:14:28 -03:00
|
|
|
from __future__ import print_function
|
2018-09-01 21:30:36 -03:00
|
|
|
from waflib import Build, ConfigSet, Configure, Context, Errors, Logs, Options, Utils
|
2016-01-21 09:30:22 -04:00
|
|
|
from waflib.Configure import conf
|
2018-09-01 21:30:36 -03:00
|
|
|
from waflib.Scripting import run_command
|
2016-05-25 14:19:44 -03:00
|
|
|
from waflib.TaskGen import before_method, feature
|
2016-05-05 19:16:23 -03:00
|
|
|
import os.path, os
|
2016-05-10 01:21:43 -03:00
|
|
|
from collections import OrderedDict
|
2015-10-30 12:50:44 -03:00
|
|
|
|
2016-08-23 14:49:51 -03:00
|
|
|
import ap_persistent
|
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
SOURCE_EXTS = [
|
|
|
|
'*.S',
|
|
|
|
'*.c',
|
|
|
|
'*.cpp',
|
|
|
|
]
|
|
|
|
|
|
|
|
COMMON_VEHICLE_DEPENDENT_LIBRARIES = [
|
2015-12-30 08:42:20 -04:00
|
|
|
'AP_AccelCal',
|
2015-10-09 11:03:59 -03:00
|
|
|
'AP_ADC',
|
|
|
|
'AP_AHRS',
|
|
|
|
'AP_Airspeed',
|
|
|
|
'AP_Baro',
|
|
|
|
'AP_BattMonitor',
|
|
|
|
'AP_BoardConfig',
|
2019-11-16 18:47:16 -04:00
|
|
|
'AP_Camera',
|
2020-05-31 08:50:44 -03:00
|
|
|
'AP_CANManager',
|
2015-10-09 11:03:59 -03:00
|
|
|
'AP_Common',
|
|
|
|
'AP_Compass',
|
|
|
|
'AP_Declination',
|
|
|
|
'AP_GPS',
|
|
|
|
'AP_HAL',
|
|
|
|
'AP_HAL_Empty',
|
|
|
|
'AP_InertialSensor',
|
|
|
|
'AP_Math',
|
|
|
|
'AP_Mission',
|
2020-11-05 19:36:51 -04:00
|
|
|
'AP_DAL',
|
2019-08-28 01:08:59 -03:00
|
|
|
'AP_NavEKF',
|
2015-10-09 11:03:59 -03:00
|
|
|
'AP_NavEKF2',
|
2016-07-14 02:08:43 -03:00
|
|
|
'AP_NavEKF3',
|
2015-10-09 11:03:59 -03:00
|
|
|
'AP_Notify',
|
|
|
|
'AP_OpticalFlow',
|
|
|
|
'AP_Param',
|
|
|
|
'AP_Rally',
|
|
|
|
'AP_RangeFinder',
|
|
|
|
'AP_Scheduler',
|
|
|
|
'AP_SerialManager',
|
|
|
|
'AP_Terrain',
|
|
|
|
'AP_Vehicle',
|
2019-03-18 08:26:39 -03:00
|
|
|
'AP_InternalError',
|
2019-01-18 00:23:19 -04:00
|
|
|
'AP_Logger',
|
2015-10-09 11:03:59 -03:00
|
|
|
'Filter',
|
|
|
|
'GCS_MAVLink',
|
|
|
|
'RC_Channel',
|
2017-01-06 02:16:00 -04:00
|
|
|
'SRV_Channel',
|
2015-10-09 11:03:59 -03:00
|
|
|
'StorageManager',
|
2016-05-06 07:38:20 -03:00
|
|
|
'AP_Tuning',
|
2016-05-09 23:20:44 -03:00
|
|
|
'AP_RPM',
|
2016-05-09 23:48:41 -03:00
|
|
|
'AP_RSSI',
|
|
|
|
'AP_Mount',
|
2016-07-12 23:49:00 -03:00
|
|
|
'AP_Module',
|
2016-07-21 21:27:39 -03:00
|
|
|
'AP_Button',
|
2016-07-23 04:37:04 -03:00
|
|
|
'AP_ICEngine',
|
2016-10-27 01:19:52 -03:00
|
|
|
'AP_Frsky_Telem',
|
2016-11-17 05:19:01 -04:00
|
|
|
'AP_FlashStorage',
|
2017-07-14 20:25:26 -03:00
|
|
|
'AP_Relay',
|
|
|
|
'AP_ServoRelayEvents',
|
2017-11-02 23:35:14 -03:00
|
|
|
'AP_Volz_Protocol',
|
2017-11-22 13:36:55 -04:00
|
|
|
'AP_SBusOut',
|
2018-01-05 03:14:11 -04:00
|
|
|
'AP_IOMCU',
|
2019-02-04 22:42:17 -04:00
|
|
|
'AP_Parachute',
|
2019-12-09 00:31:30 -04:00
|
|
|
'AP_PiccoloCAN',
|
|
|
|
'AP_PiccoloCAN/piccolo_protocol',
|
2018-01-05 03:14:11 -04:00
|
|
|
'AP_RAMTRON',
|
2018-01-17 18:53:08 -04:00
|
|
|
'AP_RCProtocol',
|
2018-01-05 04:56:49 -04:00
|
|
|
'AP_Radio',
|
2017-04-13 00:19:49 -03:00
|
|
|
'AP_TempCalibration',
|
2018-03-21 01:29:48 -03:00
|
|
|
'AP_VisualOdom',
|
2018-03-21 21:45:27 -03:00
|
|
|
'AP_BLHeli',
|
2018-04-14 05:30:54 -03:00
|
|
|
'AP_ROMFS',
|
2018-05-13 05:47:55 -03:00
|
|
|
'AP_Proximity',
|
2018-06-08 03:19:40 -03:00
|
|
|
'AP_Gripper',
|
2018-04-11 03:04:29 -03:00
|
|
|
'AP_RTC',
|
2018-06-08 01:41:42 -03:00
|
|
|
'AC_Sprayer',
|
2019-01-30 22:24:30 -04:00
|
|
|
'AC_Fence',
|
2018-10-26 02:39:00 -03:00
|
|
|
'AC_Avoidance',
|
2018-11-08 20:03:27 -04:00
|
|
|
'AP_LandingGear',
|
2018-12-18 23:28:04 -04:00
|
|
|
'AP_RobotisServo',
|
2018-11-12 06:31:16 -04:00
|
|
|
'AP_ToshibaCAN',
|
2019-03-04 14:30:38 -04:00
|
|
|
'AP_NMEA_Output',
|
2019-08-01 08:17:38 -03:00
|
|
|
'AP_Filesystem',
|
2019-10-02 08:52:08 -03:00
|
|
|
'AP_ADSB',
|
2019-11-02 00:11:23 -03:00
|
|
|
'AC_PID',
|
2019-10-30 07:14:17 -03:00
|
|
|
'AP_SerialLED',
|
2019-11-11 00:36:43 -04:00
|
|
|
'AP_EFI',
|
2020-01-02 23:55:52 -04:00
|
|
|
'AP_Hott_Telem',
|
2020-02-11 07:22:16 -04:00
|
|
|
'AP_ESC_Telem',
|
2020-01-03 06:14:53 -04:00
|
|
|
'AP_Stats',
|
2019-07-20 11:41:39 -03:00
|
|
|
'AP_GyroFFT',
|
2020-03-28 19:41:57 -03:00
|
|
|
'AP_RCTelemetry',
|
2019-11-06 20:33:12 -04:00
|
|
|
'AP_Generator',
|
2020-08-04 17:46:16 -03:00
|
|
|
'AP_MSP',
|
2020-08-20 02:24:57 -03:00
|
|
|
'AP_OLC',
|
2020-11-27 21:27:58 -04:00
|
|
|
'AP_WheelEncoder',
|
2020-12-27 22:05:42 -04:00
|
|
|
'AP_ExternalAHRS',
|
2015-10-09 11:03:59 -03:00
|
|
|
]
|
|
|
|
|
2016-07-25 17:38:38 -03:00
|
|
|
def get_legacy_defines(sketch_name):
|
2015-10-09 11:03:59 -03:00
|
|
|
return [
|
2016-01-22 16:21:09 -04:00
|
|
|
'APM_BUILD_DIRECTORY=APM_BUILD_' + sketch_name,
|
|
|
|
'SKETCH="' + sketch_name + '"',
|
|
|
|
'SKETCHNAME="' + sketch_name + '"',
|
2015-10-09 11:03:59 -03:00
|
|
|
]
|
|
|
|
|
|
|
|
IGNORED_AP_LIBRARIES = [
|
|
|
|
'doc',
|
2018-10-04 18:33:33 -03:00
|
|
|
'AP_Scripting', # this gets explicitly included when it is needed and should otherwise never be globbed in
|
2015-10-09 11:03:59 -03:00
|
|
|
]
|
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
|
|
|
|
def ap_autoconfigure(execute_method):
|
|
|
|
"""
|
|
|
|
Decorator that enables context commands to run *configure* as needed.
|
|
|
|
"""
|
|
|
|
def execute(self):
|
|
|
|
"""
|
|
|
|
Wraps :py:func:`waflib.Context.Context.execute` on the context class
|
|
|
|
"""
|
|
|
|
if not Configure.autoconfig:
|
|
|
|
return execute_method(self)
|
|
|
|
|
|
|
|
# Disable autoconfig so waf's version doesn't run (and don't end up on loop of bad configure)
|
|
|
|
Configure.autoconfig = False
|
|
|
|
|
|
|
|
if self.variant == '':
|
|
|
|
raise Errors.WafError('The project is badly configured: run "waf configure" again!')
|
|
|
|
|
|
|
|
env = ConfigSet.ConfigSet()
|
|
|
|
do_config = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
p = os.path.join(Context.out_dir, Build.CACHE_DIR, self.variant + Build.CACHE_SUFFIX)
|
|
|
|
env.load(p)
|
|
|
|
except EnvironmentError:
|
|
|
|
raise Errors.WafError('The project is not configured for board {0}: run "waf configure --board {0} [...]" first!'.format(self.variant))
|
|
|
|
|
|
|
|
lock_env = ConfigSet.ConfigSet()
|
|
|
|
|
|
|
|
try:
|
|
|
|
lock_env.load(os.path.join(Context.top_dir, Options.lockfile))
|
|
|
|
except EnvironmentError:
|
|
|
|
Logs.warn('Configuring the project')
|
|
|
|
do_config = True
|
|
|
|
else:
|
|
|
|
if lock_env.run_dir != Context.run_dir:
|
|
|
|
do_config = True
|
|
|
|
else:
|
|
|
|
h = 0
|
|
|
|
|
|
|
|
for f in env.CONFIGURE_FILES:
|
|
|
|
try:
|
|
|
|
h = Utils.h_list((h, Utils.readf(f, 'rb')))
|
|
|
|
except EnvironmentError:
|
|
|
|
do_config = True
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
do_config = h != env.CONFIGURE_HASH
|
|
|
|
|
|
|
|
if do_config:
|
|
|
|
cmd = lock_env.config_cmd or 'configure'
|
|
|
|
tmp = Options.options.__dict__
|
|
|
|
|
|
|
|
if env.OPTIONS and sorted(env.OPTIONS.keys()) == sorted(tmp.keys()):
|
|
|
|
Options.options.__dict__ = env.OPTIONS
|
|
|
|
else:
|
|
|
|
raise Errors.WafError('The project configure options have changed: run "waf configure" again!')
|
|
|
|
|
|
|
|
try:
|
|
|
|
run_command(cmd)
|
|
|
|
finally:
|
|
|
|
Options.options.__dict__ = tmp
|
|
|
|
|
|
|
|
run_command(self.cmd)
|
|
|
|
else:
|
|
|
|
return execute_method(self)
|
|
|
|
|
|
|
|
return execute
|
|
|
|
|
|
|
|
def ap_configure_post_recurse():
|
|
|
|
post_recurse_orig = Configure.ConfigurationContext.post_recurse
|
|
|
|
|
|
|
|
def post_recurse(self, node):
|
|
|
|
post_recurse_orig(self, node)
|
|
|
|
|
|
|
|
self.all_envs[self.variant].CONFIGURE_FILES = self.files
|
|
|
|
self.all_envs[self.variant].CONFIGURE_HASH = self.hash
|
|
|
|
|
|
|
|
return post_recurse
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-22 17:00:13 -04:00
|
|
|
def ap_get_all_libraries(bld):
|
2018-06-23 19:13:15 -03:00
|
|
|
if bld.env.BOOTLOADER:
|
|
|
|
# we don't need the full set of libraries for the bootloader build
|
|
|
|
return ['AP_HAL']
|
2015-10-09 11:03:59 -03:00
|
|
|
libraries = []
|
2016-05-12 10:48:00 -03:00
|
|
|
for lib_node in bld.srcnode.ant_glob('libraries/*', dir=True, src=False):
|
2015-10-09 11:03:59 -03:00
|
|
|
name = lib_node.name
|
|
|
|
if name in IGNORED_AP_LIBRARIES:
|
|
|
|
continue
|
|
|
|
if name.startswith('AP_HAL'):
|
|
|
|
continue
|
2016-02-24 14:35:46 -04:00
|
|
|
if name == 'SITL':
|
|
|
|
continue
|
2015-10-09 11:03:59 -03:00
|
|
|
libraries.append(name)
|
|
|
|
libraries.extend(['AP_HAL', 'AP_HAL_Empty'])
|
|
|
|
return libraries
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-22 17:00:13 -04:00
|
|
|
def ap_common_vehicle_libraries(bld):
|
2017-08-09 19:57:05 -03:00
|
|
|
libraries = COMMON_VEHICLE_DEPENDENT_LIBRARIES
|
|
|
|
|
|
|
|
if bld.env.DEST_BINFMT == 'pe':
|
|
|
|
libraries += [
|
|
|
|
'AC_Fence',
|
2018-12-14 08:28:47 -04:00
|
|
|
'AC_AttitudeControl',
|
2017-08-09 19:57:05 -03:00
|
|
|
]
|
|
|
|
|
|
|
|
return libraries
|
2016-01-21 09:30:22 -04:00
|
|
|
|
2016-01-22 08:26:08 -04:00
|
|
|
_grouped_programs = {}
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-03-24 16:47:30 -03:00
|
|
|
def ap_program(bld,
|
2016-03-24 16:58:15 -03:00
|
|
|
program_groups='bin',
|
2016-03-24 16:47:30 -03:00
|
|
|
program_dir=None,
|
|
|
|
use_legacy_defines=True,
|
|
|
|
program_name=None,
|
|
|
|
**kw):
|
2015-10-09 11:03:59 -03:00
|
|
|
if 'target' in kw:
|
|
|
|
bld.fatal('Do not pass target for program')
|
|
|
|
if 'defines' not in kw:
|
|
|
|
kw['defines'] = []
|
|
|
|
if 'source' not in kw:
|
|
|
|
kw['source'] = bld.path.ant_glob(SOURCE_EXTS)
|
|
|
|
|
2016-01-11 16:23:59 -04:00
|
|
|
if not program_name:
|
|
|
|
program_name = bld.path.name
|
2016-01-08 17:28:04 -04:00
|
|
|
|
|
|
|
if use_legacy_defines:
|
2016-07-25 17:38:38 -03:00
|
|
|
kw['defines'].extend(get_legacy_defines(bld.path.name))
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-03-02 17:08:39 -04:00
|
|
|
kw['features'] = kw.get('features', []) + bld.env.AP_PROGRAM_FEATURES
|
2016-03-02 17:20:45 -04:00
|
|
|
|
2016-03-24 16:58:15 -03:00
|
|
|
program_groups = Utils.to_list(program_groups)
|
|
|
|
|
2016-03-24 16:47:30 -03:00
|
|
|
if not program_dir:
|
2016-03-24 16:58:15 -03:00
|
|
|
program_dir = program_groups[0]
|
2016-03-24 16:47:30 -03:00
|
|
|
|
|
|
|
name = os.path.join(program_dir, program_name)
|
2016-01-11 17:47:40 -04:00
|
|
|
|
2016-02-25 08:50:41 -04:00
|
|
|
tg_constructor = bld.program
|
|
|
|
if bld.env.AP_PROGRAM_AS_STLIB:
|
|
|
|
tg_constructor = bld.stlib
|
|
|
|
else:
|
|
|
|
if bld.env.STATIC_LINKING:
|
|
|
|
kw['features'].append('static_linking')
|
|
|
|
|
|
|
|
|
|
|
|
tg = tg_constructor(
|
2016-02-26 15:29:34 -04:00
|
|
|
target='#%s' % name,
|
2016-01-16 22:33:00 -04:00
|
|
|
name=name,
|
2016-02-25 09:04:46 -04:00
|
|
|
program_name=program_name,
|
2016-03-24 16:47:30 -03:00
|
|
|
program_dir=program_dir,
|
2015-10-09 11:03:59 -03:00
|
|
|
**kw
|
|
|
|
)
|
2018-12-30 20:55:27 -04:00
|
|
|
if 'use' in kw and bld.env.STATIC_LINKING:
|
|
|
|
# ensure we link against vehicle library
|
|
|
|
tg.env.STLIB += [kw['use']]
|
2016-03-24 16:58:15 -03:00
|
|
|
|
|
|
|
for group in program_groups:
|
|
|
|
_grouped_programs.setdefault(group, []).append(tg)
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-22 17:00:13 -04:00
|
|
|
def ap_example(bld, **kw):
|
2016-03-24 16:58:15 -03:00
|
|
|
kw['program_groups'] = 'examples'
|
2016-05-03 22:07:05 -03:00
|
|
|
ap_program(bld, use_legacy_defines=False, **kw)
|
2016-01-08 16:47:35 -04:00
|
|
|
|
2016-05-10 01:21:43 -03:00
|
|
|
def unique_list(items):
|
|
|
|
'''remove duplicate elements from a list while maintaining ordering'''
|
|
|
|
return list(OrderedDict.fromkeys(items))
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-21 08:53:08 -04:00
|
|
|
def ap_stlib(bld, **kw):
|
2015-10-09 11:03:59 -03:00
|
|
|
if 'name' not in kw:
|
2016-01-21 08:53:08 -04:00
|
|
|
bld.fatal('Missing name for ap_stlib')
|
2016-07-25 17:31:08 -03:00
|
|
|
if 'ap_vehicle' not in kw:
|
|
|
|
bld.fatal('Missing ap_vehicle for ap_stlib')
|
|
|
|
if 'ap_libraries' not in kw:
|
|
|
|
bld.fatal('Missing ap_libraries for ap_stlib')
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-07-25 19:02:09 -03:00
|
|
|
kw['ap_libraries'] = unique_list(kw['ap_libraries'] + bld.env.AP_LIBRARIES)
|
|
|
|
for l in kw['ap_libraries']:
|
|
|
|
bld.ap_library(l, kw['ap_vehicle'])
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-07-25 19:02:09 -03:00
|
|
|
kw['features'] = kw.get('features', []) + ['cxx', 'cxxstlib']
|
2016-01-13 16:29:22 -04:00
|
|
|
kw['target'] = kw['name']
|
2016-07-25 19:02:09 -03:00
|
|
|
kw['source'] = []
|
2016-01-13 16:29:22 -04:00
|
|
|
|
|
|
|
bld.stlib(**kw)
|
2015-10-30 12:50:44 -03:00
|
|
|
|
2016-05-25 14:19:44 -03:00
|
|
|
_created_program_dirs = set()
|
|
|
|
@feature('cxxstlib', 'cxxprogram')
|
|
|
|
@before_method('process_rule')
|
|
|
|
def ap_create_program_dir(self):
|
|
|
|
if not hasattr(self, 'program_dir'):
|
|
|
|
return
|
|
|
|
if self.program_dir in _created_program_dirs:
|
|
|
|
return
|
|
|
|
self.bld.bldnode.make_node(self.program_dir).mkdir()
|
|
|
|
_created_program_dirs.add(self.program_dir)
|
|
|
|
|
2016-05-20 16:44:41 -03:00
|
|
|
@feature('cxxstlib')
|
|
|
|
@before_method('process_rule')
|
|
|
|
def ap_stlib_target(self):
|
|
|
|
if self.target.startswith('#'):
|
|
|
|
self.target = self.target[1:]
|
|
|
|
self.target = '#%s' % os.path.join('lib', self.target)
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-22 17:00:13 -04:00
|
|
|
def ap_find_tests(bld, use=[]):
|
2015-10-30 13:14:28 -03:00
|
|
|
if not bld.env.HAS_GTEST:
|
|
|
|
return
|
|
|
|
|
2016-03-02 17:16:14 -04:00
|
|
|
features = []
|
2015-10-30 12:50:44 -03:00
|
|
|
if bld.cmd == 'check':
|
2016-01-07 07:16:53 -04:00
|
|
|
features.append('test')
|
2015-10-30 12:50:44 -03:00
|
|
|
|
2015-10-30 13:14:28 -03:00
|
|
|
use = Utils.to_list(use)
|
|
|
|
use.append('GTEST')
|
|
|
|
|
|
|
|
includes = [bld.srcnode.abspath() + '/tests/']
|
|
|
|
|
2015-10-30 12:50:44 -03:00
|
|
|
for f in bld.path.ant_glob(incl='*.cpp'):
|
2016-01-21 08:10:44 -04:00
|
|
|
ap_program(
|
2016-01-11 08:19:29 -04:00
|
|
|
bld,
|
2015-10-30 12:50:44 -03:00
|
|
|
features=features,
|
2015-10-30 13:14:28 -03:00
|
|
|
includes=includes,
|
2015-10-30 12:50:44 -03:00
|
|
|
source=[f],
|
|
|
|
use=use,
|
2016-01-11 09:21:57 -04:00
|
|
|
program_name=f.change_ext('').name,
|
2016-03-24 16:58:15 -03:00
|
|
|
program_groups='tests',
|
2016-01-11 08:19:29 -04:00
|
|
|
use_legacy_defines=False,
|
2016-02-18 10:45:21 -04:00
|
|
|
cxxflags=['-Wno-undef'],
|
2015-10-30 12:50:44 -03:00
|
|
|
)
|
|
|
|
|
2016-05-05 19:16:23 -03:00
|
|
|
_versions = []
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def ap_version_append_str(ctx, k, v):
|
|
|
|
ctx.env['AP_VERSION_ITEMS'] += [(k, '"{}"'.format(os.environ.get(k, v)))]
|
|
|
|
|
2018-01-05 03:26:06 -04:00
|
|
|
@conf
|
|
|
|
def ap_version_append_int(ctx, k, v):
|
|
|
|
ctx.env['AP_VERSION_ITEMS'] += [(k,v)]
|
|
|
|
|
2016-05-05 19:16:23 -03:00
|
|
|
@conf
|
|
|
|
def write_version_header(ctx, tgt):
|
|
|
|
with open(tgt, 'w') as f:
|
2017-09-12 15:33:50 -03:00
|
|
|
print(
|
|
|
|
'''// auto-generated header, do not edit
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef FORCE_VERSION_H_INCLUDE
|
|
|
|
#error ap_version.h should never be included directly. You probably want to include AP_Common/AP_FWVersion.h
|
|
|
|
#endif
|
|
|
|
''', file=f)
|
2016-05-05 19:16:23 -03:00
|
|
|
|
|
|
|
for k, v in ctx.env['AP_VERSION_ITEMS']:
|
|
|
|
print('#define {} {}'.format(k, v), file=f)
|
|
|
|
|
2016-01-21 09:30:22 -04:00
|
|
|
@conf
|
2016-01-22 17:00:13 -04:00
|
|
|
def ap_find_benchmarks(bld, use=[]):
|
2015-11-12 17:39:30 -04:00
|
|
|
if not bld.env.HAS_GBENCHMARK:
|
|
|
|
return
|
|
|
|
|
|
|
|
includes = [bld.srcnode.abspath() + '/benchmarks/']
|
2020-09-03 04:46:18 -03:00
|
|
|
to_remove = '-Werror=suggest-override'
|
|
|
|
if to_remove in bld.env.CXXFLAGS:
|
|
|
|
need_remove = True
|
|
|
|
else:
|
|
|
|
need_remove = False
|
|
|
|
if need_remove:
|
|
|
|
while to_remove in bld.env.CXXFLAGS:
|
|
|
|
bld.env.CXXFLAGS.remove(to_remove)
|
2015-11-12 17:39:30 -04:00
|
|
|
|
|
|
|
for f in bld.path.ant_glob(incl='*.cpp'):
|
2016-01-21 08:10:44 -04:00
|
|
|
ap_program(
|
2016-01-11 08:19:29 -04:00
|
|
|
bld,
|
2016-03-02 17:16:14 -04:00
|
|
|
features=['gbenchmark'],
|
2015-11-12 17:39:30 -04:00
|
|
|
includes=includes,
|
|
|
|
source=[f],
|
|
|
|
use=use,
|
2016-01-11 09:21:57 -04:00
|
|
|
program_name=f.change_ext('').name,
|
2016-03-24 16:58:15 -03:00
|
|
|
program_groups='benchmarks',
|
2016-01-11 08:19:29 -04:00
|
|
|
use_legacy_defines=False,
|
2015-11-12 17:39:30 -04:00
|
|
|
)
|
|
|
|
|
2015-10-30 12:50:44 -03:00
|
|
|
def test_summary(bld):
|
|
|
|
from io import BytesIO
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if not hasattr(bld, 'utest_results'):
|
|
|
|
Logs.info('check: no test run')
|
|
|
|
return
|
|
|
|
|
|
|
|
fails = []
|
|
|
|
|
|
|
|
for filename, exit_code, out, err in bld.utest_results:
|
|
|
|
Logs.pprint('GREEN' if exit_code == 0 else 'YELLOW',
|
|
|
|
' %s' % filename,
|
|
|
|
'returned %d' % exit_code)
|
|
|
|
|
|
|
|
if exit_code != 0:
|
|
|
|
fails.append(filename)
|
|
|
|
elif not bld.options.check_verbose:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if len(out):
|
|
|
|
buf = BytesIO(out)
|
|
|
|
for line in buf:
|
|
|
|
print(" OUT: %s" % line.decode(), end='', file=sys.stderr)
|
|
|
|
print()
|
|
|
|
|
|
|
|
if len(err):
|
|
|
|
buf = BytesIO(err)
|
|
|
|
for line in buf:
|
|
|
|
print(" ERR: %s" % line.decode(), end='', file=sys.stderr)
|
|
|
|
print()
|
|
|
|
|
|
|
|
if not fails:
|
|
|
|
Logs.info('check: All %u tests passed!' % len(bld.utest_results))
|
|
|
|
return
|
|
|
|
|
|
|
|
Logs.error('check: %u of %u tests failed' %
|
|
|
|
(len(fails), len(bld.utest_results)))
|
|
|
|
|
|
|
|
for filename in fails:
|
|
|
|
Logs.error(' %s' % filename)
|
2016-01-15 12:02:21 -04:00
|
|
|
|
2016-01-18 13:57:32 -04:00
|
|
|
bld.fatal('check: some tests failed')
|
|
|
|
|
2016-01-27 12:16:37 -04:00
|
|
|
_build_commands = {}
|
2016-01-15 12:02:21 -04:00
|
|
|
|
2016-01-27 12:16:37 -04:00
|
|
|
def _process_build_command(bld):
|
|
|
|
if bld.cmd not in _build_commands:
|
2016-01-27 08:22:24 -04:00
|
|
|
return
|
|
|
|
|
2016-01-27 12:16:37 -04:00
|
|
|
params = _build_commands[bld.cmd]
|
2016-01-27 08:22:24 -04:00
|
|
|
|
|
|
|
targets = params['targets']
|
|
|
|
if targets:
|
|
|
|
if bld.targets:
|
|
|
|
bld.targets += ',' + targets
|
|
|
|
else:
|
|
|
|
bld.targets = targets
|
|
|
|
|
2016-01-27 08:56:30 -04:00
|
|
|
program_group_list = Utils.to_list(params['program_group_list'])
|
|
|
|
bld.options.program_group.extend(program_group_list)
|
|
|
|
|
2016-01-27 12:16:37 -04:00
|
|
|
def build_command(name,
|
2016-01-27 11:45:46 -04:00
|
|
|
targets=None,
|
|
|
|
program_group_list=[],
|
|
|
|
doc='build shortcut'):
|
2016-01-27 12:16:37 -04:00
|
|
|
_build_commands[name] = dict(
|
2016-01-27 08:22:24 -04:00
|
|
|
targets=targets,
|
2016-01-27 08:56:30 -04:00
|
|
|
program_group_list=program_group_list,
|
2016-01-27 08:22:24 -04:00
|
|
|
)
|
2016-01-15 12:02:21 -04:00
|
|
|
|
2016-08-22 17:28:49 -03:00
|
|
|
class context_class(Build.BuildContext):
|
2016-01-27 08:22:24 -04:00
|
|
|
cmd = name
|
2016-01-27 11:45:46 -04:00
|
|
|
context_class.__doc__ = doc
|
2016-01-22 08:26:08 -04:00
|
|
|
|
|
|
|
def _select_programs_from_group(bld):
|
|
|
|
groups = bld.options.program_group
|
|
|
|
if not groups:
|
|
|
|
if bld.targets:
|
|
|
|
groups = []
|
|
|
|
else:
|
|
|
|
groups = ['bin']
|
|
|
|
|
|
|
|
if 'all' in groups:
|
|
|
|
groups = _grouped_programs.keys()
|
|
|
|
|
|
|
|
for group in groups:
|
|
|
|
if group not in _grouped_programs:
|
|
|
|
bld.fatal('Group %s not found' % group)
|
|
|
|
|
|
|
|
tg = _grouped_programs[group][0]
|
|
|
|
if bld.targets:
|
|
|
|
bld.targets += ',' + tg.name
|
|
|
|
else:
|
|
|
|
bld.targets = tg.name
|
|
|
|
|
|
|
|
for tg in _grouped_programs[group][1:]:
|
|
|
|
bld.targets += ',' + tg.name
|
|
|
|
|
|
|
|
def options(opt):
|
2016-08-22 16:33:18 -03:00
|
|
|
opt.ap_groups = {
|
|
|
|
'configure': opt.add_option_group('Ardupilot configure options'),
|
2018-03-27 04:16:30 -03:00
|
|
|
'linux': opt.add_option_group('Linux boards configure options'),
|
2016-08-22 16:33:18 -03:00
|
|
|
'build': opt.add_option_group('Ardupilot build options'),
|
|
|
|
'check': opt.add_option_group('Ardupilot check options'),
|
2016-08-22 17:47:03 -03:00
|
|
|
'clean': opt.add_option_group('Ardupilot clean options'),
|
2016-08-22 16:33:18 -03:00
|
|
|
}
|
|
|
|
|
2016-02-17 08:48:08 -04:00
|
|
|
g = opt.ap_groups['build']
|
2016-05-23 10:48:39 -03:00
|
|
|
|
2016-01-22 08:26:08 -04:00
|
|
|
g.add_option('--program-group',
|
|
|
|
action='append',
|
|
|
|
default=[],
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Select all programs that go in <PROGRAM_GROUP>/ for the build.
|
|
|
|
Example: `waf --program-group examples` builds all examples. The
|
|
|
|
special group "all" selects all programs.
|
2016-05-23 10:48:39 -03:00
|
|
|
''')
|
2016-01-22 08:26:08 -04:00
|
|
|
|
2016-03-02 18:09:58 -04:00
|
|
|
g.add_option('--upload',
|
|
|
|
action='store_true',
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Upload applicable targets to a connected device. Not all
|
|
|
|
platforms may support this. Example: `waf copter --upload` means "build
|
|
|
|
arducopter and upload it to my board".
|
2016-05-23 10:48:39 -03:00
|
|
|
''')
|
2016-03-02 18:09:58 -04:00
|
|
|
|
2019-09-25 08:32:32 -03:00
|
|
|
g.add_option('--upload-port',
|
|
|
|
action='store',
|
|
|
|
dest='upload_port',
|
|
|
|
default=None,
|
|
|
|
help='''Specify the port to be used with the --upload option. For example a port of /dev/ttyS10 indicates that serial port 10 shuld be used.
|
|
|
|
''')
|
|
|
|
|
2016-02-17 08:55:59 -04:00
|
|
|
g = opt.ap_groups['check']
|
2016-05-23 10:48:39 -03:00
|
|
|
|
2016-02-17 08:55:59 -04:00
|
|
|
g.add_option('--check-verbose',
|
2016-05-23 10:48:39 -03:00
|
|
|
action='store_true',
|
|
|
|
help='Output all test programs.')
|
2016-02-17 08:55:59 -04:00
|
|
|
|
2016-08-22 17:47:03 -03:00
|
|
|
g = opt.ap_groups['clean']
|
|
|
|
|
|
|
|
g.add_option('--clean-all-sigs',
|
|
|
|
action='store_true',
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Clean signatures for all tasks. By default, tasks that scan for
|
|
|
|
implicit dependencies (like the compilation tasks) keep the dependency
|
|
|
|
information across clean commands, so that that information is changed
|
|
|
|
only when really necessary. Also, some tasks that don't really produce
|
|
|
|
files persist their signature. This option avoids that behavior when
|
|
|
|
cleaning the build.
|
2020-04-14 07:45:40 -03:00
|
|
|
''')
|
|
|
|
|
|
|
|
g.add_option('--asan',
|
|
|
|
action='store_true',
|
|
|
|
help='''Build using the macOS clang Address Sanitizer. In order to run with
|
|
|
|
Address Sanitizer support llvm-symbolizer is required to be on the PATH.
|
|
|
|
This option is only supported on macOS versions of clang.
|
2016-08-22 17:47:03 -03:00
|
|
|
''')
|
|
|
|
|
2016-01-22 08:26:08 -04:00
|
|
|
def build(bld):
|
2016-01-27 12:16:37 -04:00
|
|
|
bld.add_pre_fun(_process_build_command)
|
2016-01-22 08:26:08 -04:00
|
|
|
bld.add_pre_fun(_select_programs_from_group)
|