OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 """Paths to common resources in the Chrome repository.""" | |
6 | |
7 import os | |
8 | |
9 import util | |
10 | |
11 | |
12 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | |
13 | |
14 | |
15 def GetSrc(): | |
16 """Returns the path to the root src directory.""" | |
17 return os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, os.pardir) | |
18 | |
19 | |
20 def GetTestData(): | |
21 """Returns the path to the src/chrome/test/data directory.""" | |
22 return os.path.join(GetSrc(), 'chrome', 'test', 'data') | |
23 | |
24 | |
25 def GetThirdParty(): | |
26 """Returns the path to the src/third_party directory.""" | |
27 return os.path.join(GetSrc(), 'third_party') | |
28 | |
29 | |
30 def GetBuildDir(required_paths): | |
31 """Returns the preferred build directory that contains given paths.""" | |
32 dirs = ['out', 'build', 'xcodebuild', 'sconsbuild'] | |
33 rel_dirs = [os.path.join(x, 'Release') for x in dirs] | |
34 debug_dirs = [os.path.join(x, 'Debug') for x in dirs] | |
35 full_dirs = [os.path.join(GetSrc(), x) for x in rel_dirs + debug_dirs] | |
36 for build_dir in full_dirs: | |
37 for required_path in required_paths: | |
38 if not os.path.exists(os.path.join(build_dir, required_path)): | |
39 break | |
40 else: | |
41 return build_dir | |
42 raise RuntimeError('Cannot find build directory containing ' + | |
43 ', '.join(required_paths)) | |
OLD | NEW |