| Index: build/toolchain/win/tool_wrapper.py
|
| diff --git a/build/toolchain/win/tool_wrapper.py b/build/toolchain/win/tool_wrapper.py
|
| index 4e69deafb5f92ad6f9d635df7d90b0433b262f13..417e849540c3ce7a976a5a52ab06b498e9c08d8d 100644
|
| --- a/build/toolchain/win/tool_wrapper.py
|
| +++ b/build/toolchain/win/tool_wrapper.py
|
| @@ -8,6 +8,8 @@ This file is copied to the build directory as part of toolchain setup and
|
| is used to set up calls to tools used by the build that need wrappers.
|
| """
|
|
|
| +import codecs
|
| +import filecmp
|
| import os
|
| import re
|
| import shutil
|
| @@ -291,6 +293,7 @@ class WinTool(object):
|
| """Filter logo banner from invocations of rc.exe. Older versions of RC
|
| don't support the /nologo flag."""
|
| env = self._GetEnv(arch)
|
| + #print args
|
| popen = subprocess.Popen(args, shell=True, env=env,
|
| stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
| out, _ = popen.communicate()
|
| @@ -300,7 +303,47 @@ class WinTool(object):
|
| ') Microsoft Corporation') and
|
| line):
|
| print line
|
| - return popen.returncode
|
| + final_result = popen.returncode
|
| +
|
| + ppargs = ['c:\\src\\hack\\res\pptest.exe']
|
| + ppargs += [a for a in args if a.startswith('-I') or a.startswith('-D')]
|
| + rcfile = args[-1] # FIXME assumes .rc file is last
|
| +
|
| + # convert utf-16 to ascii if needed
|
| + rcfiledata = open(rcfile, 'rb').read()
|
| + rcfile = rcfile + '%d.utf8.rc' % os.getpid() # if one rc is used twice
|
| + wrote_utf8 = False
|
| + if rcfiledata.startswith(codecs.BOM_UTF16_LE):
|
| + try:
|
| + rcfiledata = rcfiledata[2:].decode('utf-16le').encode('utf-8')
|
| + wrote_utf8 = True
|
| + except e:
|
| + print >> sys.stderr, e
|
| + with open(rcfile, 'wb') as f:
|
| + f.write(rcfiledata)
|
| +
|
| + ppargs.append(rcfile)
|
| +
|
| + ppargs += ['|', 'c:\\src\\hack\\res\\rc.exe']
|
| + # Make sure rc-relative resources can be found:
|
| + ppargs.append("/cd" + os.path.dirname(rcfile))
|
| + resflag = args[-2] # FIXME assumes .res file is 2nd-to-last
|
| + assert resflag.startswith('/fo')
|
| + resfile = resflag[3:]
|
| + resfile2 = resfile + '2'
|
| + resflag = '/fo' + os.path.abspath(resfile2)
|
| + ppargs.append(resflag)
|
| + if wrote_utf8:
|
| + ppargs.append('/utf-8')
|
| + #print 'asdfasdfa', ppargs
|
| + # MS rc.exe searches for files referenced from .rc files relative to -I
|
| + # flags in addition to the pwd, so -I flags need to be passed both to
|
| + # pptest and rc :-/
|
| + ppargs += [a for a in args if a.startswith('-I')]
|
| + subprocess.check_call(ppargs, shell=True, env=env)
|
| + assert filecmp.cmp(resfile, resfile2)
|
| +
|
| + return final_result
|
|
|
| def ExecActionWrapper(self, arch, rspfile, *dirname):
|
| """Runs an action command line from a response file using the environment
|
|
|