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

Unified Diff: build/config/android/rules.gni

Issue 1133013003: Enable proguard for apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@javac-no-java
Patch Set: fix deps Created 5 years, 5 months 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/config/android/internal_rules.gni ('k') | chrome/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 9e8568e779d81c3baecf7bfe02de60f12a706646..fc5a19d306c7246ae58091c70eb0fe7aa5ca4357 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -1470,6 +1470,12 @@ template("android_apk") {
# Help GN understand that _create_abi_split is not unused (bug in GN).
assert(_create_abi_split || true)
+ _proguard_enabled = false
+ if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
+ _proguard_enabled = true
+ _proguard_jar_path = "$base_path.proguard.jar"
+ }
+
build_config_target = "${_template_name}__build_config"
write_build_config(build_config_target) {
type = "android_apk"
@@ -1487,11 +1493,17 @@ template("android_apk") {
apk_under_test = invoker.apk_under_test
}
+ if (_proguard_enabled) {
+ proguard_enabled = true
+ proguard_info = "$_proguard_jar_path.info"
+ }
+
native_libs = _native_libs
}
final_deps = []
+ _generated_proguard_config = "$base_path.resources.proguard.txt"
process_resources_target = "${_template_name}__process_resources"
final_deps += [ ":$process_resources_target" ]
process_resources(process_resources_target) {
@@ -1502,6 +1514,7 @@ template("android_apk") {
zip_path = resources_zip_path
all_resources_zip_path = _all_resources_zip_path
generate_constant_ids = true
+ proguard_file = _generated_proguard_config
if (defined(invoker.include_all_resources)) {
include_all_resources = invoker.include_all_resources
@@ -1610,14 +1623,43 @@ template("android_apk") {
}
}
+ if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
+ _proguard_configs = [ _generated_proguard_config ]
+ if (defined(invoker.proguard_configs)) {
+ _proguard_configs += invoker.proguard_configs
+ }
+ proguard_target = "${_template_name}__proguard"
+ proguard(proguard_target) {
+ deps = [
+ ":$build_config_target",
+ ":$process_resources_target",
+ ":$java_target",
+ ]
+ inputs = [
+ _build_config,
+ jar_path,
+ ] + _proguard_configs
+
+ output_jar_path = _proguard_jar_path
+ rebased_proguard_configs = rebase_path(_proguard_configs, root_build_dir)
+ args = [
+ "--proguard-configs=$rebased_proguard_configs",
+ "--tested-apk-info=@FileArg($_rebased_build_config:proguard:tested_apk_info)",
+ "--input-paths=@FileArg($_rebased_build_config:proguard:input_paths)",
+ ]
+ }
+ dex_jar_path = _proguard_jar_path
+ dex_deps = [ ":$proguard_target" ]
+ } else {
+ dex_jar_path = jar_path
+ dex_deps = [ ":$java_target" ]
+ }
+
final_deps += [ ":$final_dex_target_name" ]
dex("$final_dex_target_name") {
- deps = [
- ":$build_config_target",
- ":$java_target",
- ]
+ deps = dex_deps + [ ":$build_config_target" ]
sources = [
- jar_path,
+ dex_jar_path,
]
inputs = [
_build_config,
@@ -1881,6 +1923,9 @@ template("instrumentation_test_apk") {
if (defined(invoker.native_libs)) {
native_libs = invoker.native_libs
}
+ if (defined(invoker.proguard_enabled)) {
+ proguard_enabled = invoker.proguard_enabled
+ }
if (defined(invoker.apk_under_test)) {
apk_under_test = invoker.apk_under_test
}
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | chrome/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698