| 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 parser.add_argument('--without-patches', action='store_false', | 706 parser.add_argument('--without-patches', action='store_false', |
| 707 help="don't apply patches (default)", dest='with_patches', | 707 help="don't apply patches (default)", dest='with_patches', |
| 708 default=True) | 708 default=True) |
| 709 | 709 |
| 710 # For now, these flags are only used for the non-Windows flow, but argparser | 710 # For now, these flags are only used for the non-Windows flow, but argparser |
| 711 # gets mad if it sees a flag it doesn't recognize. | 711 # gets mad if it sees a flag it doesn't recognize. |
| 712 parser.add_argument('--no-stdin-hack', action='store_true') | 712 parser.add_argument('--no-stdin-hack', action='store_true') |
| 713 | 713 |
| 714 args = parser.parse_args() | 714 args = parser.parse_args() |
| 715 | 715 |
| 716 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | |
| 717 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' | |
| 718 return 0 | |
| 719 if args.if_needed: | 716 if args.if_needed: |
| 720 is_clang_required = False | 717 is_clang_required = False |
| 721 # clang is always used on Mac and Linux. | 718 # clang is always used on Mac and Linux. |
| 722 if sys.platform == 'darwin' or sys.platform.startswith('linux'): | 719 if sys.platform == 'darwin' or sys.platform.startswith('linux'): |
| 723 is_clang_required = True | 720 is_clang_required = True |
| 724 # clang requested via $GYP_DEFINES. | 721 # clang requested via $GYP_DEFINES. |
| 725 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1', | 722 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1', |
| 726 os.environ.get('GYP_DEFINES', '')): | 723 os.environ.get('GYP_DEFINES', '')): |
| 727 is_clang_required = True | 724 is_clang_required = True |
| 728 # clang previously downloaded, keep it up-to-date. | 725 # clang previously downloaded, keep it up-to-date. |
| 729 # If you don't want this, delete third_party/llvm-build on your machine. | 726 # If you don't want this, delete third_party/llvm-build on your machine. |
| 730 if os.path.isdir(LLVM_BUILD_DIR): | 727 if os.path.isdir(LLVM_BUILD_DIR): |
| 731 is_clang_required = True | 728 is_clang_required = True |
| 732 if not is_clang_required: | 729 if not is_clang_required: |
| 733 return 0 | 730 return 0 |
| 734 | 731 |
| 735 global LLVM_WIN_REVISION, PACKAGE_VERSION | 732 global LLVM_WIN_REVISION, PACKAGE_VERSION |
| 736 if args.print_revision: | 733 if args.print_revision: |
| 737 if use_head_revision: | 734 if use_head_revision: |
| 738 print GetSvnRevision(LLVM_DIR) | 735 print GetSvnRevision(LLVM_DIR) |
| 739 else: | 736 else: |
| 740 print PACKAGE_VERSION | 737 print PACKAGE_VERSION |
| 741 return 0 | 738 return 0 |
| 742 | 739 |
| 740 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): |
| 741 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
| 742 return 0 |
| 743 |
| 743 # Don't buffer stdout, so that print statements are immediately flushed. | 744 # 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 | 745 # 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. | 746 # an error message when this script is run from gn for some reason. |
| 746 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) | 747 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) |
| 747 | 748 |
| 748 if use_head_revision: | 749 if use_head_revision: |
| 749 # Use a real revision number rather than HEAD to make sure that the stamp | 750 # Use a real revision number rather than HEAD to make sure that the stamp |
| 750 # file logic works. | 751 # file logic works. |
| 751 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) | 752 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) |
| 752 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' | 753 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' |
| 753 | 754 |
| 754 args.force_local_build = True | 755 args.force_local_build = True |
| 755 # Skip local patches when using HEAD: they probably don't apply anymore. | 756 # Skip local patches when using HEAD: they probably don't apply anymore. |
| 756 args.with_patches = False | 757 args.with_patches = False |
| 757 | 758 |
| 758 return UpdateClang(args) | 759 return UpdateClang(args) |
| 759 | 760 |
| 760 | 761 |
| 761 if __name__ == '__main__': | 762 if __name__ == '__main__': |
| 762 sys.exit(main()) | 763 sys.exit(main()) |
| OLD | NEW |