GN(android): Filter R.class files before obfuscating via proguard
I haven't heard of this causing issues for us yet, but I realized that filtering after proguarding could have the result that proguard renames a class to "R.class", and then filtering strips it out. BUG=585576 Review-Url: https://codereview.chromium.org/1993893002 Cr-Original-Commit-Position: refs/heads/master@{#394638} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2142bcde69837585c1571a46cf59715a81d573f9
This commit is contained in:
Родитель
cdadc1d3b1
Коммит
b2d1568643
|
@ -603,22 +603,30 @@ template("process_java_prebuilt") {
|
|||
if (defined(invoker.jar_excluded_patterns)) {
|
||||
_jar_excluded_patterns = invoker.jar_excluded_patterns
|
||||
}
|
||||
|
||||
_strip_resource_classes =
|
||||
defined(invoker.strip_resource_classes) && invoker.strip_resource_classes
|
||||
_filter_jar = _jar_excluded_patterns != [] || _strip_resource_classes
|
||||
|
||||
if (_jar_excluded_patterns != [] || _strip_resource_classes) {
|
||||
_filter_class_files_input_file = _input_jar_path
|
||||
if (_proguard_preprocess) {
|
||||
_filter_class_files_input_file =
|
||||
"$target_out_dir/$target_name-proguarded.jar"
|
||||
}
|
||||
if (_filter_jar) {
|
||||
_filter_target = "${target_name}__filter"
|
||||
_output_jar_target = _filter_target
|
||||
}
|
||||
if (_proguard_preprocess) {
|
||||
_proguard_target = "${target_name}__proguard_process"
|
||||
_output_jar_target = _proguard_target
|
||||
}
|
||||
if (!_filter_jar && !_proguard_preprocess) {
|
||||
_copy_target = "${target_name}__copy"
|
||||
_output_jar_target = _copy_target
|
||||
}
|
||||
|
||||
if (_proguard_preprocess) {
|
||||
_proguard_config_path = invoker.proguard_config
|
||||
_proguard_target = "${target_name}__proguard_process"
|
||||
proguard(_proguard_target) {
|
||||
if (_filter_jar) {
|
||||
_filtered_jar_path = _output_jar_path
|
||||
if (_proguard_preprocess) {
|
||||
_filtered_jar_path = "$target_out_dir/$target_name-filtered.jar"
|
||||
}
|
||||
action(_filter_target) {
|
||||
script = "//build/android/gyp/jar.py"
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
|
@ -627,12 +635,47 @@ template("process_java_prebuilt") {
|
|||
inputs = [
|
||||
_build_config,
|
||||
_input_jar_path,
|
||||
]
|
||||
outputs = [
|
||||
_filtered_jar_path,
|
||||
]
|
||||
args = [
|
||||
"--input-jar",
|
||||
rebase_path(_input_jar_path, root_build_dir),
|
||||
"--jar-path",
|
||||
rebase_path(_filtered_jar_path, root_build_dir),
|
||||
"--excluded-classes=$_jar_excluded_patterns",
|
||||
]
|
||||
if (_strip_resource_classes) {
|
||||
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_proguard_preprocess) {
|
||||
_proguard_config_path = invoker.proguard_config
|
||||
proguard(_proguard_target) {
|
||||
if (_filter_jar) {
|
||||
_proguard_input_jar = _filtered_jar_path
|
||||
public_deps = [
|
||||
":$_filter_target",
|
||||
]
|
||||
} else {
|
||||
_proguard_input_jar = _input_jar_path
|
||||
public_deps = []
|
||||
}
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps
|
||||
}
|
||||
if (defined(invoker.public_deps)) {
|
||||
public_deps += invoker.public_deps
|
||||
}
|
||||
inputs = [
|
||||
_build_config,
|
||||
_proguard_config_path,
|
||||
_proguard_input_jar,
|
||||
]
|
||||
output_jar_path = _output_jar_path
|
||||
if (defined(_filter_class_files_input_file)) {
|
||||
output_jar_path = _filter_class_files_input_file
|
||||
}
|
||||
|
||||
_rebased_input_paths = [ rebase_path(_input_jar_path, root_build_dir) ]
|
||||
_rebased_proguard_configs =
|
||||
|
@ -643,9 +686,8 @@ template("process_java_prebuilt") {
|
|||
"--classpath=@FileArg($_rebased_build_config:javac:classpath)",
|
||||
]
|
||||
}
|
||||
} else if (_jar_excluded_patterns == [] && !_strip_resource_classes) {
|
||||
_output_jar_target = "${target_name}__copy_jar"
|
||||
copy(_output_jar_target) {
|
||||
} else if (!_filter_jar) {
|
||||
copy(_copy_target) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
|
@ -660,42 +702,6 @@ template("process_java_prebuilt") {
|
|||
}
|
||||
}
|
||||
|
||||
if (_jar_excluded_patterns != [] || _strip_resource_classes) {
|
||||
_output_jar_target = "${target_name}__filter"
|
||||
action(_output_jar_target) {
|
||||
script = "//build/android/gyp/jar.py"
|
||||
if (_proguard_preprocess) {
|
||||
deps = [
|
||||
":$_proguard_target",
|
||||
]
|
||||
} else {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"deps",
|
||||
"public_deps",
|
||||
])
|
||||
}
|
||||
inputs = [
|
||||
_filter_class_files_input_file,
|
||||
]
|
||||
outputs = [
|
||||
_output_jar_path,
|
||||
]
|
||||
args = [
|
||||
"--input-jar",
|
||||
rebase_path(_filter_class_files_input_file, root_build_dir),
|
||||
"--jar-path",
|
||||
rebase_path(_output_jar_path, root_build_dir),
|
||||
"--excluded-classes=$_jar_excluded_patterns",
|
||||
]
|
||||
if (_strip_resource_classes) {
|
||||
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
|
||||
}
|
||||
}
|
||||
} else if (_proguard_preprocess) {
|
||||
_output_jar_target = _proguard_target
|
||||
}
|
||||
|
||||
group(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
|
@ -1615,6 +1621,9 @@ template("compile_java") {
|
|||
deps = [
|
||||
":$_javac_target_name",
|
||||
]
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
}
|
||||
|
||||
emma_instr(_emma_instr_target_name) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче