OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Generic utils.""" | 5 """Generic utils.""" |
6 | 6 |
7 import codecs | 7 import codecs |
8 import cStringIO | 8 import cStringIO |
9 import datetime | 9 import datetime |
10 import logging | 10 import logging |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 """Returns 'mac', 'win', or 'linux', matching the current platform.""" | 655 """Returns 'mac', 'win', or 'linux', matching the current platform.""" |
656 if sys.platform.startswith(('cygwin', 'win')): | 656 if sys.platform.startswith(('cygwin', 'win')): |
657 return 'win' | 657 return 'win' |
658 elif sys.platform.startswith('linux'): | 658 elif sys.platform.startswith('linux'): |
659 return 'linux' | 659 return 'linux' |
660 elif sys.platform == 'darwin': | 660 elif sys.platform == 'darwin': |
661 return 'mac' | 661 return 'mac' |
662 raise Error('Unknown platform: ' + sys.platform) | 662 raise Error('Unknown platform: ' + sys.platform) |
663 | 663 |
664 | 664 |
665 def GetBuildtoolsPath(): | 665 def GetPrimarySolutionPath(): |
666 """Returns the full path to the buildtools directory. | 666 """Returns the full path to the primary solution. (gclient_root + src)""" |
667 This is based on the root of the checkout containing the current directory.""" | |
668 | |
669 # Overriding the build tools path by environment is highly unsupported and may | |
670 # break without warning. Do not rely on this for anything important. | |
671 override = os.environ.get('CHROMIUM_BUILDTOOLS_PATH') | |
672 if override is not None: | |
673 return override | |
674 | 667 |
675 gclient_root = FindGclientRoot(os.getcwd()) | 668 gclient_root = FindGclientRoot(os.getcwd()) |
676 if not gclient_root: | 669 if not gclient_root: |
677 # Some projects might not use .gclient. Try to see whether we're in a git | 670 # Some projects might not use .gclient. Try to see whether we're in a git |
678 # checkout. | 671 # checkout. |
679 top_dir = [os.getcwd()] | 672 top_dir = [os.getcwd()] |
680 def filter_fn(line): | 673 def filter_fn(line): |
681 top_dir[0] = os.path.normpath(line.rstrip('\n')) | 674 top_dir[0] = os.path.normpath(line.rstrip('\n')) |
682 try: | 675 try: |
683 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], | 676 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], |
684 print_stdout=False, filter_fn=filter_fn) | 677 print_stdout=False, filter_fn=filter_fn) |
685 except Exception: | 678 except Exception: |
686 pass | 679 pass |
687 top_dir = top_dir[0] | 680 top_dir = top_dir[0] |
688 if os.path.exists(os.path.join(top_dir, 'buildtools')): | 681 if os.path.exists(os.path.join(top_dir, 'buildtools')): |
689 return os.path.join(top_dir, 'buildtools') | 682 return os.path.join(top_dir, 'buildtools') |
690 return None | 683 return None |
691 | 684 |
692 # Some projects' top directory is not named 'src'. | 685 # Some projects' top directory is not named 'src'. |
693 source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src' | 686 source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src' |
694 buildtools_path = os.path.join(gclient_root, source_dir_name, 'buildtools') | 687 return os.path.join(gclient_root, source_dir_name) |
| 688 |
| 689 |
| 690 def GetBuildtoolsPath(): |
| 691 """Returns the full path to the buildtools directory. |
| 692 This is based on the root of the checkout containing the current directory.""" |
| 693 |
| 694 # Overriding the build tools path by environment is highly unsupported and may |
| 695 # break without warning. Do not rely on this for anything important. |
| 696 override = os.environ.get('CHROMIUM_BUILDTOOLS_PATH') |
| 697 if override is not None: |
| 698 return override |
| 699 |
| 700 primary_solution = GetPrimarySolutionPath() |
| 701 buildtools_path = os.path.join(primary_solution, 'buildtools') |
695 if not os.path.exists(buildtools_path): | 702 if not os.path.exists(buildtools_path): |
696 # Buildtools may be in the gclient root. | 703 # Buildtools may be in the gclient root. |
| 704 gclient_root = FindGclientRoot(os.getcwd()) |
697 buildtools_path = os.path.join(gclient_root, 'buildtools') | 705 buildtools_path = os.path.join(gclient_root, 'buildtools') |
698 return buildtools_path | 706 return buildtools_path |
699 | 707 |
700 | 708 |
701 def GetBuildtoolsPlatformBinaryPath(): | 709 def GetBuildtoolsPlatformBinaryPath(): |
702 """Returns the full path to the binary directory for the current platform.""" | 710 """Returns the full path to the binary directory for the current platform.""" |
703 # Mac and Windows just have one directory, Linux has two according to whether | 711 # Mac and Windows just have one directory, Linux has two according to whether |
704 # it's 32 or 64 bits. | 712 # it's 32 or 64 bits. |
705 buildtools_path = GetBuildtoolsPath() | 713 buildtools_path = GetBuildtoolsPath() |
706 if not buildtools_path: | 714 if not buildtools_path: |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 def DefaultIndexPackConfig(url=''): | 1191 def DefaultIndexPackConfig(url=''): |
1184 """Return reasonable default values for configuring git-index-pack. | 1192 """Return reasonable default values for configuring git-index-pack. |
1185 | 1193 |
1186 Experiments suggest that higher values for pack.threads don't improve | 1194 Experiments suggest that higher values for pack.threads don't improve |
1187 performance.""" | 1195 performance.""" |
1188 cache_limit = DefaultDeltaBaseCacheLimit() | 1196 cache_limit = DefaultDeltaBaseCacheLimit() |
1189 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1197 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
1190 if url in THREADED_INDEX_PACK_BLACKLIST: | 1198 if url in THREADED_INDEX_PACK_BLACKLIST: |
1191 result.extend(['-c', 'pack.threads=1']) | 1199 result.extend(['-c', 'pack.threads=1']) |
1192 return result | 1200 return result |
OLD | NEW |