Support passing of options to compilers and linkers

If you pass options, the last element in the array won't be the
compiler basename, so just check if the basename is in the exelist
somewhere.

Includes a test.
pull/1408/head
Nirbheek Chauhan 8 years ago
parent 003e0a0610
commit 69e83d6aed
  1. 6
      mesonbuild/environment.py
  2. 8
      run_unittests.py

@ -407,8 +407,7 @@ class Environment:
if isinstance(compiler, str):
compiler = [compiler]
try:
basename = os.path.basename(compiler[-1]).lower()
if basename == 'cl' or basename == 'cl.exe':
if 'cl' in compiler or 'cl.exe' in compiler:
arg = '/?'
else:
arg = '--version'
@ -657,8 +656,7 @@ class Environment:
linker = [self.vs_static_linker]
else:
linker = [self.default_static_linker]
basename = os.path.basename(linker[-1]).lower()
if basename == 'lib' or basename == 'lib.exe':
if 'lib' in linker or 'lib.exe' in linker:
arg = '/?'
else:
arg = '--version'

@ -801,17 +801,17 @@ class AllPlatformTests(BasePlatformTests):
self.assertIsInstance(linker, lib)
self.assertEqual(cc.id, 'msvc')
# Set evar ourselves to a wrapper script that just calls the same
# exelist. This is meant to test that setting something like
# `ccache gcc` or `distcc ccache gcc` works fine.
# exelist + some argument. This is meant to test that setting
# something like `ccache gcc -pipe` or `distcc ccache gcc` works.
wrapper = os.path.join(testdir, 'compiler wrapper.py')
wrappercc = [sys.executable, wrapper] + cc.get_exelist()
wrappercc = [sys.executable, wrapper] + cc.get_exelist() + cc.get_always_args()
wrappercc_s = ''
for w in wrappercc:
wrappercc_s += shlex.quote(w) + ' '
os.environ[evar] = wrappercc_s
wcc = getattr(env, 'detect_{}_compiler'.format(lang))(False)
# Check static linker too
wrapperlinker = [sys.executable, wrapper] + linker.get_exelist()
wrapperlinker = [sys.executable, wrapper] + linker.get_exelist() + linker.get_always_args()
wrapperlinker_s = ''
for w in wrapperlinker:
wrapperlinker_s += shlex.quote(w) + ' '

Loading…
Cancel
Save