Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: tools/binary_size/libsupersize/paths.py

Issue 2881563003: supersize: Make Disassemble() work for downloaded .size files (Closed)
Patch Set: self-review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SRC_ROOT = os.path.dirname(
15 os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
16
14 17
15 class LazyPaths(object): 18 class LazyPaths(object):
16 def __init__(self, tool_prefix=None, output_directory=None, 19 def __init__(self, tool_prefix=None, output_directory=None,
17 any_path_within_output_directory=None): 20 any_path_within_output_directory=None):
18 self._tool_prefix = tool_prefix 21 self._tool_prefix = tool_prefix
19 self._output_directory = output_directory 22 self._output_directory = output_directory
20 self._any_path_within_output_directory = any_path_within_output_directory 23 self._any_path_within_output_directory = any_path_within_output_directory
21 self._output_directory_status = ( 24 self._output_directory_status = (
22 _STATUS_DETECTED if output_directory is not None else 0) 25 _STATUS_DETECTED if output_directory is not None else 0)
23 self._tool_prefix_status = ( 26 self._tool_prefix_status = (
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return None 83 return None
81 84
82 def _DetectToolPrefix(self): 85 def _DetectToolPrefix(self):
83 output_directory = self.output_directory 86 output_directory = self.output_directory
84 if output_directory: 87 if output_directory:
85 # Auto-detect from build_vars.txt 88 # Auto-detect from build_vars.txt
86 build_vars_path = os.path.join(output_directory, 'build_vars.txt') 89 build_vars_path = os.path.join(output_directory, 'build_vars.txt')
87 if os.path.exists(build_vars_path): 90 if os.path.exists(build_vars_path):
88 with open(build_vars_path) as f: 91 with open(build_vars_path) as f:
89 build_vars = dict(l.rstrip().split('=', 1) for l in f if '=' in l) 92 build_vars = dict(l.rstrip().split('=', 1) for l in f if '=' in l)
90 return os.path.normpath( 93 tool_prefix = build_vars['android_tool_prefix']
91 os.path.join(output_directory, build_vars['android_tool_prefix'])) 94 ret = os.path.normpath(os.path.join(output_directory, tool_prefix))
95 # Need to maintain a trailing /.
96 if tool_prefix.endswith(os.path.sep):
97 ret += os.path.sep
98 return ret
99 from_path = distutils.spawn.find_executable('c++filt')
100 if from_path:
101 return from_path[:-7]
92 return None 102 return None
103
104
105 def FromSrcRootRelative(path):
106 ret = os.path.relpath(os.path.join(SRC_ROOT, path))
107 # Need to maintain a trailing /.
108 if path.endswith(os.path.sep):
109 ret += os.path.sep
110 return ret
111
112
113 def ToSrcRootRelative(path):
114 ret = os.path.relpath(path, SRC_ROOT)
115 # Need to maintain a trailing /.
116 if path.endswith(os.path.sep):
117 ret += os.path.sep
118 return ret
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698