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 GetPrimarySolutionPath(): | 665 def GetPrimarySolutionPath(): |
agable
2016/08/03 16:39:50
The only things which call this function are GetBu
| |
666 """Returns the full path to the primary solution. (gclient_root + src)""" | 666 """Returns the full path to the primary solution. (gclient_root + src)""" |
667 | 667 |
668 gclient_root = FindGclientRoot(os.getcwd()) | 668 gclient_root = FindGclientRoot(os.getcwd()) |
669 if not gclient_root: | 669 if not gclient_root: |
agable
2016/08/03 16:39:50
Under what circumstances do we actually enter this
hanpfei
2016/08/04 01:35:57
I didn't call gclient. I just called gn.
I want to
| |
670 # 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 |
671 # checkout. | 671 # checkout. |
672 top_dir = [os.getcwd()] | 672 top_dir = [os.getcwd()] |
673 def filter_fn(line): | 673 def filter_fn(line): |
674 top_dir[0] = os.path.normpath(line.rstrip('\n')) | 674 repo_root_path = os.path.normpath(line.rstrip('\n')) |
675 if os.path.exists(repo_root_path): | |
676 top_dir[0] = repo_root_path | |
675 try: | 677 try: |
676 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], | 678 CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"], |
677 print_stdout=False, filter_fn=filter_fn) | 679 print_stdout=False, filter_fn=filter_fn) |
678 except Exception: | 680 except Exception: |
679 pass | 681 pass |
680 top_dir = top_dir[0] | 682 top_dir = top_dir[0] |
681 if os.path.exists(os.path.join(top_dir, 'buildtools')): | 683 if os.path.exists(os.path.join(top_dir, 'buildtools')): |
682 return top_dir | 684 return top_dir |
683 return None | 685 return None |
684 | 686 |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1223 # Just incase we have some ~/blah paths. | 1225 # Just incase we have some ~/blah paths. |
1224 target = os.path.abspath(os.path.expanduser(target)) | 1226 target = os.path.abspath(os.path.expanduser(target)) |
1225 if os.path.isfile(target) and os.access(target, os.X_OK): | 1227 if os.path.isfile(target) and os.access(target, os.X_OK): |
1226 return target | 1228 return target |
1227 if sys.platform.startswith('win'): | 1229 if sys.platform.startswith('win'): |
1228 for suffix in ('.bat', '.cmd', '.exe'): | 1230 for suffix in ('.bat', '.cmd', '.exe'): |
1229 alt_target = target + suffix | 1231 alt_target = target + suffix |
1230 if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK): | 1232 if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK): |
1231 return alt_target | 1233 return alt_target |
1232 return None | 1234 return None |
OLD | NEW |