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 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 return block | 140 return block |
141 | 141 |
142 | 142 |
143 def _CopyTool(source_path): | 143 def _CopyTool(source_path): |
144 """Copies the given tool to the current directory, including a warning not | 144 """Copies the given tool to the current directory, including a warning not |
145 to edit it.""" | 145 to edit it.""" |
146 with open(source_path) as source_file: | 146 with open(source_path) as source_file: |
147 tool_source = source_file.readlines() | 147 tool_source = source_file.readlines() |
148 | 148 |
149 # Add header and write it out to the current directory (which should be the | 149 # Add header and write it out to the current directory (which should be the |
150 # root build dir). | 150 # root build dir). Don't write the file if a matching file already exists |
151 with open("gyp-win-tool", 'w') as tool_file: | 151 # because that causes a cascade of unnecessary rebuilds. |
152 tool_file.write(''.join([tool_source[0], | 152 match = False |
153 '# Generated by setup_toolchain.py do not edit.\n'] | 153 contents = ''.join([tool_source[0], |
154 + tool_source[1:])) | 154 '# Generated by setup_toolchain.py do not edit.\n'] |
155 + tool_source[1:]) | |
156 try: | |
scottmg
2016/04/29 02:11:40
filename = 'gyp-win-tool'
and use in both places.
brucedawson
2016/04/29 17:25:28
Done.
| |
157 with open("gyp-win-tool", 'r') as tool_file: | |
scottmg
2016/04/29 02:11:40
" -> ' while you're here (and below).
scottmg
2016/04/29 02:11:40
'rb' here, and 'wb' below since we're sort of doin
scottmg
2016/04/29 02:11:40
Maybe call this read_tool_file and the one below w
brucedawson
2016/04/29 17:25:28
Yeah, I noticed that and wondered if there was som
brucedawson
2016/04/29 17:25:28
Done.
brucedawson
2016/04/29 17:25:28
Done.
| |
158 existing_contents = tool_file.read() | |
159 if existing_contents == contents: | |
160 match = True | |
161 except: | |
162 pass | |
163 if not match: | |
164 with open("gyp-win-tool", 'w') as tool_file: | |
165 tool_file.write(contents) | |
155 | 166 |
156 | 167 |
157 def main(): | 168 def main(): |
158 if len(sys.argv) != 6: | 169 if len(sys.argv) != 6: |
159 print('Usage setup_toolchain.py ' | 170 print('Usage setup_toolchain.py ' |
160 '<visual studio path> <win tool path> <win sdk path> ' | 171 '<visual studio path> <win tool path> <win sdk path> ' |
161 '<runtime dirs> <target_cpu>') | 172 '<runtime dirs> <target_cpu>') |
162 sys.exit(2) | 173 sys.exit(2) |
163 tool_source = sys.argv[2] | 174 tool_source = sys.argv[2] |
164 win_sdk_path = sys.argv[3] | 175 win_sdk_path = sys.argv[3] |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 env_block = _FormatAsEnvironmentBlock(env) | 208 env_block = _FormatAsEnvironmentBlock(env) |
198 with open('environment.winrt_' + cpu, 'wb') as f: | 209 with open('environment.winrt_' + cpu, 'wb') as f: |
199 f.write(env_block) | 210 f.write(env_block) |
200 | 211 |
201 assert vc_bin_dir | 212 assert vc_bin_dir |
202 print 'vc_bin_dir = "%s"' % vc_bin_dir | 213 print 'vc_bin_dir = "%s"' % vc_bin_dir |
203 | 214 |
204 | 215 |
205 if __name__ == '__main__': | 216 if __name__ == '__main__': |
206 main() | 217 main() |
OLD | NEW |