Make msvc.py behave itself when other toolchains are loaded

Chain down to the pre-existing Task.exec_command() implementation
if task.env.CC_NAME indicates that the current taskgen isn't building
using Microsoft tools.

Issue 1237.

Signed-off-by: Thomas Nagy <tnagy2pow10@gmail.com>
This commit is contained in:
Matt Hoosier 2012-12-14 08:23:58 -06:00 committed by Thomas Nagy
parent 4b4aaf7dc5
commit 9b443a4e88
1 changed files with 18 additions and 15 deletions

View File

@ -970,22 +970,24 @@ def exec_command_msvc(self, *k, **kw):
Change the command-line execution for msvc programs.
Instead of quoting all the paths and keep using the shell, we can just join the options msvc is interested in
"""
if self.env['CC_NAME'] == 'msvc':
if isinstance(k[0], list):
lst = []
carry = ''
for a in k[0]:
if a == '/Fo' or a == '/doc' or a[-1] == ':':
carry = a
else:
lst.append(carry + a)
carry = ''
k = [lst]
if self.env['CC_NAME'] != 'msvc':
return self.exec_command_nomsvc(*k, **kw)
if self.env['PATH']:
env = dict(self.env.env or os.environ)
env.update(PATH = ';'.join(self.env['PATH']))
kw['env'] = env
if isinstance(k[0], list):
lst = []
carry = ''
for a in k[0]:
if a == '/Fo' or a == '/doc' or a[-1] == ':':
carry = a
else:
lst.append(carry + a)
carry = ''
k = [lst]
if self.env['PATH']:
env = dict(self.env.env or os.environ)
env.update(PATH = ';'.join(self.env['PATH']))
kw['env'] = env
bld = self.generator.bld
try:
@ -1002,6 +1004,7 @@ def exec_command_msvc(self, *k, **kw):
for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
cls = Task.classes.get(k, None)
if cls:
cls.exec_command_nomsvc = cls.exec_command
cls.exec_command = exec_command_msvc
cls.exec_response_command = exec_response_command
cls.quote_response_command = quote_response_command