Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """This script is used to download prebuilt clang binaries. | 6 """This script is used to download prebuilt clang binaries. |
| 7 | 7 |
| 8 It is also used by package.py to build the prebuilt clang binaries.""" | 8 It is also used by package.py to build the prebuilt clang binaries.""" |
| 9 | 9 |
| 10 import argparse | 10 import argparse |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 return vs_version | 366 return vs_version |
| 367 | 367 |
| 368 | 368 |
| 369 def CopyDiaDllTo(target_dir): | 369 def CopyDiaDllTo(target_dir): |
| 370 # This script always wants to use the 64-bit msdia*.dll. | 370 # This script always wants to use the 64-bit msdia*.dll. |
| 371 dia_path = os.path.join(GetVSVersion().Path(), 'DIA SDK', 'bin', 'amd64') | 371 dia_path = os.path.join(GetVSVersion().Path(), 'DIA SDK', 'bin', 'amd64') |
| 372 dia_dll = os.path.join(dia_path, DIA_DLL[GetVSVersion().ShortName()]) | 372 dia_dll = os.path.join(dia_path, DIA_DLL[GetVSVersion().ShortName()]) |
| 373 CopyFile(dia_dll, target_dir) | 373 CopyFile(dia_dll, target_dir) |
| 374 | 374 |
| 375 | 375 |
| 376 def VeryifyVersionOfBuiltClangMatchesVERSION(): | |
| 377 """Checks that `clang --version` outputs VERSION. If this fails, VERSION | |
| 378 in this file is out-of-date and needs to be updated (possibly in an | |
| 379 `if use_head_revision:` block in main() first).""" | |
| 380 clang = os.path.join(LLVM_BUILD_DIR, 'bin', 'clang') | |
| 381 if sys.platform == 'win32': | |
| 382 # TODO: Parse `clang-cl /?` output for built clang's version and check that | |
| 383 # to check the binary we're actually shipping? But clang-cl.exe is just | |
| 384 # a copy of clang.exe, so this does check the same thing. | |
| 385 clang += '.exe' | |
|
hans
2016/08/08 18:54:00
Yeah, I think checking clang is good enough.
If w
| |
| 386 version_out = subprocess.check_output([clang, '--version']) | |
| 387 version_out = re.match(r'clang version (\S+)', version_out).group(1) | |
|
hans
2016/08/08 18:54:00
Sorry, I should have mentioned this the first time
Nico
2016/08/08 19:00:31
Does it matter if we compare to VERSION later? If
hans
2016/08/08 19:27:32
I figured if for whatever reason clang starts prin
Nico
2016/08/08 20:26:20
Hm, I think I'd prefer if this turned red in that
| |
| 388 if version_out != VERSION: | |
| 389 print ('unexpected clang version %s (not %s), update VERSION in update.py' | |
| 390 % (version_out, VERSION)) | |
| 391 sys.exit(1) | |
| 392 | |
| 393 | |
| 376 def UpdateClang(args): | 394 def UpdateClang(args): |
| 377 print 'Updating Clang to %s...' % PACKAGE_VERSION | 395 print 'Updating Clang to %s...' % PACKAGE_VERSION |
| 378 | 396 |
| 379 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( | 397 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( |
| 380 sys.platform.startswith('linux') and | 398 sys.platform.startswith('linux') and |
| 381 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and | 399 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and |
| 382 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) | 400 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) |
| 383 | 401 |
| 384 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: | 402 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: |
| 385 print 'Clang is already up to date.' | 403 print 'Clang is already up to date.' |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 if args.tools: | 659 if args.tools: |
| 642 # If any Chromium tools were built, install those now. | 660 # If any Chromium tools were built, install those now. |
| 643 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') | 661 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') |
| 644 | 662 |
| 645 if sys.platform == 'darwin': | 663 if sys.platform == 'darwin': |
| 646 # See http://crbug.com/256342 | 664 # See http://crbug.com/256342 |
| 647 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 665 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 648 elif sys.platform.startswith('linux'): | 666 elif sys.platform.startswith('linux'): |
| 649 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 667 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 650 | 668 |
| 651 # TODO(thakis): Check that `clang --version` matches VERSION. | 669 VeryifyVersionOfBuiltClangMatchesVERSION() |
| 652 | 670 |
| 653 # Do an out-of-tree build of compiler-rt. | 671 # Do an out-of-tree build of compiler-rt. |
| 654 # On Windows, this is used to get the 32-bit ASan run-time. | 672 # On Windows, this is used to get the 32-bit ASan run-time. |
| 655 # TODO(hans): Remove once the regular build above produces this. | 673 # TODO(hans): Remove once the regular build above produces this. |
| 656 # On Mac and Linux, this is used to get the regular 64-bit run-time. | 674 # On Mac and Linux, this is used to get the regular 64-bit run-time. |
| 657 # Do a clobbered build due to cmake changes. | 675 # Do a clobbered build due to cmake changes. |
| 658 if os.path.isdir(COMPILER_RT_BUILD_DIR): | 676 if os.path.isdir(COMPILER_RT_BUILD_DIR): |
| 659 RmTree(COMPILER_RT_BUILD_DIR) | 677 RmTree(COMPILER_RT_BUILD_DIR) |
| 660 os.makedirs(COMPILER_RT_BUILD_DIR) | 678 os.makedirs(COMPILER_RT_BUILD_DIR) |
| 661 os.chdir(COMPILER_RT_BUILD_DIR) | 679 os.chdir(COMPILER_RT_BUILD_DIR) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 args.force_local_build = True | 898 args.force_local_build = True |
| 881 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | 899 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 882 # Only build the Android ASan rt on ToT bots when targetting Android. | 900 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 883 args.with_android = False | 901 args.with_android = False |
| 884 | 902 |
| 885 return UpdateClang(args) | 903 return UpdateClang(args) |
| 886 | 904 |
| 887 | 905 |
| 888 if __name__ == '__main__': | 906 if __name__ == '__main__': |
| 889 sys.exit(main()) | 907 sys.exit(main()) |
| OLD | NEW |