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..7fb5a98094a17e35ae90da39935045677e7dd184 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,18 @@ class ApkInfo(object): |
| self._Initialize() |
| def _Initialize(self): |
| + pickle_name = self._jar_path + "-proguard.pickle" |
|
frankf
2012/11/22 03:03:48
single quotes here and below.
Yaron
2012/11/26 18:26:15
Done.
|
| + if os.path.exists(pickle_name) and (os.stat(pickle_name).st_mtime > |
| + os.stat(self._jar_path).st_mtime): |
|
frankf
2012/11/22 03:03:48
os.path.getmtime() is slightly preferred.
Yaron
2012/11/26 18:26:15
Done.
|
| + logging.info("Loading cached proguard output from %s", pickle_name) |
|
bulach
2012/11/22 13:51:20
see below, probably best as:
try:
with open(pick
Yaron
2012/11/26 18:26:15
Done.
|
| + unpickler = pickle.Unpickler(open(pickle_name)) |
| + if PICKLE_FORMAT_VERSION == unpickler.load(): |
|
bulach
2012/11/22 13:51:20
prefer to pickle one dict, see below..
Yaron
2012/11/26 18:26:15
Done.
|
| + self._annotation_map = unpickler.load() |
| + self._test_methods = unpickler.load() |
| + return |
| + else: |
| + logging.warning("PICKLE_FORMAT_VERSION has changed, ignoring cache") |
|
frankf
2012/11/22 03:03:48
Can you put this in a finally block with above lin
Yaron
2012/11/26 18:26:15
Done.
|
| + |
| proguard_output = cmd_helper.GetCmdOutput([self._PROGUARD_PATH, |
| '-injars', self._jar_path, |
| '-dontshrink', |
| @@ -98,6 +114,12 @@ class ApkInfo(object): |
| annotation + ':' + value) |
| has_value = False |
| + logging.info("Storing proguard output to %s", pickle_name) |
| + pickler = pickle.Pickler(open(pickle_name, 'w')) |
|
bulach
2012/11/22 13:51:20
pickle.dumps with a dict works better, no need for
Yaron
2012/11/26 18:26:15
Done.
|
| + pickler.dump(PICKLE_FORMAT_VERSION) |
| + pickler.dump(self._annotation_map) |
| + pickler.dump(self._test_methods) |
| + |
| def _GetAnnotationMap(self): |
| return self._annotation_map |