From 80f03b618b283d41e716b30cbce28f98ad0943e1 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Fri, 20 May 2016 09:22:30 -0300 Subject: [PATCH] waf: toolchain: add find_toolchain_program() --- Tools/ardupilotwaf/toolchain.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tools/ardupilotwaf/toolchain.py b/Tools/ardupilotwaf/toolchain.py index b2764e9d9d..9b8c0a780c 100644 --- a/Tools/ardupilotwaf/toolchain.py +++ b/Tools/ardupilotwaf/toolchain.py @@ -13,10 +13,12 @@ Example:: """ 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 import os +import re def _set_toolchain_prefix_wrapper(tool_module, var, compiler_names): original_configure = tool_module.configure @@ -116,6 +118,20 @@ def _filter_supported_cxx_compilers(*compilers): l = compiler_cxx.cxx_compiler[k] compiler_cxx.cxx_compiler[k] = [c for c in l if c in compilers] +@conf +def find_toolchain_program(cfg, filename, **kw): + filename = Utils.to_list(filename) + + if not kw.get('var', ''): + # just copy from the original implementation + kw['var'] = re.sub(r'[-.]', '_', filename[0].upper()) + + if cfg.env.TOOLCHAIN != 'native': + for i, name in enumerate(filename): + filename[i] = '%s-%s' % (cfg.env.TOOLCHAIN, name) + + return cfg.find_program(filename, **kw) + def configure(cfg): if cfg.env.TOOLCHAIN == 'native': cfg.load('compiler_cxx compiler_c')