diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 6f55302483..637c31c999 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -481,8 +481,6 @@ class linux(Board): def configure_env(self, cfg, env): super(linux, self).configure_env(cfg, env) - cfg.find_toolchain_program('pkg-config', var='PKGCONFIG') - env.DEFINES.update( CONFIG_HAL_BOARD = 'HAL_BOARD_LINUX', CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_NONE', diff --git a/Tools/ardupilotwaf/build_summary.py b/Tools/ardupilotwaf/build_summary.py index 5607d40d62..792d9a7a96 100644 --- a/Tools/ardupilotwaf/build_summary.py +++ b/Tools/ardupilotwaf/build_summary.py @@ -214,7 +214,12 @@ information about the first %d targets will be printed. ''' % MAX_TARGETS) def configure(cfg): - cfg.find_toolchain_program('size', mandatory=False) + size_name = 'size' + + if cfg.env.TOOLCHAIN != 'native': + size_name = cfg.env.TOOLCHAIN + '-' + size_name + + cfg.find_program(size_name, var='SIZE', mandatory=False) if not cfg.env.BUILD_SUMMARY_HEADER: cfg.env.BUILD_SUMMARY_HEADER = [ diff --git a/Tools/ardupilotwaf/toolchain.py b/Tools/ardupilotwaf/toolchain.py index a4e5ed0e1d..2d79c6aa7d 100644 --- a/Tools/ardupilotwaf/toolchain.py +++ b/Tools/ardupilotwaf/toolchain.py @@ -16,6 +16,7 @@ from waflib import Errors, Context, Utils from waflib.Configure import conf from waflib.Tools import compiler_c, compiler_cxx from waflib.Tools import clang, clangxx, gcc, gxx +from waflib.Tools import c_config from waflib import Logs import os @@ -112,19 +113,19 @@ def _filter_supported_cxx_compilers(*compilers): l = compiler_cxx.cxx_compiler[k] compiler_cxx.cxx_compiler[k] = [c for c in compilers if c in l] -@conf -def find_toolchain_program(cfg, filename, **kw): - filename = Utils.to_list(filename) +def _set_pkgconfig_crosscompilation_wrapper(cfg): + original_validatecfg = cfg.validate_cfg - if not kw.get('var', ''): - # just copy from the original implementation - kw['var'] = re.sub(r'[-.]', '_', filename[0].upper()) + @conf + def new_validate_cfg(kw): + if not 'path' in kw: + if not cfg.env.PKGCONFIG: + cfg.find_program('%s-pkg-config' % cfg.env.TOOLCHAIN, var='PKGCONFIG') + kw['path'] = cfg.env.PKGCONFIG - if cfg.env.TOOLCHAIN != 'native': - for i, name in enumerate(filename): - filename[i] = '%s-%s' % (cfg.env.TOOLCHAIN, name) + original_validatecfg(kw) - return cfg.find_program(filename, **kw) + cfg.validate_cfg = new_validate_cfg def configure(cfg): _filter_supported_c_compilers('gcc', 'clang') @@ -138,9 +139,10 @@ def configure(cfg): return - cfg.find_toolchain_program('ar') - cfg.msg('Using toolchain', cfg.env.TOOLCHAIN) + + _set_pkgconfig_crosscompilation_wrapper(cfg) + cfg.find_program('%s-ar' % cfg.env.TOOLCHAIN, var='AR', quiet=True) cfg.load('compiler_cxx compiler_c') if not cfg.options.disable_gccdeps: