forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for proguard preprocessing.
* Adds support for running proguard on our libraries before they are added to the final release APK. * Start using the proguard preprocessing for third_party/guava. BUG=272790 NOTRY=true TBR=darin@chromium.org Review URL: https://chromiumcodereview.appspot.com/23213002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217706 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
cjhopman@chromium.org
committed
Aug 15, 2013
1 parent
8ce89cd
commit 582a857
Showing
4 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import fnmatch | ||
import optparse | ||
import os | ||
import sys | ||
|
||
from util import build_utils | ||
|
||
def DoProguard(options): | ||
injars = options.input_path | ||
outjars = options.output_path | ||
classpath = build_utils.ParseGypList(options.classpath) | ||
classpath = list(set(classpath)) | ||
libraryjars = ':'.join(classpath) | ||
# proguard does its own dependency checking, which can be avoided by deleting | ||
# the output. | ||
if os.path.exists(options.output_path): | ||
os.remove(options.output_path) | ||
proguard_cmd = [options.proguard_path, | ||
'-injars', injars, | ||
'-outjars', outjars, | ||
'-libraryjars', libraryjars, | ||
'@' + options.proguard_config] | ||
build_utils.CheckCallDie(proguard_cmd) | ||
|
||
def main(argv): | ||
parser = optparse.OptionParser() | ||
parser.add_option('--proguard-path', | ||
help='Path to the proguard executable.') | ||
parser.add_option('--input-path', | ||
help='Path to the .jar file proguard should run on.') | ||
parser.add_option('--output-path', help='Path to the generated .jar file.') | ||
parser.add_option('--proguard-config', | ||
help='Path to the proguard configuration file.') | ||
parser.add_option('--classpath', help="Classpath for proguard.") | ||
parser.add_option('--stamp', help='Path to touch on success.') | ||
|
||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | ||
parser.add_option('--ignore', help='Ignored.') | ||
|
||
options, _ = parser.parse_args() | ||
|
||
DoProguard(options) | ||
|
||
if options.stamp: | ||
build_utils.Touch(options.stamp) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
-keep class com.google.common.base.** { | ||
*; | ||
} | ||
|
||
-keep class com.google.common.annotations.** { | ||
*; | ||
} | ||
|
||
-keep class com.google.common.collect.** { | ||
*; | ||
} | ||
|
||
-keepattributes Signature | ||
|
||
# Don't complain about usage of sun.misc.Unsafe. Guava imports this, | ||
# but does not use it unless it exists. | ||
# The gyp-target that uses this is guava.gyp:guava_javalib. | ||
-dontwarn sun.misc.Unsafe | ||
# Striped64 uses reflection to access some local fields. | ||
-dontnote com.google.common.cache.Striped64 | ||
-dontnote com.google.common.cache.Striped64$Cell | ||
|
||
# Keep all enum values and valueOf methods. See | ||
# http://proguard.sourceforge.net/index.html#manual/examples.html | ||
# for the reason for this. Also, see http://crbug.com/248037. | ||
-keepclassmembers enum * { | ||
public static **[] values(); | ||
public static ** valueOf(java.lang.String); | ||
} |