waf: add toolchain tool for cross-compiling

This commit is contained in:
Gustavo Jose de Sousa 2015-11-30 19:13:20 -02:00 committed by Lucas De Marchi
parent 7aa43d36d2
commit e7312a1f81
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,37 @@
"""
WAF Tool to select the correct toolchain based on the target archtecture.
This tool must be loaded before compiler tools. Use the environment variable
TOOLCHAIN to define the toolchain prefix.
Example::
def configure(cfg):
cfg.env.TOOLCHAIN = 'arm-linux-gnueabihf'
cfg.load('toolchain')
cfg.load('cxx_compiler')
"""
from waflib import Utils
suffixes = dict(
CXX='g++',
CC='gcc',
AS='gcc',
AR='ar',
LD='g++',
GDB='gdb',
OBJCOPY='objcopy',
)
def configure(cfg):
if not cfg.env.TOOLCHAIN:
cfg.env.TOOLCHAIN = 'native'
prefix = ''
else:
cfg.env.TOOLCHAIN = Utils.to_list(cfg.env.TOOLCHAIN)[0]
cfg.msg('Using toolchain prefix', cfg.env.TOOLCHAIN)
prefix = cfg.env.TOOLCHAIN + '-'
for k in suffixes:
cfg.env.append_value(k, prefix + suffixes[k])

View File

@ -74,6 +74,7 @@ def configure(cfg):
else:
cfg.env.prepend_value(k, val)
cfg.load('toolchain')
cfg.load('compiler_cxx compiler_c')
cfg.load('clang_compilation_database')
cfg.load('waf_unit_test')