OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
8 | 8 |
9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 with open(os.devnull, 'wb') as nul: | 283 with open(os.devnull, 'wb') as nul: |
284 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'], | 284 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'], |
285 stdin=nul, stdout=nul, stderr=nul) | 285 stdin=nul, stdout=nul, stderr=nul) |
286 if os.path.isdir(target_dir): | 286 if os.path.isdir(target_dir): |
287 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) | 287 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) |
288 | 288 |
289 DoTreeMirror(target_dir, desired_hashes[0]) | 289 DoTreeMirror(target_dir, desired_hashes[0]) |
290 | 290 |
291 got_new_toolchain = True | 291 got_new_toolchain = True |
292 | 292 |
293 win_sdk = os.path.join(abs_target_dir, 'win_sdk') | 293 data = { |
| 294 'path': abs_target_dir, |
| 295 'win_sdk': os.path.join(abs_target_dir, 'win_sdk'), |
| 296 'wdk': os.path.join(abs_target_dir, 'wdk'), |
| 297 'runtime_dirs': [ |
| 298 os.path.join(abs_target_dir, 'sys64'), |
| 299 os.path.join(abs_target_dir, 'sys32'), |
| 300 ], |
| 301 } |
| 302 |
294 try: | 303 try: |
295 with open(os.path.join(target_dir, 'VS_VERSION'), 'rb') as f: | 304 with open(os.path.join(target_dir, 'VS_VERSION'), 'rb') as f: |
296 vs_version = f.read().strip() | 305 vs_version = f.read().strip() |
297 except IOError: | 306 except IOError: |
298 # Older toolchains didn't have the VS_VERSION file, and used 'win8sdk' | 307 # Older toolchains didn't have the VS_VERSION file, and used 'win8sdk' |
299 # instead of just 'win_sdk'. | 308 # instead of just 'win_sdk'. |
300 vs_version = '2013' | 309 vs_version = '2013' |
301 win_sdk = os.path.join(abs_target_dir, 'win8sdk') | 310 data['win8sdk'] = os.path.join(abs_target_dir, 'win8sdk') |
302 | 311 |
303 data = { | 312 data['version'] = vs_version |
304 'path': abs_target_dir, | 313 |
305 'version': vs_version, | |
306 'win_sdk': win_sdk, | |
307 'wdk': os.path.join(abs_target_dir, 'wdk'), | |
308 'runtime_dirs': [ | |
309 os.path.join(abs_target_dir, 'sys64'), | |
310 os.path.join(abs_target_dir, 'sys32'), | |
311 ], | |
312 } | |
313 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: | 314 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: |
314 json.dump(data, f) | 315 json.dump(data, f) |
315 | 316 |
316 if got_new_toolchain: | 317 if got_new_toolchain: |
317 current_hash = CalculateHash(target_dir) | 318 current_hash = CalculateHash(target_dir) |
318 if current_hash not in desired_hashes: | 319 if current_hash not in desired_hashes: |
319 print >> sys.stderr, ( | 320 print >> sys.stderr, ( |
320 'Got wrong hash after pulling a new toolchain. ' | 321 'Got wrong hash after pulling a new toolchain. ' |
321 'Wanted one of \'%s\', got \'%s\'.' % ( | 322 'Wanted one of \'%s\', got \'%s\'.' % ( |
322 ', '.join(desired_hashes), current_hash)) | 323 ', '.join(desired_hashes), current_hash)) |
323 return 1 | 324 return 1 |
324 SaveTimestampsAndHash(target_dir, current_hash) | 325 SaveTimestampsAndHash(target_dir, current_hash) |
325 | 326 |
326 if options.output_json: | 327 if options.output_json: |
327 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 328 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
328 options.output_json) | 329 options.output_json) |
329 | 330 |
330 return 0 | 331 return 0 |
331 | 332 |
332 | 333 |
333 if __name__ == '__main__': | 334 if __name__ == '__main__': |
334 sys.exit(main()) | 335 sys.exit(main()) |
OLD | NEW |