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 # |
| 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 |
| 7 # Windows to the build directory. |
| 8 # |
| 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 |
| 11 # and the files will be written to the current directory. |
4 | 12 |
5 import errno | 13 import errno |
6 import os | 14 import os |
7 import re | 15 import re |
8 import subprocess | 16 import subprocess |
9 import sys | 17 import sys |
10 | 18 |
11 """ | |
12 Copies the given "win tool" (which the toolchain uses to wrap compiler | |
13 invocations) and the environment blocks for the 32-bit and 64-bit builds on | |
14 Windows to the build directory. | |
15 | |
16 The arguments are the visual studio install location and the location of the | |
17 win tool. The script assumes that the root build directory is the current dir | |
18 and the files will be written to the current directory. | |
19 """ | |
20 | |
21 | 19 |
22 def _ExtractImportantEnvironment(output_of_set): | 20 def _ExtractImportantEnvironment(output_of_set): |
23 """Extracts environment variables required for the toolchain to run from | 21 """Extracts environment variables required for the toolchain to run from |
24 a textual dump output by the cmd.exe 'set' command.""" | 22 a textual dump output by the cmd.exe 'set' command.""" |
25 envvars_to_save = ( | 23 envvars_to_save = ( |
26 'goma_.*', # TODO(scottmg): This is ugly, but needed for goma. | 24 'goma_.*', # TODO(scottmg): This is ugly, but needed for goma. |
27 'include', | 25 'include', |
28 'lib', | 26 'lib', |
29 'libpath', | 27 'libpath', |
30 'path', | 28 'path', |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 '# Generated by setup_toolchain.py do not edit.\n'] | 95 '# Generated by setup_toolchain.py do not edit.\n'] |
98 + tool_source[1:])) | 96 + tool_source[1:])) |
99 | 97 |
100 | 98 |
101 def main(): | 99 def main(): |
102 if len(sys.argv) != 6: | 100 if len(sys.argv) != 6: |
103 print('Usage setup_toolchain.py ' | 101 print('Usage setup_toolchain.py ' |
104 '<visual studio path> <win tool path> <win sdk path> ' | 102 '<visual studio path> <win tool path> <win sdk path> ' |
105 '<runtime dirs> <cpu_arch>') | 103 '<runtime dirs> <cpu_arch>') |
106 sys.exit(2) | 104 sys.exit(2) |
107 vs_path = sys.argv[1] | |
108 tool_source = sys.argv[2] | 105 tool_source = sys.argv[2] |
109 win_sdk_path = sys.argv[3] | 106 win_sdk_path = sys.argv[3] |
110 runtime_dirs = sys.argv[4] | 107 runtime_dirs = sys.argv[4] |
111 cpu_arch = sys.argv[5] | 108 cpu_arch = sys.argv[5] |
112 | 109 |
113 _CopyTool(tool_source) | 110 _CopyTool(tool_source) |
114 | 111 |
115 archs = ('x86', 'x64') | 112 archs = ('x86', 'x64') |
116 assert cpu_arch in archs | 113 assert cpu_arch in archs |
117 vc_bin_dir = '' | 114 vc_bin_dir = '' |
(...skipping 30 matching lines...) Expand all Loading... |
148 env_block = _FormatAsEnvironmentBlock(env) | 145 env_block = _FormatAsEnvironmentBlock(env) |
149 with open('environment.' + arch, 'wb') as f: | 146 with open('environment.' + arch, 'wb') as f: |
150 f.write(env_block) | 147 f.write(env_block) |
151 | 148 |
152 assert vc_bin_dir | 149 assert vc_bin_dir |
153 print 'vc_bin_dir = "%s"' % vc_bin_dir | 150 print 'vc_bin_dir = "%s"' % vc_bin_dir |
154 | 151 |
155 | 152 |
156 if __name__ == '__main__': | 153 if __name__ == '__main__': |
157 main() | 154 main() |
OLD | NEW |