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 data = { | 293 win_sdk = os.path.join(abs_target_dir, 'win_sdk') |
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 | |
303 try: | 294 try: |
304 with open(os.path.join(target_dir, 'VS_VERSION'), 'rb') as f: | 295 with open(os.path.join(target_dir, 'VS_VERSION'), 'rb') as f: |
305 vs_version = f.read().strip() | 296 vs_version = f.read().strip() |
306 except IOError: | 297 except IOError: |
307 # Older toolchains didn't have the VS_VERSION file, and used 'win8sdk' | 298 # Older toolchains didn't have the VS_VERSION file, and used 'win8sdk' |
308 # instead of just 'win_sdk'. | 299 # instead of just 'win_sdk'. |
309 vs_version = '2013' | 300 vs_version = '2013' |
310 data['win8sdk'] = os.path.join(abs_target_dir, 'win8sdk') | 301 win_sdk = os.path.join(abs_target_dir, 'win8sdk') |
311 | 302 |
312 data['version'] = vs_version | 303 data = { |
313 | 304 'path': abs_target_dir, |
| 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 } |
314 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: | 313 with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: |
315 json.dump(data, f) | 314 json.dump(data, f) |
316 | 315 |
317 if got_new_toolchain: | 316 if got_new_toolchain: |
318 current_hash = CalculateHash(target_dir) | 317 current_hash = CalculateHash(target_dir) |
319 if current_hash not in desired_hashes: | 318 if current_hash not in desired_hashes: |
320 print >> sys.stderr, ( | 319 print >> sys.stderr, ( |
321 'Got wrong hash after pulling a new toolchain. ' | 320 'Got wrong hash after pulling a new toolchain. ' |
322 'Wanted one of \'%s\', got \'%s\'.' % ( | 321 'Wanted one of \'%s\', got \'%s\'.' % ( |
323 ', '.join(desired_hashes), current_hash)) | 322 ', '.join(desired_hashes), current_hash)) |
324 return 1 | 323 return 1 |
325 SaveTimestampsAndHash(target_dir, current_hash) | 324 SaveTimestampsAndHash(target_dir, current_hash) |
326 | 325 |
327 if options.output_json: | 326 if options.output_json: |
328 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 327 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
329 options.output_json) | 328 options.output_json) |
330 | 329 |
331 return 0 | 330 return 0 |
332 | 331 |
333 | 332 |
334 if __name__ == '__main__': | 333 if __name__ == '__main__': |
335 sys.exit(main()) | 334 sys.exit(main()) |
OLD | NEW |