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