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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 """Returns 'mac', 'win', or 'linux', matching the current platform.""" | 643 """Returns 'mac', 'win', or 'linux', matching the current platform.""" |
644 if sys.platform.startswith(('cygwin', 'win')): | 644 if sys.platform.startswith(('cygwin', 'win')): |
645 return 'win' | 645 return 'win' |
646 elif sys.platform.startswith('linux'): | 646 elif sys.platform.startswith('linux'): |
647 return 'linux' | 647 return 'linux' |
648 elif sys.platform == 'darwin': | 648 elif sys.platform == 'darwin': |
649 return 'mac' | 649 return 'mac' |
650 raise Error('Unknown platform: ' + sys.platform) | 650 raise Error('Unknown platform: ' + sys.platform) |
651 | 651 |
652 | 652 |
| 653 def GetBuildtoolsPath(): |
| 654 """Returns the full path to the buildtools directory. |
| 655 This is based on the root of the checkout containing the current directory.""" |
| 656 gclient_root = FindGclientRoot(os.getcwd()) |
| 657 if not gclient_root: |
| 658 return None |
| 659 return os.path.join(gclient_root, 'src', 'buildtools') |
| 660 |
| 661 |
| 662 def GetBuildtoolsPlatformBinaryPath(): |
| 663 """Returns the full path to the binary directory for the current platform.""" |
| 664 # Mac and Windows just have one directory, Linux has two according to whether |
| 665 # it's 32 or 64 bits. |
| 666 buildtools_path = GetBuildtoolsPath() |
| 667 if not buildtools_path: |
| 668 return None |
| 669 |
| 670 if sys.platform.startswith(('cygwin', 'win')): |
| 671 subdir = 'win' |
| 672 elif sys.platform == 'darwin': |
| 673 subdir = 'mac' |
| 674 elif sys.platform.startswith('linux'): |
| 675 if sys.maxsize > 2**32: |
| 676 subdir = 'linux64' |
| 677 else: |
| 678 subdir = 'linux32' |
| 679 else: |
| 680 raise Error('Unknown platform: ' + sys.platform) |
| 681 return os.path.join(buildtools_path, subdir) |
| 682 |
| 683 |
653 def GetExeSuffix(): | 684 def GetExeSuffix(): |
654 """Returns '' or '.exe' depending on how executables work on this platform.""" | 685 """Returns '' or '.exe' depending on how executables work on this platform.""" |
655 if sys.platform.startswith(('cygwin', 'win')): | 686 if sys.platform.startswith(('cygwin', 'win')): |
656 return '.exe' | 687 return '.exe' |
657 return '' | 688 return '' |
658 | 689 |
659 | 690 |
660 def GetGClientRootAndEntries(path=None): | 691 def GetGClientRootAndEntries(path=None): |
661 """Returns the gclient root and the dict of entries.""" | 692 """Returns the gclient root and the dict of entries.""" |
662 config_file = '.gclient_entries' | 693 config_file = '.gclient_entries' |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 def DefaultIndexPackConfig(url=''): | 1114 def DefaultIndexPackConfig(url=''): |
1084 """Return reasonable default values for configuring git-index-pack. | 1115 """Return reasonable default values for configuring git-index-pack. |
1085 | 1116 |
1086 Experiments suggest that higher values for pack.threads don't improve | 1117 Experiments suggest that higher values for pack.threads don't improve |
1087 performance.""" | 1118 performance.""" |
1088 cache_limit = DefaultDeltaBaseCacheLimit() | 1119 cache_limit = DefaultDeltaBaseCacheLimit() |
1089 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1120 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
1090 if url in THREADED_INDEX_PACK_BLACKLIST: | 1121 if url in THREADED_INDEX_PACK_BLACKLIST: |
1091 result.extend(['-c', 'pack.threads=1']) | 1122 result.extend(['-c', 'pack.threads=1']) |
1092 return result | 1123 return result |
OLD | NEW |