| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (C) 2013 The Android Open Source Project | 3 # Copyright (C) 2013 The Android Open Source Project |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 | 112 |
| 113 def GetBasenameFromMojoApp(url): | 113 def GetBasenameFromMojoApp(url): |
| 114 """Used by GetSymbolMapping() to extract the basename from the location the | 114 """Used by GetSymbolMapping() to extract the basename from the location the |
| 115 mojo app was downloaded from. The location is a URL, e.g. | 115 mojo app was downloaded from. The location is a URL, e.g. |
| 116 http://foo/bar/x.so.""" | 116 http://foo/bar/x.so.""" |
| 117 index = url.rfind('/') | 117 index = url.rfind('/') |
| 118 return url[(index + 1):] if index != -1 else url | 118 return url[(index + 1):] if index != -1 else url |
| 119 | 119 |
| 120 | 120 |
| 121 def GetSymboledNameForMojoApp(path): |
| 122 """Used by GetSymbolMapping to get the non-stripped library name for an |
| 123 installed mojo app.""" |
| 124 # e.g. tracing.mojo -> libtracing_library.so |
| 125 name, ext = os.path.splitext(path) |
| 126 if ext != '.mojo': |
| 127 return path |
| 128 return 'lib%s_library.so' % name |
| 129 |
| 130 |
| 121 def GetSymbolMapping(lines): | 131 def GetSymbolMapping(lines): |
| 122 """Returns a mapping (dictionary) from download file to .so.""" | 132 """Returns a mapping (dictionary) from download file to .so.""" |
| 123 regex = re.compile('Caching mojo app (\S+) at (\S+)') | 133 regex = re.compile('Caching mojo app (\S+) at (\S+)') |
| 134 # lib_mojo_shell.so moved to mojo_shell as part of building the APK |
| 135 # currently this is the only library for which we do this. |
| 136 # The install path of the apk can change every install, hence the regexp. |
| 137 lib_mojo_regexp = re.compile(r'(/data/app/.*/libmojo_shell\.so)') |
| 124 mappings = {} | 138 mappings = {} |
| 125 for line in lines: | 139 for line in lines: |
| 140 lib_mojo_result = lib_mojo_regexp.search(line) |
| 141 if lib_mojo_result: |
| 142 mappings[lib_mojo_result.group(1)] = 'mojo_shell' |
| 143 |
| 126 result = regex.search(line) | 144 result = regex.search(line) |
| 127 if result: | 145 if result: |
| 128 mappings[result.group(2)] = GetBasenameFromMojoApp(result.group(1)) | 146 url = GetBasenameFromMojoApp(result.group(1)) |
| 147 mappings[result.group(2)] = GetSymboledNameForMojoApp(url) |
| 129 return mappings | 148 return mappings |
| 130 | 149 |
| 131 | 150 |
| 132 def main(): | 151 def main(): |
| 133 try: | 152 try: |
| 134 options, arguments = getopt.getopt(sys.argv[1:], "", | 153 options, arguments = getopt.getopt(sys.argv[1:], "", |
| 135 ["more-info", | 154 ["more-info", |
| 136 "less-info", | 155 "less-info", |
| 137 "mojo-symbols-dir=", | 156 "mojo-symbols-dir=", |
| 138 "symbols-dir=", | 157 "symbols-dir=", |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if rootdir: | 203 if rootdir: |
| 185 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work | 204 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work |
| 186 cmd = "rm -rf \"%s\"" % rootdir | 205 cmd = "rm -rf \"%s\"" % rootdir |
| 187 print "\ncleaning up (%s)" % cmd | 206 print "\ncleaning up (%s)" % cmd |
| 188 os.system(cmd) | 207 os.system(cmd) |
| 189 | 208 |
| 190 if __name__ == "__main__": | 209 if __name__ == "__main__": |
| 191 main() | 210 main() |
| 192 | 211 |
| 193 # vi: ts=2 sw=2 | 212 # vi: ts=2 sw=2 |
| OLD | NEW |