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 if sys.platform == 'win32': | |
| 381 # FIXME: Parse `clang-cl /?` output for built clang's version and check | |
|
hans
2016/08/08 16:11:23
Doesn't the code below work on Windows too? Regula
Nico
2016/08/08 17:01:32
That's a good point. I figured it'd be nicer to ge
| |
| 382 pass | |
| 383 else: | |
| 384 clang = os.path.join(LLVM_BUILD_DIR, 'bin', 'clang') | |
| 385 version_out = subprocess.check_output([clang, '--version']) | |
| 386 version_out = re.match(r'clang version (\S+)', version_out).group(1) | |
| 387 if version_out != VERSION: | |
| 388 print ('unexpected clang version %s (not %s), update VERSION in update.py' | |
| 389 % (version_out, VERSION)) | |
| 390 sys.exit(1) | |
| 391 | |
| 392 | |
| 376 def UpdateClang(args): | 393 def UpdateClang(args): |
| 377 print 'Updating Clang to %s...' % PACKAGE_VERSION | 394 print 'Updating Clang to %s...' % PACKAGE_VERSION |
| 378 | 395 |
| 379 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( | 396 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( |
| 380 sys.platform.startswith('linux') and | 397 sys.platform.startswith('linux') and |
| 381 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and | 398 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and |
| 382 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) | 399 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) |
| 383 | 400 |
| 384 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: | 401 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: |
| 385 print 'Clang is already up to date.' | 402 print 'Clang is already up to date.' |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 if args.tools: | 658 if args.tools: |
| 642 # If any Chromium tools were built, install those now. | 659 # If any Chromium tools were built, install those now. |
| 643 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') | 660 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') |
| 644 | 661 |
| 645 if sys.platform == 'darwin': | 662 if sys.platform == 'darwin': |
| 646 # See http://crbug.com/256342 | 663 # See http://crbug.com/256342 |
| 647 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 664 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 648 elif sys.platform.startswith('linux'): | 665 elif sys.platform.startswith('linux'): |
| 649 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 666 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 650 | 667 |
| 651 # TODO(thakis): Check that `clang --version` matches VERSION. | 668 VeryifyVersionOfBuiltClangMatchesVERSION() |
| 652 | 669 |
| 653 # Do an out-of-tree build of compiler-rt. | 670 # Do an out-of-tree build of compiler-rt. |
| 654 # On Windows, this is used to get the 32-bit ASan run-time. | 671 # On Windows, this is used to get the 32-bit ASan run-time. |
| 655 # TODO(hans): Remove once the regular build above produces this. | 672 # 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. | 673 # On Mac and Linux, this is used to get the regular 64-bit run-time. |
| 657 # Do a clobbered build due to cmake changes. | 674 # Do a clobbered build due to cmake changes. |
| 658 if os.path.isdir(COMPILER_RT_BUILD_DIR): | 675 if os.path.isdir(COMPILER_RT_BUILD_DIR): |
| 659 RmTree(COMPILER_RT_BUILD_DIR) | 676 RmTree(COMPILER_RT_BUILD_DIR) |
| 660 os.makedirs(COMPILER_RT_BUILD_DIR) | 677 os.makedirs(COMPILER_RT_BUILD_DIR) |
| 661 os.chdir(COMPILER_RT_BUILD_DIR) | 678 os.chdir(COMPILER_RT_BUILD_DIR) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 args.force_local_build = True | 902 args.force_local_build = True |
| 886 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | 903 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 887 # Only build the Android ASan rt on ToT bots when targetting Android. | 904 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 888 args.with_android = False | 905 args.with_android = False |
| 889 | 906 |
| 890 return UpdateClang(args) | 907 return UpdateClang(args) |
| 891 | 908 |
| 892 | 909 |
| 893 if __name__ == '__main__': | 910 if __name__ == '__main__': |
| 894 sys.exit(main()) | 911 sys.exit(main()) |
| OLD | NEW |