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

Unified Diff: build/android/gyp/util/proguard_util.py

Issue 1433873004: GN: Enable proguard for apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nites Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/gyp/proguard.py ('k') | build/android/gyp/write_build_config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/util/proguard_util.py
diff --git a/build/android/gyp/util/proguard_util.py b/build/android/gyp/util/proguard_util.py
index 901cd9f2a8f30c5491986492cc3a4575776ef8a2..8ca86462631939eb0f44eb2b506b8e508e5fe762 100644
--- a/build/android/gyp/util/proguard_util.py
+++ b/build/android/gyp/util/proguard_util.py
@@ -32,45 +32,55 @@ class ProguardCmdBuilder(object):
def __init__(self, proguard_jar):
assert os.path.exists(proguard_jar)
self._proguard_jar_path = proguard_jar
- self._test = None
+ self._tested_apk_info_path = None
+ self._tested_apk_info = None
self._mapping = None
self._libraries = None
self._injars = None
self._configs = None
self._outjar = None
+ self._cmd = None
def outjar(self, path):
+ assert self._cmd is None
assert self._outjar is None
self._outjar = path
- def is_test(self, enable):
- assert self._test is None
- self._test = enable
+ def tested_apk_info(self, tested_apk_info_path):
+ assert self._cmd is None
+ assert self._tested_apk_info is None
+ self._tested_apk_info_path = tested_apk_info_path
def mapping(self, path):
+ assert self._cmd is None
assert self._mapping is None
assert os.path.exists(path), path
self._mapping = path
def libraryjars(self, paths):
+ assert self._cmd is None
assert self._libraries is None
for p in paths:
assert os.path.exists(p), p
self._libraries = paths
def injars(self, paths):
+ assert self._cmd is None
assert self._injars is None
for p in paths:
assert os.path.exists(p), p
self._injars = paths
def configs(self, paths):
+ assert self._cmd is None
assert self._configs is None
for p in paths:
assert os.path.exists(p), p
self._configs = paths
def build(self):
+ if self._cmd:
+ return self._cmd
assert self._injars is not None
assert self._outjar is not None
assert self._configs is not None
@@ -78,7 +88,16 @@ class ProguardCmdBuilder(object):
'java', '-jar', self._proguard_jar_path,
'-forceprocessing',
]
- if self._test:
+ if self._tested_apk_info_path:
+ assert len(self._configs) == 1
+ tested_apk_info = build_utils.ReadJson(self._tested_apk_info_path)
+ self._configs += tested_apk_info['configs']
+ self._injars = [
+ p for p in self._injars if not p in tested_apk_info['inputs']]
+ if not self._libraries:
+ self._libraries = []
+ self._libraries += tested_apk_info['inputs']
+ self._mapping = tested_apk_info['mapping']
cmd += [
'-dontobfuscate',
'-dontoptimize',
@@ -111,18 +130,38 @@ class ProguardCmdBuilder(object):
'-printusage', self._outjar + '.usage',
'-printmapping', self._outjar + '.mapping',
]
- return cmd
+ self._cmd = cmd
+ return self._cmd
def GetInputs(self):
+ self.build()
inputs = [self._proguard_jar_path] + self._configs + self._injars
if self._mapping:
inputs.append(self._mapping)
if self._libraries:
inputs += self._libraries
+ if self._tested_apk_info_path:
+ inputs += [self._tested_apk_info_path]
return inputs
def CheckOutput(self):
- build_utils.CheckOutput(self.build(), print_stdout=True,
+ self.build()
+ # Proguard will skip writing these files if they would be empty. Create
+ # empty versions of them all now so that they are updated as the build
+ # expects.
+ open(self._outjar + '.dump', 'w').close()
+ open(self._outjar + '.seeds', 'w').close()
+ open(self._outjar + '.usage', 'w').close()
+ open(self._outjar + '.mapping', 'w').close()
+ build_utils.CheckOutput(self._cmd, print_stdout=True,
stdout_filter=FilterProguardOutput)
+ this_info = {
+ 'inputs': self._injars,
+ 'configs': self._configs,
+ 'mapping': self._outjar + '.mapping',
+ }
+
+ build_utils.WriteJson(this_info, self._outjar + '.info')
+
« no previous file with comments | « build/android/gyp/proguard.py ('k') | build/android/gyp/write_build_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698