Commit 6321888e authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Remove support for legacy proguard

It's pretty bitrotten at this point and R8 is serving us well.

Bug: None
Change-Id: I6aa003237b2aef1c9004f7234285a5e3e9c1169b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212545
Commit-Queue: Sam Maier <smaier@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771170}
parent 95cc141c
...@@ -167,8 +167,8 @@ performed, which consists of the following steps: ...@@ -167,8 +167,8 @@ performed, which consists of the following steps:
This synchronized proguarding step is added by the `android_app_bundle()` GN This synchronized proguarding step is added by the `android_app_bundle()` GN
template. In practice this means the following: template. In practice this means the following:
- If `proguard_enabled` and `proguard_jar_path` must be passed to - `proguard_enabled` must be passed to `android_app_bundle` targets, but not
`android_app_bundle` targets, but not to `android_app_bundle_module` ones. to `android_app_bundle_module` ones.
- `proguard_configs` can be still passed to individual modules, just - `proguard_configs` can be still passed to individual modules, just
like regular APKs. All proguard configs will be merged during the like regular APKs. All proguard configs will be merged during the
......
...@@ -107,9 +107,9 @@ def _ParseOptions(): ...@@ -107,9 +107,9 @@ def _ParseOptions():
args = build_utils.ExpandFileArgs(sys.argv[1:]) args = build_utils.ExpandFileArgs(sys.argv[1:])
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
build_utils.AddDepfileOption(parser) build_utils.AddDepfileOption(parser)
group = parser.add_mutually_exclusive_group(required=True) parser.add_argument('--r8-path',
group.add_argument('--proguard-path', help='Path to the proguard.jar to use.') required=True,
group.add_argument('--r8-path', help='Path to the R8.jar to use.') help='Path to the R8.jar to use.')
parser.add_argument( parser.add_argument(
'--desugar-jdk-libs-json', help='Path to desugar_jdk_libs.json.') '--desugar-jdk-libs-json', help='Path to desugar_jdk_libs.json.')
parser.add_argument('--input-paths', parser.add_argument('--input-paths',
...@@ -213,9 +213,6 @@ def _ParseOptions(): ...@@ -213,9 +213,6 @@ def _ParseOptions():
if options.expected_configs_file and not options.output_config: if options.expected_configs_file and not options.output_config:
parser.error('--expected-configs-file requires --output-config') parser.error('--expected-configs-file requires --output-config')
if options.proguard_path and options.disable_outlining:
parser.error('--disable-outlining requires --r8-path')
if options.only_verify_expectations and not options.stamp: if options.only_verify_expectations and not options.stamp:
parser.error('--only-verify-expectations requires --stamp') parser.error('--only-verify-expectations requires --stamp')
...@@ -393,65 +390,6 @@ def _OptimizeWithR8(options, ...@@ -393,65 +390,6 @@ def _OptimizeWithR8(options,
out_file.writelines(l for l in in_file if not l.startswith('#')) out_file.writelines(l for l in in_file if not l.startswith('#'))
def _OptimizeWithProguard(options,
config_paths,
libraries,
dynamic_config_data,
print_stdout=False):
with build_utils.TempDir() as tmp_dir:
combined_injars_path = os.path.join(tmp_dir, 'injars.jar')
combined_libjars_path = os.path.join(tmp_dir, 'libjars.jar')
combined_proguard_configs_path = os.path.join(tmp_dir, 'includes.txt')
tmp_mapping_path = os.path.join(tmp_dir, 'mapping.txt')
tmp_output_jar = os.path.join(tmp_dir, 'output.jar')
build_utils.MergeZips(combined_injars_path, options.input_paths)
build_utils.MergeZips(combined_libjars_path, libraries)
with open(combined_proguard_configs_path, 'w') as f:
f.write(_CombineConfigs(config_paths, dynamic_config_data))
if options.proguard_path.endswith('.jar'):
cmd = [
build_utils.JAVA_PATH, '-jar', options.proguard_path, '-include',
combined_proguard_configs_path
]
else:
cmd = [options.proguard_path, '@' + combined_proguard_configs_path]
cmd += [
'-forceprocessing',
'-libraryjars',
combined_libjars_path,
'-injars',
combined_injars_path,
'-outjars',
tmp_output_jar,
'-printmapping',
tmp_mapping_path,
]
# Warning: and Error: are sent to stderr, but messages and Note: are sent
# to stdout.
stdout_filter = None
stderr_filter = None
if print_stdout:
stdout_filter = _ProguardOutputFilter()
stderr_filter = _ProguardOutputFilter()
build_utils.CheckOutput(
cmd,
print_stdout=True,
print_stderr=True,
stdout_filter=stdout_filter,
stderr_filter=stderr_filter)
# ProGuard will skip writing if the file would be empty.
build_utils.Touch(tmp_mapping_path)
# Copy output files to correct locations.
shutil.move(tmp_output_jar, options.output_path)
shutil.move(tmp_mapping_path, options.mapping_output)
def _CombineConfigs(configs, dynamic_config_data, exclude_generated=False): def _CombineConfigs(configs, dynamic_config_data, exclude_generated=False):
ret = [] ret = []
...@@ -597,12 +535,8 @@ def main(): ...@@ -597,12 +535,8 @@ def main():
with open(options.output_config, 'w') as f: with open(options.output_config, 'w') as f:
f.write(merged_configs) f.write(merged_configs)
if options.r8_path: _OptimizeWithR8(options, proguard_configs, libraries, dynamic_config_data,
_OptimizeWithR8(options, proguard_configs, libraries, dynamic_config_data, print_stdout)
print_stdout)
else:
_OptimizeWithProguard(options, proguard_configs, libraries,
dynamic_config_data, print_stdout)
# After ProGuard / R8 has run: # After ProGuard / R8 has run:
for output in options.extra_mapping_output_paths: for output in options.extra_mapping_output_paths:
......
...@@ -981,7 +981,10 @@ if (enable_java_templates) { ...@@ -981,7 +981,10 @@ if (enable_java_templates) {
# http://crbug.com/725224. Fix for bots running out of memory. # http://crbug.com/725224. Fix for bots running out of memory.
_pool = "//build/toolchain:link_pool($default_toolchain)" _pool = "//build/toolchain:link_pool($default_toolchain)"
_inputs = [ invoker.build_config ] _inputs = [
invoker.build_config,
_r8_path,
]
if (defined(invoker.inputs)) { if (defined(invoker.inputs)) {
_inputs += invoker.inputs _inputs += invoker.inputs
} }
...@@ -1007,6 +1010,8 @@ if (enable_java_templates) { ...@@ -1007,6 +1010,8 @@ if (enable_java_templates) {
"@FileArg($_rebased_build_config:deps_info:proguard_classpath_jars)", "@FileArg($_rebased_build_config:deps_info:proguard_classpath_jars)",
"--classpath", "--classpath",
"@FileArg($_rebased_build_config:android:sdk_jars)", "@FileArg($_rebased_build_config:android:sdk_jars)",
"--r8-path",
rebase_path(_r8_path, root_build_dir),
] ]
if (enable_proguard_obfuscation) { if (enable_proguard_obfuscation) {
...@@ -1074,26 +1079,12 @@ if (enable_java_templates) { ...@@ -1074,26 +1079,12 @@ if (enable_java_templates) {
] ]
} }
if (!defined(invoker.proguard_jar_path)) { if (enable_jdk_library_desugaring) {
_args += [
"--r8-path",
rebase_path(_r8_path, root_build_dir),
]
_inputs += [ _r8_path ]
if (enable_jdk_library_desugaring) {
_args += [
"--desugar-jdk-libs-json",
rebase_path(_desugar_jdk_libs_json, root_build_dir),
]
_inputs += [ _desugar_jdk_libs_json ]
}
} else {
_proguard_jar_path = invoker.proguard_jar_path
_args += [ _args += [
"--proguard-path", "--desugar-jdk-libs-json",
rebase_path(_proguard_jar_path, root_build_dir), rebase_path(_desugar_jdk_libs_json, root_build_dir),
] ]
_inputs += [ _proguard_jar_path ] _inputs += [ _desugar_jdk_libs_json ]
} }
_enable_assert = is_java_debug || dcheck_always_on _enable_assert = is_java_debug || dcheck_always_on
...@@ -1222,8 +1213,6 @@ if (enable_java_templates) { ...@@ -1222,8 +1213,6 @@ if (enable_java_templates) {
_proguard_enabled = _proguard_enabled =
defined(invoker.proguard_enabled) && invoker.proguard_enabled defined(invoker.proguard_enabled) && invoker.proguard_enabled
_is_dex_merging = defined(invoker.input_dex_filearg) _is_dex_merging = defined(invoker.input_dex_filearg)
_proguarding_with_r8 =
_proguard_enabled && !defined(invoker.proguard_jar_path)
_enable_multidex = _enable_multidex =
!defined(invoker.enable_multidex) || invoker.enable_multidex !defined(invoker.enable_multidex) || invoker.enable_multidex
_enable_main_dex_list = _enable_multidex && _min_sdk_version < 21 _enable_main_dex_list = _enable_multidex && _min_sdk_version < 21
...@@ -1243,7 +1232,7 @@ if (enable_java_templates) { ...@@ -1243,7 +1232,7 @@ if (enable_java_templates) {
} }
assert(defined(invoker.output) || assert(defined(invoker.output) ||
(_proguarding_with_r8 && defined(invoker.modules))) (_proguard_enabled && defined(invoker.modules)))
assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) || assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) ||
defined(invoker.input_classes_filearg) || defined(invoker.input_classes_filearg) ||
defined(invoker.input_class_jars)), defined(invoker.input_class_jars)),
...@@ -1265,15 +1254,10 @@ if (enable_java_templates) { ...@@ -1265,15 +1254,10 @@ if (enable_java_templates) {
} }
if (_proguard_enabled) { if (_proguard_enabled) {
if (_proguarding_with_r8) { if (defined(invoker.output)) {
if (defined(invoker.output)) { _proguard_output_path = invoker.output
_proguard_output_path = invoker.output
}
_proguard_target_name = target_name
} else {
_proguard_output_path = invoker.output + ".proguard.jar"
_proguard_target_name = "${target_name}__proguard"
} }
_proguard_target_name = target_name
proguard(_proguard_target_name) { proguard(_proguard_target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
...@@ -1284,7 +1268,6 @@ if (enable_java_templates) { ...@@ -1284,7 +1268,6 @@ if (enable_java_templates) {
"deps", "deps",
"modules", "modules",
"verify_proguard_flags_target_name", "verify_proguard_flags_target_name",
"proguard_jar_path",
"proguard_mapping_path", "proguard_mapping_path",
"proguard_sourcefile_suffix", "proguard_sourcefile_suffix",
"is_static_library", "is_static_library",
...@@ -1325,7 +1308,7 @@ if (enable_java_templates) { ...@@ -1325,7 +1308,7 @@ if (enable_java_templates) {
args += [ "--apply-mapping=$_rebased_apply_mapping_path" ] args += [ "--apply-mapping=$_rebased_apply_mapping_path" ]
} }
if (_proguarding_with_r8 && _enable_main_dex_list) { if (_enable_main_dex_list) {
if (defined(invoker.extra_main_dex_proguard_config)) { if (defined(invoker.extra_main_dex_proguard_config)) {
args += [ args += [
"--main-dex-rules-path", "--main-dex-rules-path",
...@@ -1343,30 +1326,18 @@ if (enable_java_templates) { ...@@ -1343,30 +1326,18 @@ if (enable_java_templates) {
if (defined(_proguard_output_path)) { if (defined(_proguard_output_path)) {
output_path = _proguard_output_path output_path = _proguard_output_path
if (_proguarding_with_r8) { config_output_path = "$_proguard_output_path.proguard_flags"
config_output_path = "$_proguard_output_path.proguard_flags"
}
} else { } else {
mapping_path = "$target_out_dir/$target_name.mapping" mapping_path = "$target_out_dir/$target_name.mapping"
if (_proguarding_with_r8) { config_output_path = "$target_out_dir/$target_name.proguard_flags"
config_output_path = "$target_out_dir/$target_name.proguard_flags"
}
} }
} }
} } else { # !_proguard_enabled
if (!_proguarding_with_r8) {
_input_class_jars = [] _input_class_jars = []
if (defined(invoker.input_class_jars)) { if (defined(invoker.input_class_jars)) {
_input_class_jars = invoker.input_class_jars _input_class_jars = invoker.input_class_jars
} }
if (_proguard_enabled) {
_input_class_jars += [ _proguard_output_path ]
}
_deps = invoker.deps _deps = invoker.deps
if (_proguard_enabled) {
_deps += [ ":${_proguard_target_name}" ]
}
if (_is_dex_merging && enable_bazel_desugar) { if (_is_dex_merging && enable_bazel_desugar) {
# It would be more efficient to use the pre-dex'ed copy of the runtime, # It would be more efficient to use the pre-dex'ed copy of the runtime,
...@@ -1467,9 +1438,8 @@ if (enable_java_templates) { ...@@ -1467,9 +1438,8 @@ if (enable_java_templates) {
rebase_path(_r8_path, root_build_dir), rebase_path(_r8_path, root_build_dir),
] ]
if (!_proguard_enabled && enable_incremental_d8 && if (enable_incremental_d8 && !(defined(invoker.disable_incremental) &&
!(defined(invoker.disable_incremental) && invoker.disable_incremental)) {
invoker.disable_incremental)) {
# Don't use incremental dexing for ProGuarded inputs as a precaution. # Don't use incremental dexing for ProGuarded inputs as a precaution.
args += [ args += [
"--incremental-dir", "--incremental-dir",
...@@ -1523,13 +1493,6 @@ if (enable_java_templates) { ...@@ -1523,13 +1493,6 @@ if (enable_java_templates) {
invoker.dexlayout_profile, invoker.dexlayout_profile,
] ]
inputs += _default_art_libs inputs += _default_art_libs
if (_proguard_enabled) {
args += [
"--proguard-mapping-path",
rebase_path(invoker.proguard_mapping_path, root_build_dir),
]
inputs += [ invoker.proguard_mapping_path ]
}
} }
# Never compile intemediates with --release in order to: # Never compile intemediates with --release in order to:
......
...@@ -1644,8 +1644,6 @@ if (enable_java_templates) { ...@@ -1644,8 +1644,6 @@ if (enable_java_templates) {
# output: Path to the output dex. # output: Path to the output dex.
# proguard_enabled: Whether to enable R8. # proguard_enabled: Whether to enable R8.
# proguard_configs: List of proguard configs. # proguard_configs: List of proguard configs.
# proguard_jar_path: The path to proguard.jar you wish to use. If undefined,
# the proguard used will be the checked in one in //third_party/proguard.
# #
# Example # Example
# dist_dex("lib_fatjar") { # dist_dex("lib_fatjar") {
...@@ -2878,13 +2876,6 @@ if (enable_java_templates) { ...@@ -2878,13 +2876,6 @@ if (enable_java_templates) {
if (_uses_static_library_synchronized_proguard) { if (_uses_static_library_synchronized_proguard) {
_final_dex_target_dep = "${invoker.static_library_provider}__dexsplitter" _final_dex_target_dep = "${invoker.static_library_provider}__dexsplitter"
} else if (_is_bundle_module && _proguard_enabled) { } else if (_is_bundle_module && _proguard_enabled) {
# A small sanity check to help developers with a subtle point!
assert(
!defined(invoker.proguard_jar_path),
"proguard_jar_path should not be used for app bundle modules " +
"when proguard is enabled. Pass it to the android_app_bundle() " +
"target instead!")
_final_deps += [ ":$_java_target" ] _final_deps += [ ":$_java_target" ]
} else if (_incremental_apk) { } else if (_incremental_apk) {
if (defined(invoker.negative_main_dex_globs)) { if (defined(invoker.negative_main_dex_globs)) {
...@@ -2922,7 +2913,6 @@ if (enable_java_templates) { ...@@ -2922,7 +2913,6 @@ if (enable_java_templates) {
":$_java_target", ":$_java_target",
] ]
if (_proguard_enabled) { if (_proguard_enabled) {
forward_variables_from(invoker, [ "proguard_jar_path" ])
deps += _deps + [ ":$_compile_resources_target" ] deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code" proguard_sourcefile_suffix = "$android_channel-$_version_code"
...@@ -3494,7 +3484,6 @@ if (enable_java_templates) { ...@@ -3494,7 +3484,6 @@ if (enable_java_templates) {
"product_version_resources_dep", "product_version_resources_dep",
"proguard_configs", "proguard_configs",
"proguard_enabled", "proguard_enabled",
"proguard_jar_path",
"r_java_root_package_name", "r_java_root_package_name",
"resource_exclusion_exceptions", "resource_exclusion_exceptions",
"resource_exclusion_regex", "resource_exclusion_regex",
...@@ -3624,7 +3613,6 @@ if (enable_java_templates) { ...@@ -3624,7 +3613,6 @@ if (enable_java_templates) {
"product_version_resources_dep", "product_version_resources_dep",
"proguard_configs", "proguard_configs",
"proguard_enabled", "proguard_enabled",
"proguard_jar_path",
"resource_exclusion_exceptions", "resource_exclusion_exceptions",
"resource_exclusion_regex", "resource_exclusion_regex",
"resource_ids_provider_dep", "resource_ids_provider_dep",
...@@ -4419,9 +4407,6 @@ if (enable_java_templates) { ...@@ -4419,9 +4407,6 @@ if (enable_java_templates) {
# bundle. Default is to enable this only for release builds. Note that # bundle. Default is to enable this only for release builds. Note that
# this will always perform synchronized proguarding. # this will always perform synchronized proguarding.
# #
# proguard_jar_path: Optional. Path to custom proguard jar used for
# proguarding.
#
# enable_multidex: Optional. Enable multidexing of optimized modules jars # enable_multidex: Optional. Enable multidexing of optimized modules jars
# when using synchronized proguarding. Only applies to base module. # when using synchronized proguarding. Only applies to base module.
# #
...@@ -4672,18 +4657,11 @@ if (enable_java_templates) { ...@@ -4672,18 +4657,11 @@ if (enable_java_templates) {
if (defined(invoker.min_sdk_version)) { if (defined(invoker.min_sdk_version)) {
not_needed(invoker, [ "min_sdk_version" ]) not_needed(invoker, [ "min_sdk_version" ])
} }
if (defined(proguard_jar_path)) {
not_needed(invoker, [ "proguard_jar_path" ])
}
} else { } else {
_verify_proguard_flags = defined(invoker.verify_proguard_flags) && _verify_proguard_flags = defined(invoker.verify_proguard_flags) &&
invoker.verify_proguard_flags invoker.verify_proguard_flags
dex(_dex_target) { dex(_dex_target) {
forward_variables_from(invoker, forward_variables_from(invoker, [ "min_sdk_version" ])
[
"proguard_jar_path",
"min_sdk_version",
])
enable_multidex = _enable_multidex enable_multidex = _enable_multidex
proguard_enabled = true proguard_enabled = true
proguard_mapping_path = _proguard_mapping_path proguard_mapping_path = _proguard_mapping_path
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# Copyright 2014 The Chromium Authors. All rights reserved.
# found in the LICENSE file. # found in the LICENSE file.
import("//build/android/resource_sizes.gni") import("//build/android/resource_sizes.gni")
...@@ -1966,7 +1966,6 @@ template("monochrome_public_apk_or_module_tmpl") { ...@@ -1966,7 +1966,6 @@ template("monochrome_public_apk_or_module_tmpl") {
"include_64_bit_webview", "include_64_bit_webview",
"is_64_bit_browser", "is_64_bit_browser",
"is_base_module", "is_base_module",
"proguard_jar_path",
"resource_ids_provider_dep", "resource_ids_provider_dep",
"static_library_provider", "static_library_provider",
"static_library_synchronized_proguard", "static_library_synchronized_proguard",
......
...@@ -84,7 +84,6 @@ template("chrome_bundle") { ...@@ -84,7 +84,6 @@ template("chrome_bundle") {
"manifest_package", "manifest_package",
"min_sdk_version", "min_sdk_version",
"proguard_android_sdk_dep", "proguard_android_sdk_dep",
"proguard_jar_path",
"sign_bundle", "sign_bundle",
"static_library_provider", "static_library_provider",
"static_library_synchronized_proguard", "static_library_synchronized_proguard",
......
...@@ -45,7 +45,6 @@ template("trichrome_library_apk_tmpl") { ...@@ -45,7 +45,6 @@ template("trichrome_library_apk_tmpl") {
"android_manifest_dep", "android_manifest_dep",
"apk_name", "apk_name",
"min_sdk_version", "min_sdk_version",
"proguard_jar_path",
"target_sdk_version", "target_sdk_version",
"verify_manifest", "verify_manifest",
"verify_native_libs_and_assets", "verify_native_libs_and_assets",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment