mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
waf: add toolchain tool for cross-compiling
This commit is contained in:
parent
7aa43d36d2
commit
e7312a1f81
37
Tools/ardupilotwaf/toolchain.py
Normal file
37
Tools/ardupilotwaf/toolchain.py
Normal 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])
|
Loading…
Reference in New Issue
Block a user