OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 """Functions for dealing with determining --tool-prefix.""" | 5 """Functions for dealing with determining --tool-prefix.""" |
6 | 6 |
7 import distutils.spawn | 7 import distutils.spawn |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 | 10 |
11 _STATUS_DETECTED = 1 | 11 _STATUS_DETECTED = 1 |
12 _STATUS_VERIFIED = 2 | 12 _STATUS_VERIFIED = 2 |
13 | 13 |
14 | 14 |
15 class LazyPaths(object): | 15 class LazyPaths(object): |
16 def __init__(self, tool_prefix=None, output_directory=None, | 16 def __init__(self, tool_prefix=None, output_directory=None, |
17 any_path_within_output_directory=None): | 17 any_path_within_output_directory=None): |
18 self._tool_prefix = tool_prefix | 18 self._tool_prefix = tool_prefix |
19 self._output_directory = output_directory | 19 self._output_directory = output_directory |
20 self._any_path_within_output_directory = any_path_within_output_directory | 20 self._any_path_within_output_directory = any_path_within_output_directory |
21 self._output_directory_status = _STATUS_DETECTED if output_directory else 0 | 21 self._output_directory_status = ( |
22 self._tool_prefix_status = _STATUS_DETECTED if tool_prefix else 0 | 22 _STATUS_DETECTED if output_directory is not None else 0) |
| 23 self._tool_prefix_status = ( |
| 24 _STATUS_DETECTED if tool_prefix is not None else 0) |
23 | 25 |
24 @property | 26 @property |
25 def tool_prefix(self): | 27 def tool_prefix(self): |
26 if self._tool_prefix_status < _STATUS_DETECTED: | 28 if self._tool_prefix_status < _STATUS_DETECTED: |
27 self._tool_prefix_status = _STATUS_DETECTED | 29 self._tool_prefix_status = _STATUS_DETECTED |
28 self._tool_prefix = self._DetectToolPrefix() or '' | 30 self._tool_prefix = self._DetectToolPrefix() or '' |
29 logging.debug('Detected --tool-prefix=%s', self._tool_prefix) | 31 logging.debug('Detected --tool-prefix=%s', self._tool_prefix) |
30 return self._tool_prefix | 32 return self._tool_prefix |
31 | 33 |
32 @property | 34 @property |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 output_directory = self.output_directory | 83 output_directory = self.output_directory |
82 if output_directory: | 84 if output_directory: |
83 # Auto-detect from build_vars.txt | 85 # Auto-detect from build_vars.txt |
84 build_vars_path = os.path.join(output_directory, 'build_vars.txt') | 86 build_vars_path = os.path.join(output_directory, 'build_vars.txt') |
85 if os.path.exists(build_vars_path): | 87 if os.path.exists(build_vars_path): |
86 with open(build_vars_path) as f: | 88 with open(build_vars_path) as f: |
87 build_vars = dict(l.rstrip().split('=', 1) for l in f if '=' in l) | 89 build_vars = dict(l.rstrip().split('=', 1) for l in f if '=' in l) |
88 return os.path.normpath( | 90 return os.path.normpath( |
89 os.path.join(output_directory, build_vars['android_tool_prefix'])) | 91 os.path.join(output_directory, build_vars['android_tool_prefix'])) |
90 return None | 92 return None |
OLD | NEW |