android_resources targets can no longer create srcjars

With all current targets setting create_srcjar=false, we can remove all
code that creates srcjars in prepare resources so that no new usages are
created.

TBR= #cced OWNERS, just a mechanical deprecation change (for the files outside of build).

Bug: 1073476
Change-Id: I102744c75f9be1ee8e78203a524a12a474f55390
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392740
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804979}
GitOrigin-RevId: 2bc4ba086520af61dec3ab3b2c0599f99b35149f
This commit is contained in:
Mohamed Heikal 2020-09-08 18:07:41 +00:00 коммит произвёл Copybara-Service
Родитель 1ec9496d25
Коммит d580658b50
3 изменённых файлов: 6 добавлений и 55 удалений

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

@ -4,8 +4,8 @@
# 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
# found in the LICENSE file. # found in the LICENSE file.
"""Process Android resource directories to generate .resources.zip, R.txt and """Process Android resource directories to generate .resources.zip and R.txt
.srcjar files.""" files."""
import argparse import argparse
import collections import collections
@ -55,9 +55,6 @@ def _ParseArgs(args):
help='Path to a zip archive containing all resources from ' help='Path to a zip archive containing all resources from '
'--resource-dirs, merged into a single directory tree.') '--resource-dirs, merged into a single directory tree.')
output_opts.add_argument('--srcjar-out',
help='Path to .srcjar to contain the generated R.java.')
output_opts.add_argument('--r-text-out', output_opts.add_argument('--r-text-out',
help='Path to store the generated R.txt file.') help='Path to store the generated R.txt file.')
@ -174,33 +171,6 @@ def _OnStaleMd5(options):
if options.r_text_out: if options.r_text_out:
shutil.copyfile(r_txt_path, options.r_text_out) shutil.copyfile(r_txt_path, options.r_text_out)
if options.srcjar_out:
package = options.custom_package
if not package and options.android_manifest:
_, manifest_node, _ = manifest_utils.ParseManifest(
options.android_manifest)
package = manifest_utils.GetPackage(manifest_node)
# Don't create a .java file for the current resource target when no
# package name was provided (either by manifest or build rules).
if package:
# All resource IDs should be non-final here, but the
# onResourcesLoaded() method should only be generated if
# --shared-resources is used.
rjava_build_options = resource_utils.RJavaBuildOptions()
rjava_build_options.ExportAllResources()
rjava_build_options.ExportAllStyleables()
if options.shared_resources:
rjava_build_options.GenerateOnResourcesLoaded(fake=True)
# Not passing in custom_root_package_name or parent to keep
# file names unique.
resource_utils.CreateRJavaFiles(build.srcjar_dir, package, r_txt_path,
options.extra_res_packages,
rjava_build_options, options.srcjar_out)
build_utils.ZipDir(options.srcjar_out, build.srcjar_dir)
if options.resource_zip_out: if options.resource_zip_out:
ignore_pattern = resource_utils.AAPT_IGNORE_PATTERN ignore_pattern = resource_utils.AAPT_IGNORE_PATTERN
if options.strip_drawables: if options.strip_drawables:
@ -218,7 +188,6 @@ def main(args):
possible_output_paths = [ possible_output_paths = [
options.resource_zip_out, options.resource_zip_out,
options.r_text_out, options.r_text_out,
options.srcjar_out,
] ]
output_paths = [x for x in possible_output_paths if x] output_paths = [x for x in possible_output_paths if x]

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

@ -2197,9 +2197,6 @@ if (enable_java_templates) {
# #
# r_text_out_path: Path for the generated R.txt file. # r_text_out_path: Path for the generated R.txt file.
# #
# srcjar_path: (optional) Path to a generated .srcjar containing the
# generated R.java source file.
#
template("prepare_resources") { template("prepare_resources") {
action_with_pydeps(target_name) { action_with_pydeps(target_name) {
set_sources_assignment_filter([]) set_sources_assignment_filter([])
@ -2252,14 +2249,6 @@ if (enable_java_templates) {
] ]
} }
if (defined(invoker.srcjar_path)) {
outputs += [ invoker.srcjar_path ]
args += [
"--srcjar-out",
rebase_path(invoker.srcjar_path, root_build_dir),
]
}
if (defined(invoker.r_text_in_path)) { if (defined(invoker.r_text_in_path)) {
_r_text_in_path = invoker.r_text_in_path _r_text_in_path = invoker.r_text_in_path
inputs += [ _r_text_in_path ] inputs += [ _r_text_in_path ]

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

@ -897,9 +897,6 @@ if (enable_java_templates) {
# other. # other.
# r_text_file: (optional) path to pre-generated R.txt to be used when # r_text_file: (optional) path to pre-generated R.txt to be used when
# generating R.java instead of resource-based aapt-generated one. # generating R.java instead of resource-based aapt-generated one.
# create_srcjar: If false, does not create an R.java file. Needed only for
# prebuilts that have R.txt files that do not match their res/
# (Play Services).
# #
# Example: # Example:
# android_resources("foo_resources") { # android_resources("foo_resources") {
@ -937,8 +934,10 @@ if (enable_java_templates) {
_build_config = _base_path + ".build_config" _build_config = _base_path + ".build_config"
_build_config_target_name = "$target_name$build_config_target_suffix" _build_config_target_name = "$target_name$build_config_target_suffix"
if (!defined(invoker.create_srcjar) || invoker.create_srcjar) { if (defined(invoker.create_srcjar)) {
_srcjar_path = _base_path + ".srcjar" assert(!invoker.create_srcjar,
"create_srcjar=true has been deprecated. " +
"See https://crbug.com/1073476")
} }
_deps = [] _deps = []
@ -989,9 +988,6 @@ if (enable_java_templates) {
if (defined(custom_package) || defined(android_manifest)) { if (defined(custom_package) || defined(android_manifest)) {
r_text = _r_text_out_path r_text = _r_text_out_path
} }
if (defined(_srcjar_path)) {
srcjar = _srcjar_path
}
possible_config_deps = _deps possible_config_deps = _deps
} }
@ -1019,9 +1015,6 @@ if (enable_java_templates) {
if (defined(invoker.r_text_file)) { if (defined(invoker.r_text_file)) {
r_text_in_path = invoker.r_text_file r_text_in_path = invoker.r_text_file
} }
if (defined(_srcjar_path)) {
srcjar_path = _srcjar_path
}
# Always generate R.onResourcesLoaded() method, it is required for # Always generate R.onResourcesLoaded() method, it is required for
# compiling ResourceRewriter, there is no side effect because the # compiling ResourceRewriter, there is no side effect because the