Chromium Code Reviews| Index: build/android/pylib/apk_info.py |
| diff --git a/build/android/pylib/apk_info.py b/build/android/pylib/apk_info.py |
| index 6b0b7f63e68430d02eca6a264a4ea3b50717993f..aa5531705c7a59a74a92d8546cab42821ad3286c 100644 |
| --- a/build/android/pylib/apk_info.py |
| +++ b/build/android/pylib/apk_info.py |
| @@ -5,11 +5,15 @@ |
| """Gathers information about APKs.""" |
| import collections |
| +import logging |
| import os |
| +import pickle |
| import re |
| import cmd_helper |
| +# If you change the cached output of proguard, increment this number |
| +PICKLE_FORMAT_VERSION = 1 |
| def GetPackageNameForApk(apk_path): |
| """Returns the package name of the apk file.""" |
| @@ -50,6 +54,20 @@ class ApkInfo(object): |
| self._Initialize() |
| def _Initialize(self): |
| + pickle_name = self._jar_path + '-proguard.pickle' |
| + if os.path.exists(pickle_name) and (os.path.getmtime(pickle_name) > |
| + os.path.getmtime(self._jar_path)): |
| + logging.info('Loading cached proguard output from %s', pickle_name) |
| + try: |
| + with open(pickle_name, 'r') as r: |
| + d = pickle.loads(r.read()) |
| + if d['VERSION'] == PICKLE_FORMAT_VERSION: |
| + self._annotation_map = d['ANNOTATION_MAP'] |
| + self._test_methods = d['TEST_METHODS'] |
| + return |
| + except: |
| + logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache') |
|
frankf
2012/11/26 19:09:08
Optional: For sake of modularity, can you factor o
Yaron
2012/11/27 18:06:18
Done.
|
| + |
| proguard_output = cmd_helper.GetCmdOutput([self._PROGUARD_PATH, |
| '-injars', self._jar_path, |
| '-dontshrink', |
| @@ -98,6 +116,13 @@ class ApkInfo(object): |
| annotation + ':' + value) |
| has_value = False |
| + logging.info('Storing proguard output to %s', pickle_name) |
| + d = {'VERSION': PICKLE_FORMAT_VERSION, |
| + 'ANNOTATION_MAP': self._annotation_map, |
| + 'TEST_METHODS': self._test_methods} |
| + with open(pickle_name, 'w') as f: |
| + f.write(pickle.dumps(d)) |
| + |
| def _GetAnnotationMap(self): |
| return self._annotation_map |