Android: Passing min-api to R8

Bug: 910319
Change-Id: Ic9a9fa2be934d95aee31a7f1440890d6a9fa2697
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717694
Commit-Queue: Sam Maier <smaier@chromium.org>
Auto-Submit: Sam Maier <smaier@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#681311}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ab73abf2b712ae71e346299c61db5dcf8301c023
This commit is contained in:
Sam Maier 2019-07-26 15:56:58 +00:00 коммит произвёл Commit Bot
Родитель c3472b022f
Коммит e36ae524d9
4 изменённых файлов: 14 добавлений и 39 удалений

Просмотреть файл

@ -1,15 +0,0 @@
# Copyright 2019 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.
# Proguard flags to pass to R8 which do nothing, and thus allows R8 to
# arbitrarily assign code to different dex files. If we pass a flags file with
# no rules, R8 applies default main dex rules which usually include too much
# and pushes us over the main dex limit. We can't pass higher --min-api since we
# also want to allow multidex in libraries, which are compiled with a low
# min-api. Thus, we have rules which won't do anything to pass as a
# main-dex-rule.
-keep class this.should.not.match.anything {
*;
}

Просмотреть файл

@ -165,21 +165,19 @@ def _CreateR8Command(options, map_output_path, output_dir, tmp_config_path,
cmd += ['--pg-conf', config_file]
temp_config_string = ''
if options.apply_mapping or options.repackage_classes or options.min_api:
if options.apply_mapping or options.repackage_classes:
with open(tmp_config_path, 'w') as f:
if options.apply_mapping:
temp_config_string += '-applymapping \'%s\'\n' % (options.apply_mapping)
if options.repackage_classes:
temp_config_string += '-repackageclasses \'%s\'\n' % (
options.repackage_classes)
if options.min_api:
temp_config_string += (
'-assumenosideeffects class android.os.Build$VERSION {\n' +
' public static final int SDK_INT return ' + options.min_api +
'..9999;\n}\n')
f.write(temp_config_string)
cmd += ['--pg-conf', tmp_config_path]
if options.min_api:
cmd += ['--min-api', options.min_api]
if options.main_dex_rules_path:
for main_dex_rule in options.main_dex_rules_path:
cmd += ['--main-dex-rules', main_dex_rule]

Просмотреть файл

@ -136,7 +136,7 @@ class ProguardCmdBuilder(object):
if self._min_api:
cmd += [
'-assumevalues class android.os.Build$VERSION {' +
'-assumenosideeffects class android.os.Build$VERSION {' +
' public static final int SDK_INT return ' + self._min_api +
'..9999; }'
]

Просмотреть файл

@ -1180,28 +1180,20 @@ if (enable_java_templates) {
]
}
if (_enable_multidex && _proguarding_with_r8) {
if (_enable_main_dex_list) {
if (defined(invoker.extra_main_dex_proguard_config)) {
args += [
"--main-dex-rules-path",
rebase_path(invoker.extra_main_dex_proguard_config,
root_build_dir),
]
inputs += [ invoker.extra_main_dex_proguard_config ]
}
if (_proguarding_with_r8 && _enable_main_dex_list) {
if (defined(invoker.extra_main_dex_proguard_config)) {
args += [
"--main-dex-rules-path",
rebase_path(_main_dex_rules, root_build_dir),
]
inputs += [ _main_dex_rules ]
} else {
args += [
"--main-dex-rules-path",
rebase_path("//build/android/arbitrary_main_dex.flags",
rebase_path(invoker.extra_main_dex_proguard_config,
root_build_dir),
]
inputs += [ invoker.extra_main_dex_proguard_config ]
}
args += [
"--main-dex-rules-path",
rebase_path(_main_dex_rules, root_build_dir),
]
inputs += [ _main_dex_rules ]
}
output_path = _proguard_output_path