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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 return True | 214 return True |
| 215 print 'Failed.' | 215 print 'Failed.' |
| 216 if fail_hard: | 216 if fail_hard: |
| 217 sys.exit(1) | 217 sys.exit(1) |
| 218 return False | 218 return False |
| 219 | 219 |
| 220 | 220 |
| 221 def CopyFile(src, dst): | 221 def CopyFile(src, dst): |
| 222 """Copy a file from src to dst.""" | 222 """Copy a file from src to dst.""" |
| 223 shutil.copy(src, dst) | 223 shutil.copy(src, dst) |
| 224 print "Copying %s to %s" % (src, dst) | 224 print "Copying %s to %s" % (src, dst) |
|
hans
2016/04/12 16:47:23
Hmm, why do we print *after* calling shutil.copy?
Nico
2016/04/12 17:00:57
Done.
| |
| 225 | 225 |
| 226 | 226 |
| 227 def CopyDirectoryContents(src, dst, filename_filter=None): | 227 def CopyDirectoryContents(src, dst, filename_filter=None): |
| 228 """Copy the files from directory src to dst | 228 """Copy the files from directory src to dst |
| 229 with an optional filename filter.""" | 229 with an optional filename filter.""" |
| 230 dst = os.path.realpath(dst) # realpath() in case dst ends in /.. | 230 dst = os.path.realpath(dst) # realpath() in case dst ends in /.. |
| 231 EnsureDirExists(dst) | 231 EnsureDirExists(dst) |
| 232 for root, _, files in os.walk(src): | 232 for root, _, files in os.walk(src): |
| 233 for f in files: | 233 for f in files: |
| 234 if filename_filter and not re.match(filename_filter, f): | 234 if filename_filter and not re.match(filename_filter, f): |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 344 |
| 345 # Use gyp to find the MSVS installation, either in depot_tools as per above, | 345 # Use gyp to find the MSVS installation, either in depot_tools as per above, |
| 346 # or a system-wide installation otherwise. | 346 # or a system-wide installation otherwise. |
| 347 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) | 347 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) |
| 348 import gyp.MSVSVersion | 348 import gyp.MSVSVersion |
| 349 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion( | 349 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion( |
| 350 vs_toolchain.GetVisualStudioVersion()) | 350 vs_toolchain.GetVisualStudioVersion()) |
| 351 return vs_version | 351 return vs_version |
| 352 | 352 |
| 353 | 353 |
| 354 def CopyDiaDllTo(target_dir): | |
| 355 # This script always wants to use the 64-bit msdia*.dll. | |
| 356 dia_path = os.path.join(GetVSVersion().Path(), 'DIA SDK', 'bin', 'amd64') | |
| 357 dia_dll = os.path.join(dia_path, 'msdia140.dll') # Bump after VC updates. | |
| 358 CopyFile(dia_dll, target_dir) | |
| 359 | |
| 360 | |
| 354 def UpdateClang(args): | 361 def UpdateClang(args): |
| 355 print 'Updating Clang to %s...' % PACKAGE_VERSION | 362 print 'Updating Clang to %s...' % PACKAGE_VERSION |
| 356 | 363 |
| 357 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( | 364 need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or ( |
| 358 sys.platform.startswith('linux') and | 365 sys.platform.startswith('linux') and |
| 359 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and | 366 'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and |
| 360 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) | 367 'branding=Chrome' in os.environ.get('GYP_DEFINES', '')) |
| 361 | 368 |
| 362 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: | 369 if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build: |
| 363 print 'Clang is already up to date.' | 370 print 'Clang is already up to date.' |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 377 else: | 384 else: |
| 378 assert sys.platform.startswith('linux') | 385 assert sys.platform.startswith('linux') |
| 379 cds_full_url = CDS_URL + '/Linux_x64/' + cds_file | 386 cds_full_url = CDS_URL + '/Linux_x64/' + cds_file |
| 380 | 387 |
| 381 print 'Downloading prebuilt clang' | 388 print 'Downloading prebuilt clang' |
| 382 if os.path.exists(LLVM_BUILD_DIR): | 389 if os.path.exists(LLVM_BUILD_DIR): |
| 383 RmTree(LLVM_BUILD_DIR) | 390 RmTree(LLVM_BUILD_DIR) |
| 384 try: | 391 try: |
| 385 DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR) | 392 DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR) |
| 386 print 'clang %s unpacked' % PACKAGE_VERSION | 393 print 'clang %s unpacked' % PACKAGE_VERSION |
| 394 if sys.platform == 'win32': | |
| 395 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin')) | |
| 387 # Download the gold plugin if requested to by an environment variable. | 396 # Download the gold plugin if requested to by an environment variable. |
| 388 # This is used by the CFI ClusterFuzz bot, and it's required for official | 397 # This is used by the CFI ClusterFuzz bot, and it's required for official |
| 389 # builds on linux. | 398 # builds on linux. |
| 390 if need_gold_plugin: | 399 if need_gold_plugin: |
| 391 RunCommand(['python', CHROMIUM_DIR+'/build/download_gold_plugin.py']) | 400 RunCommand(['python', CHROMIUM_DIR+'/build/download_gold_plugin.py']) |
| 392 WriteStampFile(PACKAGE_VERSION) | 401 WriteStampFile(PACKAGE_VERSION) |
| 393 return 0 | 402 return 0 |
| 394 except urllib2.URLError: | 403 except urllib2.URLError: |
| 395 print 'Failed to download prebuilt clang %s' % cds_file | 404 print 'Failed to download prebuilt clang %s' % cds_file |
| 396 print 'Use --force-local-build if you want to build locally.' | 405 print 'Use --force-local-build if you want to build locally.' |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, | 478 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, |
| 470 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), | 479 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
| 471 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), | 480 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), |
| 472 ] | 481 ] |
| 473 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) | 482 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) |
| 474 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) | 483 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) |
| 475 RmCmakeCache('.') | 484 RmCmakeCache('.') |
| 476 RunCommand(['cmake'] + bootstrap_args + [LLVM_DIR], msvc_arch='x64') | 485 RunCommand(['cmake'] + bootstrap_args + [LLVM_DIR], msvc_arch='x64') |
| 477 RunCommand(['ninja'], msvc_arch='x64') | 486 RunCommand(['ninja'], msvc_arch='x64') |
| 478 if args.run_tests: | 487 if args.run_tests: |
| 488 if sys.platform == 'win32': | |
| 489 CopyDiaDllTo(os.path.join(LLVM_BOOTSTRAP_DIR, 'bin')) | |
| 479 RunCommand(['ninja', 'check-all'], msvc_arch='x64') | 490 RunCommand(['ninja', 'check-all'], msvc_arch='x64') |
| 480 RunCommand(['ninja', 'install'], msvc_arch='x64') | 491 RunCommand(['ninja', 'install'], msvc_arch='x64') |
| 481 if args.gcc_toolchain: | 492 if args.gcc_toolchain: |
| 482 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap | 493 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap |
| 483 # compiler can start. | 494 # compiler can start. |
| 484 CopyFile(libstdcpp, os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'lib')) | 495 CopyFile(libstdcpp, os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'lib')) |
| 485 | 496 |
| 486 if sys.platform == 'win32': | 497 if sys.platform == 'win32': |
| 487 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') | 498 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') |
| 488 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') | 499 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 runtime = 'libclang_rt.asan-%s-android.so' % target_arch | 764 runtime = 'libclang_rt.asan-%s-android.so' % target_arch |
| 754 for root, _, files in os.walk(build_dir): | 765 for root, _, files in os.walk(build_dir): |
| 755 if runtime in files: | 766 if runtime in files: |
| 756 shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir) | 767 shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir) |
| 757 | 768 |
| 758 # Run tests. | 769 # Run tests. |
| 759 if args.run_tests or use_head_revision: | 770 if args.run_tests or use_head_revision: |
| 760 os.chdir(LLVM_BUILD_DIR) | 771 os.chdir(LLVM_BUILD_DIR) |
| 761 RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64') | 772 RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64') |
| 762 if args.run_tests: | 773 if args.run_tests: |
| 774 if sys.platform == 'win32': | |
| 775 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin')) | |
| 763 os.chdir(LLVM_BUILD_DIR) | 776 os.chdir(LLVM_BUILD_DIR) |
| 764 RunCommand(['ninja', 'check-all'], msvc_arch='x64') | 777 RunCommand(['ninja', 'check-all'], msvc_arch='x64') |
| 765 | 778 |
| 766 WriteStampFile(PACKAGE_VERSION) | 779 WriteStampFile(PACKAGE_VERSION) |
| 767 print 'Clang update was successful.' | 780 print 'Clang update was successful.' |
| 768 return 0 | 781 return 0 |
| 769 | 782 |
| 770 | 783 |
| 771 def main(): | 784 def main(): |
| 772 parser = argparse.ArgumentParser(description='Build Clang.') | 785 parser = argparse.ArgumentParser(description='Build Clang.') |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 args.force_local_build = True | 861 args.force_local_build = True |
| 849 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | 862 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 850 # Only build the Android ASan rt on ToT bots when targetting Android. | 863 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 851 args.with_android = False | 864 args.with_android = False |
| 852 | 865 |
| 853 return UpdateClang(args) | 866 return UpdateClang(args) |
| 854 | 867 |
| 855 | 868 |
| 856 if __name__ == '__main__': | 869 if __name__ == '__main__': |
| 857 sys.exit(main()) | 870 sys.exit(main()) |
| OLD | NEW |