ardupilot/Tools/ardupilotwaf/toolchain.py

38 lines
867 B
Python

"""
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])