mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 14:08:45 -04:00
waf: toolchain: override find_g{xx,cc}() instead of wrapping configure()
That's more correct than setting Waf environment variables: (1) We don't need to worry about differences between OSes - the previous implementation was actually broken for Windows because the program names in the environment variables were missing the ".exe" extension. (2) That looks better than looping over possible compiler names and running the configuration transactionally multiple times.
This commit is contained in:
parent
97613ef961
commit
f430ef3825
@ -20,30 +20,23 @@ 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
|
||||
def new_configure(cfg):
|
||||
if cfg.env.TOOLCHAIN == 'native':
|
||||
original_configure(cfg)
|
||||
return
|
||||
@conf
|
||||
def find_gxx(conf):
|
||||
names = ['g++', 'c++']
|
||||
if conf.env.TOOLCHAIN != 'native':
|
||||
names = ['%s-%s' % (conf.env.TOOLCHAIN, n) for n in names]
|
||||
cxx = conf.find_program(names, var='CXX')
|
||||
conf.get_cc_version(cxx, gcc=True)
|
||||
conf.env.CXX_NAME = 'gcc'
|
||||
|
||||
last_exception = None
|
||||
for name in compiler_names:
|
||||
cfg.env.stash()
|
||||
try:
|
||||
cfg.env[var] = '%s-%s' % (cfg.env.TOOLCHAIN, name)
|
||||
original_configure(cfg)
|
||||
except Errors.ConfigurationError as e:
|
||||
cfg.env.revert()
|
||||
last_exception = e
|
||||
else:
|
||||
cfg.env.commit()
|
||||
return
|
||||
raise last_exception
|
||||
tool_module.configure = new_configure
|
||||
|
||||
_set_toolchain_prefix_wrapper(gxx, 'CXX', ('g++', 'c++'))
|
||||
_set_toolchain_prefix_wrapper(gcc, 'CC', ('gcc', 'cc'))
|
||||
@conf
|
||||
def find_gcc(conf):
|
||||
names = ['gcc', 'cc']
|
||||
if conf.env.TOOLCHAIN != 'native':
|
||||
names = ['%s-%s' % (conf.env.TOOLCHAIN, n) for n in names]
|
||||
cc = conf.find_program(names, var='CC')
|
||||
conf.get_cc_version(cc, gcc=True)
|
||||
conf.env.CC_NAME = 'gcc'
|
||||
|
||||
def _clang_cross_support(cfg):
|
||||
if _clang_cross_support.called:
|
||||
|
Loading…
Reference in New Issue
Block a user