| 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 top_dir[0] = os.path.normpath(line.rstrip('\n')) | 674 top_dir[0] = os.path.normpath(line.rstrip('\n')) |
| 675 try: | 675 try: |
| 676 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], | 676 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], |
| 677 print_stdout=False, filter_fn=filter_fn) | 677 print_stdout=False, filter_fn=filter_fn) |
| 678 except Exception: | 678 except Exception: |
| 679 pass | 679 pass |
| 680 top_dir = top_dir[0] | 680 top_dir = top_dir[0] |
| 681 if os.path.exists(os.path.join(top_dir, 'buildtools')): | 681 if os.path.exists(os.path.join(top_dir, 'buildtools')): |
| 682 return os.path.join(top_dir, 'buildtools') | 682 return os.path.join(top_dir, 'buildtools') |
| 683 return None | 683 return None |
| 684 return os.path.join(gclient_root, 'src', 'buildtools') | 684 |
| 685 # Some projects' top directory is not named 'src'. |
| 686 source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src' |
| 687 return os.path.join(gclient_root, source_dir_name, 'buildtools') |
| 685 | 688 |
| 686 | 689 |
| 687 def GetBuildtoolsPlatformBinaryPath(): | 690 def GetBuildtoolsPlatformBinaryPath(): |
| 688 """Returns the full path to the binary directory for the current platform.""" | 691 """Returns the full path to the binary directory for the current platform.""" |
| 689 # Mac and Windows just have one directory, Linux has two according to whether | 692 # Mac and Windows just have one directory, Linux has two according to whether |
| 690 # it's 32 or 64 bits. | 693 # it's 32 or 64 bits. |
| 691 buildtools_path = GetBuildtoolsPath() | 694 buildtools_path = GetBuildtoolsPath() |
| 692 if not buildtools_path: | 695 if not buildtools_path: |
| 693 return None | 696 return None |
| 694 | 697 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 706 return os.path.join(buildtools_path, subdir) | 709 return os.path.join(buildtools_path, subdir) |
| 707 | 710 |
| 708 | 711 |
| 709 def GetExeSuffix(): | 712 def GetExeSuffix(): |
| 710 """Returns '' or '.exe' depending on how executables work on this platform.""" | 713 """Returns '' or '.exe' depending on how executables work on this platform.""" |
| 711 if sys.platform.startswith(('cygwin', 'win')): | 714 if sys.platform.startswith(('cygwin', 'win')): |
| 712 return '.exe' | 715 return '.exe' |
| 713 return '' | 716 return '' |
| 714 | 717 |
| 715 | 718 |
| 719 def GetGClientPrimarySolutionName(gclient_root_dir_path): |
| 720 """Returns the name of the primary solution in the .gclient file specified.""" |
| 721 gclient_config_file = os.path.join(gclient_root_dir_path, '.gclient') |
| 722 env = {} |
| 723 execfile(gclient_config_file, env) |
| 724 solutions = env.get('solutions', []) |
| 725 if solutions: |
| 726 return solutions[0].get('name') |
| 727 return None |
| 728 |
| 729 |
| 716 def GetGClientRootAndEntries(path=None): | 730 def GetGClientRootAndEntries(path=None): |
| 717 """Returns the gclient root and the dict of entries.""" | 731 """Returns the gclient root and the dict of entries.""" |
| 718 config_file = '.gclient_entries' | 732 config_file = '.gclient_entries' |
| 719 root = FindFileUpwards(config_file, path) | 733 root = FindFileUpwards(config_file, path) |
| 720 if not root: | 734 if not root: |
| 721 print "Can't find %s" % config_file | 735 print "Can't find %s" % config_file |
| 722 return None | 736 return None |
| 723 config_path = os.path.join(root, config_file) | 737 config_path = os.path.join(root, config_file) |
| 724 env = {} | 738 env = {} |
| 725 execfile(config_path, env) | 739 execfile(config_path, env) |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 def DefaultIndexPackConfig(url=''): | 1155 def DefaultIndexPackConfig(url=''): |
| 1142 """Return reasonable default values for configuring git-index-pack. | 1156 """Return reasonable default values for configuring git-index-pack. |
| 1143 | 1157 |
| 1144 Experiments suggest that higher values for pack.threads don't improve | 1158 Experiments suggest that higher values for pack.threads don't improve |
| 1145 performance.""" | 1159 performance.""" |
| 1146 cache_limit = DefaultDeltaBaseCacheLimit() | 1160 cache_limit = DefaultDeltaBaseCacheLimit() |
| 1147 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1161 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
| 1148 if url in THREADED_INDEX_PACK_BLACKLIST: | 1162 if url in THREADED_INDEX_PACK_BLACKLIST: |
| 1149 result.extend(['-c', 'pack.threads=1']) | 1163 result.extend(['-c', 'pack.threads=1']) |
| 1150 return result | 1164 return result |
| OLD | NEW |