Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 # | 4 # |
| 5 # Copies the given "win tool" (which the toolchain uses to wrap compiler | 5 # Copies the given "win tool" (which the toolchain uses to wrap compiler |
| 6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on | 6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on |
| 7 # Windows to the build directory. | 7 # Windows to the build directory. |
| 8 # | 8 # |
| 9 # The arguments are the visual studio install location and the location of the | 9 # The arguments are the visual studio install location and the location of the |
| 10 # win tool. The script assumes that the root build directory is the current dir | 10 # win tool. The script assumes that the root build directory is the current dir |
| 11 # and the files will be written to the current directory. | 11 # and the files will be written to the current directory. |
| 12 | 12 |
| 13 import errno | 13 import errno |
| 14 import json | 14 import json |
| 15 import os | 15 import os |
| 16 import re | 16 import re |
| 17 import subprocess | 17 import subprocess |
| 18 import sys | 18 import sys |
| 19 | 19 |
| 20 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) | |
| 21 import gn_helpers | |
| 22 | |
| 20 SCRIPT_DIR = os.path.dirname(__file__) | 23 SCRIPT_DIR = os.path.dirname(__file__) |
| 21 | 24 |
| 22 def _ExtractImportantEnvironment(output_of_set): | 25 def _ExtractImportantEnvironment(output_of_set): |
| 23 """Extracts environment variables required for the toolchain to run from | 26 """Extracts environment variables required for the toolchain to run from |
| 24 a textual dump output by the cmd.exe 'set' command.""" | 27 a textual dump output by the cmd.exe 'set' command.""" |
| 25 envvars_to_save = ( | 28 envvars_to_save = ( |
| 26 'goma_.*', # TODO(scottmg): This is ugly, but needed for goma. | 29 'goma_.*', # TODO(scottmg): This is ugly, but needed for goma. |
| 27 'include', | 30 'include', |
| 28 'lib', | 31 'lib', |
| 29 'libpath', | 32 'libpath', |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 env = _LoadToolchainEnv(cpu, win_sdk_path) | 200 env = _LoadToolchainEnv(cpu, win_sdk_path) |
| 198 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] | 201 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] |
| 199 | 202 |
| 200 if cpu == target_cpu: | 203 if cpu == target_cpu: |
| 201 for path in env['PATH'].split(os.pathsep): | 204 for path in env['PATH'].split(os.pathsep): |
| 202 if os.path.exists(os.path.join(path, 'cl.exe')): | 205 if os.path.exists(os.path.join(path, 'cl.exe')): |
| 203 vc_bin_dir = os.path.realpath(path) | 206 vc_bin_dir = os.path.realpath(path) |
| 204 break | 207 break |
| 205 # The separator for INCLUDE here must match the one used in | 208 # The separator for INCLUDE here must match the one used in |
| 206 # _LoadToolchainEnv() above. | 209 # _LoadToolchainEnv() above. |
| 207 include = ' '.join([include_prefix + p | 210 include = [include_prefix + p for p in env['INCLUDE'].split(';')] |
|
hans
2016/08/23 15:16:54
Should we remove empty components from the result
Nico
2016/08/23 15:23:32
Yes, we should (...but we really shouldn't have th
| |
| 208 for p in env['INCLUDE'].split(';')]) | 211 include = ' '.join(['"' + i.replace('"', r'\"') + '"' for i in include]) |
| 209 | 212 |
| 210 env_block = _FormatAsEnvironmentBlock(env) | 213 env_block = _FormatAsEnvironmentBlock(env) |
| 211 with open('environment.' + cpu, 'wb') as f: | 214 with open('environment.' + cpu, 'wb') as f: |
| 212 f.write(env_block) | 215 f.write(env_block) |
| 213 | 216 |
| 214 # Create a store app version of the environment. | 217 # Create a store app version of the environment. |
| 215 if 'LIB' in env: | 218 if 'LIB' in env: |
| 216 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') | 219 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') |
| 217 if 'LIBPATH' in env: | 220 if 'LIBPATH' in env: |
| 218 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') | 221 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') |
| 219 env_block = _FormatAsEnvironmentBlock(env) | 222 env_block = _FormatAsEnvironmentBlock(env) |
| 220 with open('environment.winrt_' + cpu, 'wb') as f: | 223 with open('environment.winrt_' + cpu, 'wb') as f: |
| 221 f.write(env_block) | 224 f.write(env_block) |
| 222 | 225 |
| 223 assert vc_bin_dir | 226 assert vc_bin_dir |
| 224 assert '"' not in vc_bin_dir | 227 print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) |
| 225 print 'vc_bin_dir = "%s"' % vc_bin_dir | |
| 226 assert include | 228 assert include |
| 227 assert '"' not in include | 229 print 'include_flags = ' + gn_helpers.ToGNString(include) |
| 228 print 'include_flags = "%s"' % include | |
| 229 | 230 |
| 230 if __name__ == '__main__': | 231 if __name__ == '__main__': |
| 231 main() | 232 main() |
| OLD | NEW |