waf: use ap_library tool

That way we avoid recompiling source files that don't depend on vehicles.
Change notes:
- UTILITY_SOURCE_EXTS: moved to ap_library
- Task generators indexes: ap_library handles that now and in a better way
- Use of AP_STLIB_FEATURES: it doesn't make sense anymore, since the stlib
  taskgen has empty source list
- Flags and defines: passed down to ap_library through AP_LIBRARIES_OBJECTS_KW
- Set use='mavlink' in AP_LIBRARIES_OBJECTS_KW instead of calls to
  bld.ap_stlib().
This commit is contained in:
Gustavo Jose de Sousa 2016-07-25 19:02:09 -03:00 committed by Lucas De Marchi
parent 9a6fcafade
commit b8e518a533
7 changed files with 12 additions and 38 deletions

View File

@ -21,7 +21,6 @@ def build(bld):
'AP_ServoRelayEvents', 'AP_ServoRelayEvents',
'PID', 'PID',
], ],
use='mavlink',
) )
bld.ap_program( bld.ap_program(

View File

@ -9,7 +9,6 @@ def build(bld):
ap_libraries=bld.ap_common_vehicle_libraries() + [ ap_libraries=bld.ap_common_vehicle_libraries() + [
'AC_PID', 'AC_PID',
], ],
use='mavlink',
) )
bld.ap_program( bld.ap_program(

View File

@ -30,7 +30,6 @@ def build(bld):
'AP_ServoRelayEvents', 'AP_ServoRelayEvents',
'AP_Avoidance', 'AP_Avoidance',
], ],
use='mavlink',
) )
frames = ( frames = (

View File

@ -31,7 +31,6 @@ def build(bld):
'AC_Fence', 'AC_Fence',
'AC_Avoidance' 'AC_Avoidance'
], ],
use='mavlink',
) )
bld.ap_program( bld.ap_program(

View File

@ -15,7 +15,6 @@ def build(bld):
ap_libraries=bld.ap_common_vehicle_libraries() + [ ap_libraries=bld.ap_common_vehicle_libraries() + [
'AP_InertialNav', 'AP_InertialNav',
], ],
use='mavlink',
) )
bld.ap_program( bld.ap_program(

View File

@ -15,8 +15,6 @@ SOURCE_EXTS = [
'*.cpp', '*.cpp',
] ]
UTILITY_SOURCE_EXTS = [ 'utility/' + glob for glob in SOURCE_EXTS ]
COMMON_VEHICLE_DEPENDENT_LIBRARIES = [ COMMON_VEHICLE_DEPENDENT_LIBRARIES = [
'AP_AccelCal', 'AP_AccelCal',
'AP_ADC', 'AP_ADC',
@ -147,17 +145,6 @@ def ap_example(bld, **kw):
kw['program_groups'] = 'examples' kw['program_groups'] = 'examples'
ap_program(bld, use_legacy_defines=False, **kw) ap_program(bld, use_legacy_defines=False, **kw)
# NOTE: Code in libraries/ is compiled multiple times. So ensure each
# compilation is independent by providing different index for each.
# The need for this should disappear when libraries change to be
# independent of vehicle type.
LAST_IDX = 0
def _get_next_idx():
global LAST_IDX
LAST_IDX += 1
return LAST_IDX
def unique_list(items): def unique_list(items):
'''remove duplicate elements from a list while maintaining ordering''' '''remove duplicate elements from a list while maintaining ordering'''
return list(OrderedDict.fromkeys(items)) return list(OrderedDict.fromkeys(items))
@ -171,22 +158,13 @@ def ap_stlib(bld, **kw):
if 'ap_libraries' not in kw: if 'ap_libraries' not in kw:
bld.fatal('Missing ap_libraries for ap_stlib') bld.fatal('Missing ap_libraries for ap_stlib')
sources = [] kw['ap_libraries'] = unique_list(kw['ap_libraries'] + bld.env.AP_LIBRARIES)
libraries = unique_list(kw['ap_libraries'] + bld.env.AP_LIBRARIES) for l in kw['ap_libraries']:
bld.ap_library(l, kw['ap_vehicle'])
for lib_name in libraries: kw['features'] = kw.get('features', []) + ['cxx', 'cxxstlib']
lib_node = bld.srcnode.find_dir('libraries/' + lib_name)
if lib_node is None:
bld.fatal('Could not find library ' + lib_name)
lib_sources = lib_node.ant_glob(SOURCE_EXTS + UTILITY_SOURCE_EXTS)
sources.extend(lib_sources)
kw['cxxflags'] = kw.get('cxxflags', []) + ['-include', 'ap_config.h']
kw['features'] = kw.get('features', []) + bld.env.AP_STLIB_FEATURES
kw['source'] = sources
kw['target'] = kw['name'] kw['target'] = kw['name']
kw['defines'] = get_legacy_defines(kw['ap_vehicle']) kw['source'] = []
kw['idx'] = _get_next_idx()
bld.stlib(**kw) bld.stlib(**kw)
@ -395,10 +373,5 @@ my board".
def build(bld): def build(bld):
global LAST_IDX
# FIXME: This is done to prevent same task generators being created with
# different idx when build() is called multiple times (e.g. waf bin tests).
# Ideally, task generators should be created just once.
LAST_IDX = 0
bld.add_pre_fun(_process_build_command) bld.add_pre_fun(_process_build_command)
bld.add_pre_fun(_select_programs_from_group) bld.add_pre_fun(_select_programs_from_group)

View File

@ -152,6 +152,8 @@ def configure(cfg):
cfg.msg('Using static linking', 'yes', color='YELLOW') cfg.msg('Using static linking', 'yes', color='YELLOW')
cfg.env.STATIC_LINKING = True cfg.env.STATIC_LINKING = True
cfg.load('ap_library')
cfg.msg('Setting board to', cfg.options.board) cfg.msg('Setting board to', cfg.options.board)
cfg.get_board().configure(cfg) cfg.get_board().configure(cfg)
@ -272,7 +274,6 @@ def _build_common_taskgens(bld):
name='ap', name='ap',
ap_vehicle='UNKNOWN', ap_vehicle='UNKNOWN',
ap_libraries=bld.ap_get_all_libraries(), ap_libraries=bld.ap_get_all_libraries(),
use='mavlink',
) )
if bld.env.HAS_GTEST: if bld.env.HAS_GTEST:
@ -344,6 +345,11 @@ def build(bld):
bld.load('ardupilotwaf') bld.load('ardupilotwaf')
bld.env.AP_LIBRARIES_OBJECTS_KW.update(
use='mavlink',
cxxflags=['-include', 'ap_config.h'],
)
_build_cmd_tweaks(bld) _build_cmd_tweaks(bld)
if bld.env.SUBMODULE_UPDATE: if bld.env.SUBMODULE_UPDATE: