Lines Matching +full:bom +full:- +full:path
3 # Use of this source code is governed by a BSD-style license that can be
10 -h, --help Print this message.
11 -Werror Treat warnings as errors.
12 -I<dir> Add include path, used for both headers and resources.
13 -imsvc<dir> Add system include path, used for preprocessing only.
15 -D<sym> Define a macro for the preprocessor.
16 /fo<out> Set path of output .res file.
29 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
31 os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR))))
36 # Can't use optparse / argparse because of /fo flag :-/
47 if flag == '-h' or flag == '--help':
50 if flag.startswith('-I'):
52 elif flag.startswith('-imsvc'):
56 elif flag.startswith('-D'):
68 elif flag == '-Werror':
70 elif (flag.startswith('-') or
71 (flag.startswith('/') and not os.path.exists(flag))):
85 output = os.path.splitext(input)[0] + '.res'
101 """"Reads input and returns it. For UTF-16LEBOM input, converts to UTF-8."""
102 # Microsoft's rc.exe only supports unicode in the form of UTF-16LE with a BOM.
103 # Our rc binary sniffs for UTF-16LE. If that's not found, if /utf-8 is
104 # passed, the input is treated as UTF-8. If /utf-8 is not passed and the
105 # input is not UTF-16LE, then our rc errors out on characters outside of
106 # 7-bit ASCII. Since the driver always converts UTF-16LE to UTF-8 here (for
107 # the preprocessor, which doesn't support UTF-16LE), our rc will either see
108 # UTF-8 with the /utf-8 flag (for UTF-16LE input), or ASCII input.
110 # a /utf-8 flag for the driver for UTF-8 .rc inputs too.
111 # TODO(thakis): Microsoft's rc.exe supports BOM-less UTF-16LE. We currently
118 rc_file_data = rc_file_data[2:].decode('utf-16le').encode('utf-8')
124 print('rc.py: failed to decode UTF-16 despite BOM', input, file=sys.stderr)
131 clang = os.path.join(SRC_DIR, 'third_party', 'llvm-build',
132 'Release+Asserts', 'bin', 'clang-cl')
141 clang_cmd = [clang, '/P', '/DRC_INVOKED', '/TC', '-', '/Fi' + temp_file]
144 if os.path.dirname(flags.input):
146 clang_cmd.append('-I' + os.path.dirname(flags.input))
160 # https://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx
173 rc = os.path.join(THIS_DIR, 'linux64', 'rc')
175 rc = os.path.join(THIS_DIR, 'mac', 'rc')
177 rc = os.path.join(THIS_DIR, 'win', 'rc.exe')
182 # Make sure rc-relative resources can be found:
183 if os.path.dirname(flags.input):
184 rc_cmd.append('/cd' + os.path.dirname(flags.input))
187 rc_cmd.append('/utf-8')
189 # but clang-cl /P doesn't. Which one is right?
192 # Microsoft rc.exe searches for referenced files relative to -I flags in
193 # addition to the pwd, so -I flags need to be passed both to both
200 TOOL_DIR = os.path.dirname(os.path.relpath(THIS_DIR)).replace("\\", "/")
220 preprocessed_output = preprocessed_output.decode('utf-8').encode('utf-16le')
227 # Make sure rc-relative resources can be found. rc.exe looks for external
233 # 3. next to -I directories
234 # Changing the cwd means we'd have to rewrite all -I flags, so just add
235 # the input file dir as -I flag. That technically gets the order of 1 and 2
239 if os.path.dirname(flags.input):
240 msrc_cmd += [ '-I' + os.path.dirname(flags.input) ]
242 # Microsoft rc.exe searches for referenced files relative to -I flags in
243 # addition to the pwd, so -I flags need to be passed both to both
261 # 2. Convert the input from UTF-16LE to UTF-8 if needed.
273 # for macro names, feed the clang-preprocessed source into it instead