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

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: Created 5 years, 7 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
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index c516a8c6857711614a7c13f2295a55fc98e6ae1a..82d2781e4f042f769095024798f9fa8307b8b05d 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -1303,6 +1303,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"
+ }
+
write_build_config("${_template_name}__build_config") {
type = "android_apk"
dex_path = final_dex_path
@@ -1318,12 +1324,18 @@ 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 = []
final_deps += [ ":${_template_name}__process_resources" ]
+ _generated_proguard_config = "$base_path.resources.proguard.txt"
process_resources("${_template_name}__process_resources") {
srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
r_text_path = "${target_gen_dir}/${target_name}_R.txt"
@@ -1332,6 +1344,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
build_config = _build_config
if (defined(invoker.include_all_resources)) {
@@ -1421,12 +1434,36 @@ template("android_apk") {
}
final_deps += [ ":${_template_name}__final_dex" ]
+
+ dex_jar_path = jar_path
+ if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
+ _proguard_configs = [ _generated_proguard_config ]
+ if (defined(invoker.proguard_configs)) {
+ _proguard_configs += invoker.proguard_configs
+ }
+ proguard("${_template_name}__proguard") {
+ inputs = [
newt (away) 2015/05/29 01:43:04 funky indentation. this would be more normal:
+ _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("${_template_name}__final_dex") {
deps = [
":${_template_name}__java",
]
sources = [
- jar_path,
+ dex_jar_path,
]
inputs = [
_build_config,

Powered by Google App Engine
This is Rietveld 408576698