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 """Windows can't run .sh files, so this is a Python implementation of | 6 """Windows can't run .sh files, so this is a Python implementation of |
7 update.sh. This script should replace update.sh on all platforms eventually.""" | 7 update.sh. This script should replace update.sh on all platforms eventually.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import contextlib | 10 import contextlib |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') | 53 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') |
54 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') | 54 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') |
55 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld') | 55 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld') |
56 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') | 56 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') |
57 LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx') | 57 LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx') |
58 LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi') | 58 LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi') |
59 LLVM_BUILD_TOOLS_DIR = os.path.abspath( | 59 LLVM_BUILD_TOOLS_DIR = os.path.abspath( |
60 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) | 60 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) |
61 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision') | 61 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision') |
62 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils') | 62 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils') |
63 VERSION = '3.7.0' | 63 VERSION = '3.7.0' |
Nico
2015/07/16 17:50:00
This needs to be bumped to 3.8.0 too, as I just le
hans
2015/07/16 17:51:04
Sorry, I should have put a TODO here too :(
Nico
2015/07/16 17:51:23
(it's only used when building clang, so it can be
hans
2015/07/16 17:59:47
I'm not following. It's also used by --print-clang
Nico
2015/07/16 18:02:14
Oh, right. It wasn't used before this CL though (I
| |
64 | 64 |
65 # URL for pre-built binaries. | 65 # URL for pre-built binaries. |
66 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang' | 66 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang' |
67 | 67 |
68 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' | 68 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' |
69 if 'LLVM_REPO_URL' in os.environ: | 69 if 'LLVM_REPO_URL' in os.environ: |
70 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] | 70 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] |
71 | 71 |
72 | 72 |
73 def DownloadUrl(url, output_file): | 73 def DownloadUrl(url, output_file): |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 | 690 |
691 parser = argparse.ArgumentParser(description='Build Clang.') | 691 parser = argparse.ArgumentParser(description='Build Clang.') |
692 parser.add_argument('--bootstrap', action='store_true', | 692 parser.add_argument('--bootstrap', action='store_true', |
693 help='first build clang with CC, then with itself.') | 693 help='first build clang with CC, then with itself.') |
694 parser.add_argument('--if-needed', action='store_true', | 694 parser.add_argument('--if-needed', action='store_true', |
695 help="run only if the script thinks clang is needed") | 695 help="run only if the script thinks clang is needed") |
696 parser.add_argument('--force-local-build', action='store_true', | 696 parser.add_argument('--force-local-build', action='store_true', |
697 help="don't try to download prebuild binaries") | 697 help="don't try to download prebuild binaries") |
698 parser.add_argument('--print-revision', action='store_true', | 698 parser.add_argument('--print-revision', action='store_true', |
699 help='print current clang revision and exit.') | 699 help='print current clang revision and exit.') |
700 parser.add_argument('--print-clang-version', action='store_true', | |
701 help='print current clang version (e.g. x.y.z) and exit.') | |
700 parser.add_argument('--run-tests', action='store_true', | 702 parser.add_argument('--run-tests', action='store_true', |
701 help='run tests after building; only for local builds') | 703 help='run tests after building; only for local builds') |
702 parser.add_argument('--tools', nargs='*', | 704 parser.add_argument('--tools', nargs='*', |
703 help='select which chrome tools to build', | 705 help='select which chrome tools to build', |
704 default=['plugins', 'blink_gc_plugin']) | 706 default=['plugins', 'blink_gc_plugin']) |
705 parser.add_argument('--without-patches', action='store_false', | 707 parser.add_argument('--without-patches', action='store_false', |
706 help="don't apply patches (default)", dest='with_patches', | 708 help="don't apply patches (default)", dest='with_patches', |
707 default=True) | 709 default=True) |
708 | 710 |
709 # For now, these flags are only used for the non-Windows flow, but argparser | 711 # For now, these flags are only used for the non-Windows flow, but argparser |
(...skipping 11 matching lines...) Expand all Loading... | |
721 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1', | 723 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1', |
722 os.environ.get('GYP_DEFINES', '')): | 724 os.environ.get('GYP_DEFINES', '')): |
723 is_clang_required = True | 725 is_clang_required = True |
724 # clang previously downloaded, keep it up-to-date. | 726 # clang previously downloaded, keep it up-to-date. |
725 # If you don't want this, delete third_party/llvm-build on your machine. | 727 # If you don't want this, delete third_party/llvm-build on your machine. |
726 if os.path.isdir(LLVM_BUILD_DIR): | 728 if os.path.isdir(LLVM_BUILD_DIR): |
727 is_clang_required = True | 729 is_clang_required = True |
728 if not is_clang_required: | 730 if not is_clang_required: |
729 return 0 | 731 return 0 |
730 | 732 |
733 if use_head_revision: | |
734 # TODO(hans): Remove after the next roll. | |
735 global VERSION | |
736 VERSION = '3.8.0' | |
737 | |
731 global LLVM_WIN_REVISION, PACKAGE_VERSION | 738 global LLVM_WIN_REVISION, PACKAGE_VERSION |
732 if args.print_revision: | 739 if args.print_revision: |
733 if use_head_revision: | 740 if use_head_revision: |
734 print GetSvnRevision(LLVM_DIR) | 741 print GetSvnRevision(LLVM_DIR) |
735 else: | 742 else: |
736 print PACKAGE_VERSION | 743 print PACKAGE_VERSION |
737 return 0 | 744 return 0 |
738 | 745 |
746 if args.print_clang_version: | |
747 sys.stdout.write(VERSION) | |
748 return 0 | |
749 | |
739 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | 750 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): |
740 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' | 751 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
741 return 0 | 752 return 0 |
742 | 753 |
743 # Don't buffer stdout, so that print statements are immediately flushed. | 754 # Don't buffer stdout, so that print statements are immediately flushed. |
744 # Do this only after --print-revision has been handled, else we'll get | 755 # Do this only after --print-revision has been handled, else we'll get |
745 # an error message when this script is run from gn for some reason. | 756 # an error message when this script is run from gn for some reason. |
746 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) | 757 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) |
747 | 758 |
748 if use_head_revision: | 759 if use_head_revision: |
749 # Use a real revision number rather than HEAD to make sure that the stamp | 760 # Use a real revision number rather than HEAD to make sure that the stamp |
750 # file logic works. | 761 # file logic works. |
751 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) | 762 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) |
752 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' | 763 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' |
753 | 764 |
754 args.force_local_build = True | 765 args.force_local_build = True |
755 # Skip local patches when using HEAD: they probably don't apply anymore. | 766 # Skip local patches when using HEAD: they probably don't apply anymore. |
756 args.with_patches = False | 767 args.with_patches = False |
757 | 768 |
758 return UpdateClang(args) | 769 return UpdateClang(args) |
759 | 770 |
760 | 771 |
761 if __name__ == '__main__': | 772 if __name__ == '__main__': |
762 sys.exit(main()) | 773 sys.exit(main()) |
OLD | NEW |