mirror of https://gitlab.com/ita1024/waf.git
response files for c#, Issue 1182
This commit is contained in:
parent
8c0126d6a1
commit
1946acc1d8
|
@ -25,6 +25,7 @@ from waflib import Utils, Task, Options, Logs, Errors
|
||||||
from waflib.TaskGen import before_method, after_method, feature
|
from waflib.TaskGen import before_method, after_method, feature
|
||||||
from waflib.Tools import ccroot
|
from waflib.Tools import ccroot
|
||||||
from waflib.Configure import conf
|
from waflib.Configure import conf
|
||||||
|
import os, tempfile
|
||||||
|
|
||||||
ccroot.USELIB_VARS['cs'] = set(['CSFLAGS', 'ASSEMBLIES', 'RESOURCES'])
|
ccroot.USELIB_VARS['cs'] = set(['CSFLAGS', 'ASSEMBLIES', 'RESOURCES'])
|
||||||
ccroot.lib_patterns['csshlib'] = ['%s']
|
ccroot.lib_patterns['csshlib'] = ['%s']
|
||||||
|
@ -124,6 +125,48 @@ class mcs(Task.Task):
|
||||||
color = 'YELLOW'
|
color = 'YELLOW'
|
||||||
run_str = '${MCS} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}'
|
run_str = '${MCS} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}'
|
||||||
|
|
||||||
|
def exec_command(self, cmd, **kw):
|
||||||
|
bld = self.generator.bld
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not kw.get('cwd', None):
|
||||||
|
kw['cwd'] = bld.cwd
|
||||||
|
except AttributeError:
|
||||||
|
bld.cwd = kw['cwd'] = bld.variant_dir
|
||||||
|
|
||||||
|
try:
|
||||||
|
tmp = None
|
||||||
|
if isinstance(cmd, list) and len(' '.join(cmd)) >= 8192:
|
||||||
|
program = cmd[0] #unquoted program name, otherwise exec_command will fail
|
||||||
|
cmd = [self.quote_response_command(x) for x in cmd]
|
||||||
|
(fd, tmp) = tempfile.mkstemp()
|
||||||
|
os.write(fd, '\r\n'.join(i.replace('\\', '\\\\') for i in cmd[1:]).encode())
|
||||||
|
os.close(fd)
|
||||||
|
cmd = [program, '@' + tmp]
|
||||||
|
# no return here, that's on purpose
|
||||||
|
ret = self.generator.bld.exec_command(cmd, **kw)
|
||||||
|
finally:
|
||||||
|
if tmp:
|
||||||
|
try:
|
||||||
|
os.remove(tmp)
|
||||||
|
except OSError:
|
||||||
|
pass # anti-virus and indexers can keep the files open -_-
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def quote_response_command(self, flag):
|
||||||
|
# /noconfig is not allowed when using response files
|
||||||
|
if flag.lower() == '/noconfig':
|
||||||
|
return ''
|
||||||
|
|
||||||
|
if flag.find(' ') > -1:
|
||||||
|
for x in ('/r:', '/reference:', '/resource:', '/lib:', '/out:'):
|
||||||
|
if flag.startswith(x):
|
||||||
|
flag = '%s"%s"' % (x, flag[len(x):])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
flag = '"%s"' % flag
|
||||||
|
return flag
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
"""
|
"""
|
||||||
Find a C# compiler, set the variable MCS for the compiler and CS_NAME (mono or csc)
|
Find a C# compiler, set the variable MCS for the compiler and CS_NAME (mono or csc)
|
||||||
|
|
Loading…
Reference in New Issue