waf: toolchain: add find_toolchain_program()

This commit is contained in:
Gustavo Jose de Sousa 2016-05-20 09:22:30 -03:00 committed by Lucas De Marchi
parent 06a515645e
commit 80f03b618b
1 changed files with 16 additions and 0 deletions

View File

@ -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')