| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 version_out = re.match(r'clang version ([0-9.]+)', version_out).group(1) | 389 version_out = re.match(r'clang version ([0-9.]+)', version_out).group(1) |
| 390 if version_out != VERSION: | 390 if version_out != VERSION: |
| 391 print ('unexpected clang version %s (not %s), update VERSION in update.py' | 391 print ('unexpected clang version %s (not %s), update VERSION in update.py' |
| 392 % (version_out, VERSION)) | 392 % (version_out, VERSION)) |
| 393 sys.exit(1) | 393 sys.exit(1) |
| 394 | 394 |
| 395 | 395 |
| 396 def UpdateClang(args): | 396 def UpdateClang(args): |
| 397 print 'Updating Clang to %s...' % PACKAGE_VERSION | 397 print 'Updating Clang to %s...' % PACKAGE_VERSION |
| 398 | 398 |
| 399 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( | |
| 400 sys.platform.startswith('linux') and | |
| 401 'buildtype=Official' in os.environ.get('GYP_DEFINES', '')) | |
| 402 | |
| 403 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: | 399 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: |
| 404 print 'Clang is already up to date.' | 400 print 'Clang is already up to date.' |
| 405 if not need_gold_plugin or os.path.exists( | 401 return 0 |
| 406 os.path.join(LLVM_BUILD_DIR, "lib/LLVMgold.so")): | |
| 407 return 0 | |
| 408 | 402 |
| 409 # Reset the stamp file in case the build is unsuccessful. | 403 # Reset the stamp file in case the build is unsuccessful. |
| 410 WriteStampFile('') | 404 WriteStampFile('') |
| 411 | 405 |
| 412 if not args.force_local_build: | 406 if not args.force_local_build: |
| 413 cds_file = "clang-%s.tgz" % PACKAGE_VERSION | 407 cds_file = "clang-%s.tgz" % PACKAGE_VERSION |
| 414 if sys.platform == 'win32' or sys.platform == 'cygwin': | 408 if sys.platform == 'win32' or sys.platform == 'cygwin': |
| 415 cds_full_url = CDS_URL + '/Win/' + cds_file | 409 cds_full_url = CDS_URL + '/Win/' + cds_file |
| 416 elif sys.platform == 'darwin': | 410 elif sys.platform == 'darwin': |
| 417 cds_full_url = CDS_URL + '/Mac/' + cds_file | 411 cds_full_url = CDS_URL + '/Mac/' + cds_file |
| 418 else: | 412 else: |
| 419 assert sys.platform.startswith('linux') | 413 assert sys.platform.startswith('linux') |
| 420 cds_full_url = CDS_URL + '/Linux_x64/' + cds_file | 414 cds_full_url = CDS_URL + '/Linux_x64/' + cds_file |
| 421 | 415 |
| 422 print 'Downloading prebuilt clang' | 416 print 'Downloading prebuilt clang' |
| 423 if os.path.exists(LLVM_BUILD_DIR): | 417 if os.path.exists(LLVM_BUILD_DIR): |
| 424 RmTree(LLVM_BUILD_DIR) | 418 RmTree(LLVM_BUILD_DIR) |
| 425 try: | 419 try: |
| 426 DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR) | 420 DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR) |
| 427 print 'clang %s unpacked' % PACKAGE_VERSION | 421 print 'clang %s unpacked' % PACKAGE_VERSION |
| 428 if sys.platform == 'win32': | 422 if sys.platform == 'win32': |
| 429 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin')) | 423 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin')) |
| 430 # Download the gold plugin if requested to by an environment variable. | |
| 431 # This is used by the CFI ClusterFuzz bot, and it's required for official | |
| 432 # builds on linux. | |
| 433 if need_gold_plugin: | |
| 434 RunCommand(['python', CHROMIUM_DIR+'/build/download_gold_plugin.py']) | |
| 435 WriteStampFile(PACKAGE_VERSION) | 424 WriteStampFile(PACKAGE_VERSION) |
| 436 return 0 | 425 return 0 |
| 437 except urllib2.URLError: | 426 except urllib2.URLError: |
| 438 print 'Failed to download prebuilt clang %s' % cds_file | 427 print 'Failed to download prebuilt clang %s' % cds_file |
| 439 print 'Use --force-local-build if you want to build locally.' | 428 print 'Use --force-local-build if you want to build locally.' |
| 440 print 'Exiting.' | 429 print 'Exiting.' |
| 441 return 1 | 430 return 1 |
| 442 | 431 |
| 443 if args.with_android and not os.path.exists(ANDROID_NDK_DIR): | 432 if args.with_android and not os.path.exists(ANDROID_NDK_DIR): |
| 444 print 'Android NDK not found at ' + ANDROID_NDK_DIR | 433 print 'Android NDK not found at ' + ANDROID_NDK_DIR |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 args.force_local_build = True | 904 args.force_local_build = True |
| 916 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | 905 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 917 # Only build the Android ASan rt on ToT bots when targetting Android. | 906 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 918 args.with_android = False | 907 args.with_android = False |
| 919 | 908 |
| 920 return UpdateClang(args) | 909 return UpdateClang(args) |
| 921 | 910 |
| 922 | 911 |
| 923 if __name__ == '__main__': | 912 if __name__ == '__main__': |
| 924 sys.exit(main()) | 913 sys.exit(main()) |
| OLD | NEW |