OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import os | 5 import os |
6 import re | 6 import re |
7 import tempfile | 7 import tempfile |
8 | 8 |
9 from pylib import constants | 9 from pylib import constants |
10 from pylib import cmd_helper | 10 from pylib import cmd_helper |
11 | 11 |
12 | 12 |
13 _PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$') | 13 _PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$') |
14 _PROGUARD_SUPERCLASS_RE = re.compile(r'\s*? Superclass:\s*([\S]+)$') | 14 _PROGUARD_SUPERCLASS_RE = re.compile(r'\s*? Superclass:\s*([\S]+)$') |
15 _PROGUARD_SECTION_RE = re.compile( | 15 _PROGUARD_SECTION_RE = re.compile( |
16 r'^(?:Interfaces|Constant Pool|Fields|Methods|Class file attributes) ' | 16 r'^(?:Interfaces|Constant Pool|Fields|Methods|Class file attributes) ' |
17 r'\(count = \d+\):$') | 17 r'\(count = \d+\):$') |
18 _PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$') | 18 _PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$') |
19 _PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$') | 19 _PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$') |
20 _PROGUARD_ANNOTATION_CONST_RE = ( | 20 _PROGUARD_ANNOTATION_CONST_RE = ( |
21 re.compile(r'\s*?- Constant element value.*$')) | 21 re.compile(r'\s*?- Constant element value.*$')) |
22 _PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$') | 22 _PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$') |
23 | 23 |
24 _PROGUARD_PATH_SDK = os.path.join( | 24 _PROGUARD_PATH_SDK = os.path.join( |
25 constants.ANDROID_SDK_ROOT, 'tools', 'proguard', 'lib', 'proguard.jar') | 25 constants.PROGUARD_ROOT, 'lib', 'proguard.jar') |
26 _PROGUARD_PATH_BUILT = ( | 26 _PROGUARD_PATH_BUILT = ( |
27 os.path.join(os.environ['ANDROID_BUILD_TOP'], 'external', 'proguard', | 27 os.path.join(os.environ['ANDROID_BUILD_TOP'], 'external', 'proguard', |
28 'lib', 'proguard.jar') | 28 'lib', 'proguard.jar') |
29 if 'ANDROID_BUILD_TOP' in os.environ else None) | 29 if 'ANDROID_BUILD_TOP' in os.environ else None) |
30 _PROGUARD_PATH = ( | 30 _PROGUARD_PATH = ( |
31 _PROGUARD_PATH_SDK if os.path.exists(_PROGUARD_PATH_SDK) | 31 _PROGUARD_PATH_SDK if os.path.exists(_PROGUARD_PATH_SDK) |
32 else _PROGUARD_PATH_BUILT) | 32 else _PROGUARD_PATH_BUILT) |
33 | 33 |
34 | 34 |
35 def Dump(jar_path): | 35 def Dump(jar_path): |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 m = _PROGUARD_ANNOTATION_VALUE_RE.match(line) | 139 m = _PROGUARD_ANNOTATION_VALUE_RE.match(line) |
140 if m: | 140 if m: |
141 if method_result: | 141 if method_result: |
142 method_result['annotations'][annotation] = m.group(1) | 142 method_result['annotations'][annotation] = m.group(1) |
143 else: | 143 else: |
144 class_result['annotations'][annotation] = m.group(1) | 144 class_result['annotations'][annotation] = m.group(1) |
145 annotation_has_value = None | 145 annotation_has_value = None |
146 | 146 |
147 return results | 147 return results |
148 | 148 |
OLD | NEW |