| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 if deployment_target: | 626 if deployment_target: |
| 627 deployment_env = os.environ.copy() | 627 deployment_env = os.environ.copy() |
| 628 deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target | 628 deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target |
| 629 | 629 |
| 630 cmake_args = [] | 630 cmake_args = [] |
| 631 # TODO(thakis): Unconditionally append this to base_cmake_args instead once | 631 # TODO(thakis): Unconditionally append this to base_cmake_args instead once |
| 632 # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698) | 632 # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698) |
| 633 cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args | 633 cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args |
| 634 if cc is not None: cc_args.append('-DCMAKE_C_COMPILER=' + cc) | 634 if cc is not None: cc_args.append('-DCMAKE_C_COMPILER=' + cc) |
| 635 if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx) | 635 if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx) |
| 636 chrome_tools = list(set(['plugins', 'blink_gc_plugin'] + args.extra_tools)) |
| 636 cmake_args += base_cmake_args + [ | 637 cmake_args += base_cmake_args + [ |
| 637 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, | 638 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, |
| 638 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), | 639 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
| 639 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), | 640 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), |
| 640 '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), | 641 '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), |
| 641 '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags), | 642 '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags), |
| 642 '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags), | 643 '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags), |
| 643 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR, | 644 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR, |
| 644 # TODO(thakis): Remove this once official builds pass -Wl,--build-id | 645 # TODO(thakis): Remove this once official builds pass -Wl,--build-id |
| 645 # explicitly, https://crbug.com/622775 | 646 # explicitly, https://crbug.com/622775 |
| 646 '-DENABLE_LINKER_BUILD_ID=ON', | 647 '-DENABLE_LINKER_BUILD_ID=ON', |
| 647 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'), | 648 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'), |
| 648 '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)] | 649 '-DCHROMIUM_TOOLS=%s' % ';'.join(chrome_tools)] |
| 649 | 650 |
| 650 EnsureDirExists(LLVM_BUILD_DIR) | 651 EnsureDirExists(LLVM_BUILD_DIR) |
| 651 os.chdir(LLVM_BUILD_DIR) | 652 os.chdir(LLVM_BUILD_DIR) |
| 652 RmCmakeCache('.') | 653 RmCmakeCache('.') |
| 653 RunCommand(['cmake'] + cmake_args + [LLVM_DIR], | 654 RunCommand(['cmake'] + cmake_args + [LLVM_DIR], |
| 654 msvc_arch='x64', env=deployment_env) | 655 msvc_arch='x64', env=deployment_env) |
| 655 | 656 |
| 656 if args.gcc_toolchain: | 657 if args.gcc_toolchain: |
| 657 # Copy in the right stdlibc++.so.6 so clang can start. | 658 # Copy in the right stdlibc++.so.6 so clang can start. |
| 658 if not os.path.exists(os.path.join(LLVM_BUILD_DIR, 'lib')): | 659 if not os.path.exists(os.path.join(LLVM_BUILD_DIR, 'lib')): |
| 659 os.mkdir(os.path.join(LLVM_BUILD_DIR, 'lib')) | 660 os.mkdir(os.path.join(LLVM_BUILD_DIR, 'lib')) |
| 660 libstdcpp = subprocess.check_output( | 661 libstdcpp = subprocess.check_output( |
| 661 [cxx] + cxxflags + ['-print-file-name=libstdc++.so.6']).rstrip() | 662 [cxx] + cxxflags + ['-print-file-name=libstdc++.so.6']).rstrip() |
| 662 CopyFile(libstdcpp, os.path.join(LLVM_BUILD_DIR, 'lib')) | 663 CopyFile(libstdcpp, os.path.join(LLVM_BUILD_DIR, 'lib')) |
| 663 | 664 |
| 664 RunCommand(['ninja'], msvc_arch='x64') | 665 RunCommand(['ninja'], msvc_arch='x64') |
| 665 | 666 |
| 666 if args.tools: | 667 if chrome_tools: |
| 667 # If any Chromium tools were built, install those now. | 668 # If any Chromium tools were built, install those now. |
| 668 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') | 669 RunCommand(['ninja', 'cr-install'], msvc_arch='x64') |
| 669 | 670 |
| 670 if sys.platform == 'darwin': | 671 if sys.platform == 'darwin': |
| 671 # See http://crbug.com/256342 | 672 # See http://crbug.com/256342 |
| 672 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 673 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 673 elif sys.platform.startswith('linux'): | 674 elif sys.platform.startswith('linux'): |
| 674 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) | 675 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')]) |
| 675 | 676 |
| 676 VeryifyVersionOfBuiltClangMatchesVERSION() | 677 VeryifyVersionOfBuiltClangMatchesVERSION() |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 help='build LLVM Gold plugin with LTO') | 840 help='build LLVM Gold plugin with LTO') |
| 840 parser.add_argument('--llvm-force-head-revision', action='store_true', | 841 parser.add_argument('--llvm-force-head-revision', action='store_true', |
| 841 help=('use the revision in the repo when printing ' | 842 help=('use the revision in the repo when printing ' |
| 842 'the revision')) | 843 'the revision')) |
| 843 parser.add_argument('--print-revision', action='store_true', | 844 parser.add_argument('--print-revision', action='store_true', |
| 844 help='print current clang revision and exit.') | 845 help='print current clang revision and exit.') |
| 845 parser.add_argument('--print-clang-version', action='store_true', | 846 parser.add_argument('--print-clang-version', action='store_true', |
| 846 help='print current clang version (e.g. x.y.z) and exit.') | 847 help='print current clang version (e.g. x.y.z) and exit.') |
| 847 parser.add_argument('--run-tests', action='store_true', | 848 parser.add_argument('--run-tests', action='store_true', |
| 848 help='run tests after building; only for local builds') | 849 help='run tests after building; only for local builds') |
| 849 parser.add_argument('--tools', nargs='*', | 850 parser.add_argument('--extra-tools', '--tools', nargs='*', |
| 850 help='select which chrome tools to build', | 851 help='select additional chrome tools to build') |
| 851 default=['plugins', 'blink_gc_plugin']) | |
| 852 parser.add_argument('--without-android', action='store_false', | 852 parser.add_argument('--without-android', action='store_false', |
| 853 help='don\'t build Android ASan runtime (linux only)', | 853 help='don\'t build Android ASan runtime (linux only)', |
| 854 dest='with_android', | 854 dest='with_android', |
| 855 default=sys.platform.startswith('linux')) | 855 default=sys.platform.startswith('linux')) |
| 856 args = parser.parse_args() | 856 args = parser.parse_args() |
| 857 | 857 |
| 858 if args.lto_gold_plugin and not args.bootstrap: | 858 if args.lto_gold_plugin and not args.bootstrap: |
| 859 print '--lto-gold-plugin requires --bootstrap' | 859 print '--lto-gold-plugin requires --bootstrap' |
| 860 return 1 | 860 return 1 |
| 861 if args.lto_gold_plugin and not sys.platform.startswith('linux'): | 861 if args.lto_gold_plugin and not sys.platform.startswith('linux'): |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 args.force_local_build = True | 907 args.force_local_build = True |
| 908 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | 908 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 909 # Only build the Android ASan rt on ToT bots when targetting Android. | 909 # Only build the Android ASan rt on ToT bots when targetting Android. |
| 910 args.with_android = False | 910 args.with_android = False |
| 911 | 911 |
| 912 return UpdateClang(args) | 912 return UpdateClang(args) |
| 913 | 913 |
| 914 | 914 |
| 915 if __name__ == '__main__': | 915 if __name__ == '__main__': |
| 916 sys.exit(main()) | 916 sys.exit(main()) |
| OLD | NEW |