summaryrefslogtreecommitdiff
path: root/chromium/build/config/android/rules.gni
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/build/config/android/rules.gni')
-rw-r--r--chromium/build/config/android/rules.gni392
1 files changed, 204 insertions, 188 deletions
diff --git a/chromium/build/config/android/rules.gni b/chromium/build/config/android/rules.gni
index cd0258af22c..412041fe56e 100644
--- a/chromium/build/config/android/rules.gni
+++ b/chromium/build/config/android/rules.gni
@@ -524,17 +524,12 @@ if (enable_java_templates) {
# The sources aren't compiled so don't check their dependencies.
check_includes = false
script = "//build/android/gyp/java_cpp_enum.py"
- depfile = "$target_gen_dir/$target_name.d"
_srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
_rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir)
_rebased_sources = rebase_path(invoker.sources, root_build_dir)
- args = [
- "--depfile",
- rebase_path(depfile, root_build_dir),
- "--srcjar=$_rebased_srcjar_path",
- ] + _rebased_sources
+ args = [ "--srcjar=$_rebased_srcjar_path" ] + _rebased_sources
outputs = [ _srcjar_path ]
}
}
@@ -708,12 +703,16 @@ if (enable_java_templates) {
_cpu_family,
]
if (invoker.use_final_fields) {
+ # Write native_libraries_list_file via depfile rather than specifyin it
+ # as a dep in order allow R8 to run in parallel with native compilation.
+ depfile = "$target_gen_dir/$target_name.d"
args += [
"--final",
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
"--native-libraries-list",
rebase_path(invoker.native_libraries_list_file, root_build_dir),
]
- inputs = [ invoker.native_libraries_list_file ]
if (defined(invoker.version_number)) {
args += [
"--version-number",
@@ -1123,12 +1122,9 @@ if (enable_java_templates) {
# }
# }
template("java_group") {
- forward_variables_from(invoker,
- [
- "testonly",
- "input_jars_paths",
- ])
+ forward_variables_from(invoker, [ "testonly" ])
write_build_config("$target_name$build_config_target_suffix") {
+ forward_variables_from(invoker, [ "input_jars_paths" ])
type = "group"
build_config = "$target_gen_dir/${invoker.target_name}.build_config"
supports_android = true
@@ -1136,11 +1132,16 @@ if (enable_java_templates) {
possible_config_deps = invoker.deps
}
}
- java_header_group("${target_name}__header") {
- forward_variables_from(invoker, [ "deps" ])
- }
- java_impl_group("${target_name}__impl") {
- forward_variables_from(invoker, [ "deps" ])
+ foreach(_group_name,
+ [
+ "header",
+ "impl",
+ "assetres",
+ ]) {
+ java_lib_group("${target_name}__${_group_name}") {
+ forward_variables_from(invoker, [ "deps" ])
+ group_name = _group_name
+ }
}
group(target_name) {
forward_variables_from(invoker, "*")
@@ -1335,13 +1336,18 @@ if (enable_java_templates) {
_build_config_target_name = "$target_name$build_config_target_suffix"
_deps = [
"//testing/android/junit:junit_test_support",
+ "//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
- "//third_party/robolectric:robolectric_all_java",
]
if (defined(invoker.deps)) {
_deps += invoker.deps
}
+ if (defined(invoker.alternative_android_sdk_dep)) {
+ _android_sdk_dep = invoker.alternative_android_sdk_dep
+ } else {
+ _android_sdk_dep = "//third_party/android_sdk:android_sdk_java"
+ }
# a package name or a manifest is required to have resources. This is
# added so that junit tests that do not care about the package name can
@@ -1356,7 +1362,9 @@ if (enable_java_templates) {
_compile_resources_target = "${target_name}__compile_resources"
compile_resources(_compile_resources_target) {
forward_variables_from(invoker, [ "android_manifest" ])
- deps = _deps + [ ":$_build_config_target_name" ]
+ deps = _deps
+ android_sdk_dep = _android_sdk_dep
+ build_config_dep = ":$_build_config_target_name"
build_config = _build_config
if (defined(_package_name)) {
rename_manifest_package = _package_name
@@ -1469,7 +1477,6 @@ if (enable_java_templates) {
# [ [ path_to_file, path_to_put_in_jar ] ]
#
# javac_args: Additional arguments to pass to javac.
- # never_goma: When true, ignore the value of use_java_goma.
# errorprone_args: Additional arguments to pass to errorprone.
#
# data_deps, testonly
@@ -1535,11 +1542,6 @@ if (enable_java_templates) {
# deps = [ ":my_java_lib" ]
# output = "$root_build_dir/MyLibrary.jar"
# }
- # dist_jar("sideloaded_dex") {
- # deps = [ ":my_java_lib" ]
- # output = "$root_build_dir/MyLibrary.jar"
- # dex_path = "$root_build_dir/MyLibrary.dex"
- # }
template("dist_jar") {
# TODO(crbug.com/1042017): Remove.
not_needed(invoker, [ "no_build_hooks" ])
@@ -1620,12 +1622,20 @@ if (enable_java_templates) {
} else if (_use_unprocessed_jars) {
args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)" ]
} else {
- args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ]
+ args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
}
}
+ _excludes = []
if (defined(invoker.jar_excluded_patterns)) {
- args +=
- [ "--input-zips-excluded-globs=${invoker.jar_excluded_patterns}" ]
+ _excludes += invoker.jar_excluded_patterns
+ }
+ if (_use_interface_jars) {
+ # Turbine adds files like: META-INF/TRANSITIVE/.../Foo.class
+ # These confuse proguard: https://crbug.com/1081443
+ _excludes += [ "META-INF/*" ]
+ }
+ if (_excludes != []) {
+ args += [ "--input-zips-excluded-globs=$_excludes" ]
}
}
}
@@ -1634,21 +1644,15 @@ if (enable_java_templates) {
#
# Variables:
# output: Path to the output dex.
+ # proguard_enabled: Whether to enable R8.
# 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
# dist_dex("lib_fatjar") {
# deps = [ ":my_java_lib" ]
# output = "$root_build_dir/MyLibrary.jar"
# }
- # dist_jar("sideloaded_dex") {
- # deps = [ ":my_java_lib" ]
- # output = "$root_build_dir/MyLibrary.jar"
- # dex_path = "$root_build_dir/MyLibrary.dex"
- # }
- template("proguarded_dist_dex") {
+ template("dist_dex") {
_deps = [ "//third_party/android_sdk:android_sdk_java" ]
if (defined(invoker.deps)) {
_deps += invoker.deps
@@ -1659,10 +1663,13 @@ if (enable_java_templates) {
write_build_config(_build_config_target_name) {
type = "dist_jar"
- forward_variables_from(invoker, [ "proguard_configs" ])
+ forward_variables_from(invoker,
+ [
+ "proguard_configs",
+ "proguard_enabled",
+ ])
supports_android = true
requires_android = true
- proguard_enabled = true
possible_config_deps = _deps
build_config = _build_config
}
@@ -1670,15 +1677,28 @@ if (enable_java_templates) {
_deps += [ ":$_build_config_target_name" ]
dex(target_name) {
- deps = _deps
- build_config = _build_config
- proguard_enabled = true
forward_variables_from(invoker,
[
+ "data",
+ "data_deps",
+ "visibility",
+ "testonly",
"proguard_configs",
+ "proguard_enabled",
"min_sdk_version",
])
+ deps = _deps
+ build_config = _build_config
+ enable_multidex = false
output = invoker.output
+ if (defined(proguard_enabled) && proguard_enabled) {
+ # When trying to build a stand-alone .dex, don't add in jdk_libs_dex.
+ supports_jdk_library_desugaring = false
+ } else {
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ input_dex_filearg =
+ "@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
+ }
}
}
@@ -1807,8 +1827,6 @@ if (enable_java_templates) {
# Supports all variables of java_library(), plus:
# deps: In addition to defining java deps, this can also include
# android_assets() and android_resources() targets.
- # dex_path: If set, the resulting .dex.jar file will be placed under this
- # path.
# alternative_android_sdk_ijar: if set, the given android_sdk_ijar file
# replaces the default android_sdk_ijar.
# alternative_android_sdk_ijar_dep: the target that generates
@@ -2073,8 +2091,8 @@ if (enable_java_templates) {
# apk or module.
# resources_config_path: Path to the aapt2 optimize config file that tags
# resources with acceptable/non-acceptable optimizations.
- # verify_manifest: Enables verification of expected merged manifest based
- # on a golden file.
+ # expected_android_manifest: Enables verification of expected merged
+ # manifest based on a golden file.
# resource_ids_provider_dep: If passed, this target will use the resource
# IDs generated by {resource_ids_provider_dep}__compile_res during
# resource compilation.
@@ -2113,14 +2131,13 @@ if (enable_java_templates) {
# main_component_library: Specifies the name of the base component's library
# in a component build. If given, the system will find dependent native
# libraries at runtime by inspecting this library (optional).
- # verify_native_libs_and_assets: (optional): If true, will verify the list
- # of included native libraries and assets is consistent with an
+ # expected_libs_and_assets: (optional): Verify the list
+ # of included native libraries and assets is consistent with the given
# expectation file.
template("android_apk_or_module") {
forward_variables_from(invoker, [ "testonly" ])
assert(defined(invoker.android_manifest))
- _out_dir = "$target_out_dir/$target_name"
- _base_path = "$_out_dir/$target_name"
+ _base_path = "$target_out_dir/$target_name/$target_name"
_build_config = "$target_gen_dir/$target_name.build_config"
_build_config_target = "$target_name$build_config_target_suffix"
@@ -2133,9 +2150,6 @@ if (enable_java_templates) {
_target_sdk_version = invoker.target_sdk_version
}
- # JUnit tests use resource zip files. These must not be put in gen/
- # directory or they will not be available to tester bots.
- _jar_path = "$_base_path.jar"
_template_name = target_name
_is_bundle_module =
@@ -2154,9 +2168,11 @@ if (enable_java_templates) {
}
_short_resource_paths =
- defined(invoker.short_resource_paths) && invoker.short_resource_paths
+ defined(invoker.short_resource_paths) && invoker.short_resource_paths &&
+ enable_arsc_obfuscation
_strip_resource_names =
- defined(invoker.strip_resource_names) && invoker.strip_resource_names
+ defined(invoker.strip_resource_names) && invoker.strip_resource_names &&
+ enable_arsc_obfuscation
_optimize_resources = _strip_resource_names || _short_resource_paths
if (!_is_bundle_module && _short_resource_paths) {
@@ -2330,8 +2346,7 @@ if (enable_java_templates) {
_is_static_library_provider =
defined(invoker.static_library_dependent_targets) && _proguard_enabled
if (_is_static_library_provider) {
- _static_library_sync_dex_path =
- "$_out_dir/static_library_synchronized_proguard.r8dex.jar"
+ _static_library_sync_dex_path = "$_base_path.synchronized.r8dex.jar"
_resource_ids_provider_deps = []
foreach(_target, invoker.static_library_dependent_targets) {
if (_target.is_resource_ids_provider) {
@@ -2405,9 +2420,7 @@ if (enable_java_templates) {
_final_deps = []
- _enable_main_dex_list =
- _enable_multidex &&
- (!defined(invoker.min_sdk_version) || invoker.min_sdk_version < 21)
+ _enable_main_dex_list = _enable_multidex && _min_sdk_version < 21
if (_enable_main_dex_list) {
_generated_proguard_main_dex_config =
"$_base_path.resources.main-dex-proguard.txt"
@@ -2453,6 +2466,8 @@ if (enable_java_templates) {
[
"aapt_locale_allowlist",
"app_as_shared_lib",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
"manifest_package",
"max_sdk_version",
"no_xml_namespaces",
@@ -2466,22 +2481,19 @@ if (enable_java_templates) {
"resources_config_path",
"shared_resources",
"shared_resources_allowlist_locales",
- "short_resource_paths",
- "strip_resource_names",
"support_zh_hk",
])
+ short_resource_paths = _short_resource_paths
+ strip_resource_names = _strip_resource_names
android_manifest = _android_manifest
+ android_manifest_dep = ":$_merge_manifest_target"
version_code = _version_code
version_name = _version_name
min_sdk_version = _min_sdk_version
target_sdk_version = _target_sdk_version
- if (defined(invoker.verify_manifest) && invoker.verify_manifest &&
- !is_java_debug) {
- verify_manifest_target_name = _template_name
- build_config_dep = ":$_build_config_target"
- android_manifest_dep = ":$_merge_manifest_target"
- forward_variables_from(invoker,
- [ "expected_manifest_base_expectation" ])
+
+ if (defined(expected_android_manifest)) {
+ top_target_name = _template_name
}
if (defined(_resource_ids_provider_dep)) {
@@ -2503,11 +2515,9 @@ if (enable_java_templates) {
}
build_config = _build_config
- deps = _deps + [
- ":$_merge_manifest_target",
- ":$_build_config_target",
- _android_sdk_dep,
- ]
+ build_config_dep = ":$_build_config_target"
+ android_sdk_dep = _android_sdk_dep
+ deps = _deps
# The static library uses the R.txt files generated by the
# static_library_dependent_targets when generating the final R.java file.
@@ -2622,16 +2632,17 @@ if (enable_java_templates) {
if (_generate_native_libraries_java) {
write_native_libraries_java("${_template_name}__native_libraries") {
forward_variables_from(invoker, [ "main_component_library" ])
- deps = [
- ":${_template_name}__secondary_abi_shared_library_list",
- ":${_template_name}__shared_library_list",
- ]
+ deps = []
if (defined(invoker.native_lib_version_rule)) {
deps += [ invoker.native_lib_version_rule ]
}
if (defined(invoker.native_lib_version_arg)) {
version_number = invoker.native_lib_version_arg
}
+
+ # Do not add a dep on the generated_file target in order to avoid having
+ # to build the native libraries before this target. The dependency is
+ # instead captured via a depfile.
if (_native_libs_deps != []) {
native_libraries_list_file = _shared_library_list_file
} else {
@@ -2750,7 +2761,6 @@ if (enable_java_templates) {
"javac_args",
"native_lib_placeholders",
"processor_args_javac",
- "skip_jetify",
"secondary_abi_loadable_modules",
"secondary_native_lib_placeholders",
"sources",
@@ -2784,7 +2794,6 @@ if (enable_java_templates) {
supports_android = true
requires_android = true
srcjar_deps = _srcjar_deps
- final_jar_path = _jar_path
if (defined(_final_dex_path)) {
final_dex_path = _final_dex_path
}
@@ -2824,10 +2833,9 @@ if (enable_java_templates) {
}
}
- # Don't depend on the runtime_deps target in order to avoid having to
- # build the native libraries just to create the .build_config file.
- # The dep is unnecessary since the runtime_deps file is created by gn gen
- # and the runtime_deps file is added to write_build_config.py's depfile.
+ # Do not add a dep on the generated_file target in order to avoid having
+ # to build the native libraries before this target. The dependency is
+ # instead captured via a depfile.
if (_native_libs_deps != []) {
shared_libraries_runtime_deps_file = _shared_library_list_file
}
@@ -2866,13 +2874,6 @@ if (enable_java_templates) {
if (_uses_static_library_synchronized_proguard) {
_final_dex_target_dep = "${invoker.static_library_provider}__dexsplitter"
} 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" ]
} else if (_incremental_apk) {
if (defined(invoker.negative_main_dex_globs)) {
@@ -2910,16 +2911,21 @@ if (enable_java_templates) {
":$_java_target",
]
if (_proguard_enabled) {
- forward_variables_from(invoker, [ "proguard_jar_path" ])
deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code"
- } else {
+ has_apk_under_test = defined(invoker.apk_under_test)
+ } else if (_min_sdk_version >= default_min_sdk_version) {
+ # Enable dex merging only when min_sdk_version is >= what the library
+ # .dex files were created with.
input_dex_filearg =
"@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
if (_enable_main_dex_list) {
- main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)"
+ main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath_extended)"
}
+ } else {
+ input_classes_filearg =
+ "@FileArg($_rebased_build_config:deps_info:device_classpath)"
}
if (_is_static_library_provider) {
@@ -3137,6 +3143,7 @@ if (enable_java_templates) {
package_apk("$_create_apk_target") {
forward_variables_from(invoker,
[
+ "expected_libs_and_assets",
"native_lib_placeholders",
"secondary_abi_loadable_modules",
"secondary_native_lib_placeholders",
@@ -3146,10 +3153,9 @@ if (enable_java_templates) {
"library_renames",
])
- if (defined(invoker.verify_native_libs_and_assets) &&
- invoker.verify_native_libs_and_assets) {
- verify_native_libs_and_assets_target_name = _template_name
+ if (defined(expected_libs_and_assets)) {
build_config_dep = ":$_build_config_target"
+ top_target_name = _template_name
}
build_config = _build_config
@@ -3161,8 +3167,7 @@ if (enable_java_templates) {
deps = _deps + [ ":$_build_config_target" ]
- # TODO(https://crbug.com/1056751): Add support for proguarding jdk libs.
- if (enable_jdk_library_desugaring) {
+ if (!_proguard_enabled && enable_jdk_library_desugaring) {
_all_jdk_libs = "//build/android:all_jdk_libs"
deps += [ _all_jdk_libs ]
jdk_libs_dex = get_label_info(_all_jdk_libs, "target_out_dir") +
@@ -3170,16 +3175,14 @@ if (enable_java_templates) {
}
if (_incremental_apk) {
- _dex_target =
- "//build/android/incremental_install:bootstrap_java__dex"
+ _dex_target = "//build/android/incremental_install:apk_dex"
deps += [
":${_incremental_compile_resources_target_name}",
_dex_target,
]
- dex_path =
- get_label_info(_dex_target, "target_out_dir") + "/bootstrap.dex"
+ dex_path = get_label_info(_dex_target, "target_out_dir") + "/apk.dex"
# All native libraries are side-loaded, so use a placeholder to force
# the proper bitness for the app.
@@ -3353,17 +3356,22 @@ if (enable_java_templates) {
android_lint(_android_lint_target) {
forward_variables_from(invoker,
[
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"manifest_package",
"min_sdk_version",
])
build_config = _build_config
- deps = [
- ":$_build_config_target",
- ":$_java_target",
- ]
+ build_config_dep = ":$_build_config_target"
+ deps = [ ":$_java_target" ]
}
} else {
- not_needed(invoker, [ "manifest_package" ])
+ not_needed(invoker,
+ [
+ "manifest_package",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
+ ])
}
group(target_name) {
@@ -3382,14 +3390,16 @@ if (enable_java_templates) {
data_deps = []
}
+ # Include unstripped native libraries so tests can symbolize stacks.
+ data_deps += _all_native_libs_deps
+
if (_enable_lint) {
data_deps += [ ":$_android_lint_target" ]
}
if (_incremental_apk) {
# device/commands is used by the installer script to push files via .zip.
- data_deps +=
- [ "//build/android/pylib/device/commands" ] + _native_libs_deps
+ data_deps += [ "//build/android/pylib/device/commands" ]
}
if (_uses_static_library) {
data_deps += [ invoker.static_library_provider ]
@@ -3465,6 +3475,8 @@ if (enable_java_templates) {
"keystore_name",
"keystore_password",
"keystore_path",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"load_library_from_apk",
"loadable_modules",
"manifest_package",
@@ -3484,7 +3496,6 @@ if (enable_java_templates) {
"product_version_resources_dep",
"proguard_configs",
"proguard_enabled",
- "proguard_jar_path",
"r_java_root_package_name",
"resource_exclusion_exceptions",
"resource_exclusion_regex",
@@ -3495,7 +3506,6 @@ if (enable_java_templates) {
"secondary_abi_loadable_modules",
"secondary_abi_shared_libraries",
"secondary_native_lib_placeholders",
- "skip_jetify",
"shared_libraries",
"shared_resources",
"shared_resources_allowlist_locales",
@@ -3515,9 +3525,9 @@ if (enable_java_templates) {
"library_always_compress",
"library_renames",
"use_chromium_linker",
- "verify_manifest",
- "expected_manifest_base_expectation",
- "verify_native_libs_and_assets",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
+ "expected_libs_and_assets",
"version_code",
"version_name",
])
@@ -3615,7 +3625,6 @@ if (enable_java_templates) {
"product_version_resources_dep",
"proguard_configs",
"proguard_enabled",
- "proguard_jar_path",
"resource_exclusion_exceptions",
"resource_exclusion_regex",
"resource_ids_provider_dep",
@@ -3641,8 +3650,8 @@ if (enable_java_templates) {
"library_renames",
"use_chromium_linker",
"use_modern_linker",
- "verify_manifest",
- "expected_manifest_base_expectation",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
"version_code",
"version_name",
])
@@ -4045,12 +4054,13 @@ if (enable_java_templates) {
# Use the regular proto library to generate lite protos.
_protoc_bin = "//third_party/android_protoc/protoc"
_proto_runtime = "//third_party/android_deps:com_google_protobuf_protobuf_javalite_java"
- _protoc_javalite_plugin_dir = "//third_party/protoc_javalite/"
}
_proto_path = invoker.proto_path
_template_name = target_name
action_with_pydeps("${_template_name}__protoc_java") {
+ # The suffix "__protoc_java.srcjar" is used by SuperSize to identify
+ # protobuf symbols.
_srcjar_path = "$target_gen_dir/$target_name.srcjar"
script = "//build/protoc_java.py"
@@ -4087,11 +4097,6 @@ if (enable_java_templates) {
if (_generate_nano) {
args += [ "--nano" ]
- } else {
- args += [
- "--protoc-javalite-plugin-dir",
- rebase_path(_protoc_javalite_plugin_dir, root_build_dir),
- ]
}
}
@@ -4148,7 +4153,13 @@ if (enable_java_templates) {
_info_path = invoker.info_path
}
_output_path = "${target_out_dir}/${target_name}"
- _unpack_target_name = "${target_name}__unpack_aar"
+ _target_name_without_java_or_junit =
+ string_replace(string_replace(target_name, "_java", ""), "_junit", "")
+
+ # This unpack target is a python action, not a valid java target. Since the
+ # java targets below depend on it, its name must not match the java patterns
+ # in internal_rules.gni.
+ _unpack_target_name = "${_target_name_without_java_or_junit}__unpack_aar"
_ignore_aidl = defined(invoker.ignore_aidl) && invoker.ignore_aidl
_ignore_assets = defined(invoker.ignore_assets) && invoker.ignore_assets
_ignore_manifest =
@@ -4237,8 +4248,14 @@ if (enable_java_templates) {
outputs +=
get_path_info(rebase_path(_scanned_files.subjars, "", _output_path),
"abspath")
- if (!_ignore_proguard_configs && _scanned_files.has_proguard_flags) {
- outputs += [ "${_output_path}/proguard.txt" ]
+ if (!_ignore_proguard_configs) {
+ if (_scanned_files.has_proguard_flags) {
+ outputs += [ "${_output_path}/proguard.txt" ]
+ }
+ if (defined(_scanned_files.has_proguard_check_flags) &&
+ _scanned_files.has_proguard_check_flags) {
+ outputs += [ "${_output_path}/proguard-checks.txt" ]
+ }
}
if (_extract_native_libraries && _scanned_files.has_native_libraries) {
@@ -4255,7 +4272,7 @@ if (enable_java_templates) {
# Create the android_resources target for resources.
if (_has_unignored_resources ||
(!_scanned_files.is_manifest_empty && !_ignore_manifest)) {
- _res_target_name = "${target_name}__res"
+ _res_target_name = "${target_name}__resources"
android_resources(_res_target_name) {
forward_variables_from(invoker,
[
@@ -4285,38 +4302,37 @@ if (enable_java_templates) {
not_needed(invoker, [ "strip_drawables" ])
}
- _java_library_vars = [
- "enable_bytecode_checks",
- "enable_bytecode_rewriter",
- "missing_classes_allowlist",
- "enable_jetify",
- "jar_excluded_patterns",
- "jar_included_patterns",
- "requires_android",
- "skip_jetify",
- "testonly",
- ]
+ # Create android_java_prebuilt target for classes.jar.
+ if (_scanned_files.has_classes_jar) {
+ _java_library_vars = [
+ "enable_bytecode_checks",
+ "enable_jetify",
+ "jar_excluded_patterns",
+ "jar_included_patterns",
+ "missing_classes_allowlist",
+ "requires_android",
+ "testonly",
+ ]
- # Create android_java_prebuilt target for extra jars within jars/.
- _subjar_targets = []
- foreach(_tuple, _scanned_files.subjar_tuples) {
- _current_target = "${target_name}__subjar_${_tuple[0]}"
- _subjar_targets += [ ":$_current_target" ]
- java_prebuilt(_current_target) {
- forward_variables_from(invoker, _java_library_vars)
- deps = [ ":$_unpack_target_name" ]
- if (!defined(requires_android)) {
- requires_android = true
+ # Create android_java_prebuilt target for extra jars within jars/.
+ _subjar_targets = []
+ foreach(_tuple, _scanned_files.subjar_tuples) {
+ _current_target = "${target_name}__subjar_${_tuple[0]}"
+ _subjar_targets += [ ":$_current_target" ]
+ java_prebuilt(_current_target) {
+ forward_variables_from(invoker, _java_library_vars)
+ deps = [ ":$_unpack_target_name" ]
+ if (!defined(requires_android)) {
+ requires_android = true
+ }
+ supports_android = true
+ jar_path = "$_output_path/${_tuple[1]}"
+ _base_output_name = get_path_info(jar_path, "name")
+ output_name = "${invoker.target_name}-$_base_output_name"
+ public_target_label = invoker.target_name
}
- supports_android = true
- jar_path = "$_output_path/${_tuple[1]}"
- _base_output_name = get_path_info(jar_path, "name")
- output_name = "${invoker.target_name}-$_base_output_name"
}
- }
- # Create android_java_prebuilt target for classes.jar.
- if (_scanned_files.has_classes_jar) {
_jar_target_name = "${target_name}__classes"
java_prebuilt(_jar_target_name) {
forward_variables_from(invoker, _java_library_vars)
@@ -4340,12 +4356,19 @@ if (enable_java_templates) {
jar_path = "$_output_path/classes.jar"
output_name = invoker.target_name
- if (!_ignore_proguard_configs && _scanned_files.has_proguard_flags) {
+ if (!_ignore_proguard_configs) {
if (!defined(proguard_configs)) {
proguard_configs = []
}
- proguard_configs += [ "$_output_path/proguard.txt" ]
+ if (_scanned_files.has_proguard_flags) {
+ proguard_configs += [ "$_output_path/proguard.txt" ]
+ }
+ if (defined(_scanned_files.has_proguard_check_flags) &&
+ _scanned_files.has_proguard_check_flags) {
+ proguard_configs += [ "$_output_path/proguard-checks.txt" ]
+ }
}
+ public_target_label = invoker.target_name
}
}
@@ -4416,9 +4439,6 @@ if (enable_java_templates) {
# bundle. Default is to enable this only for release builds. Note that
# 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
# when using synchronized proguarding. Only applies to base module.
#
@@ -4439,16 +4459,16 @@ if (enable_java_templates) {
# avoid library duplication. Effectively, the static library will be
# treated as the parent of the base module.
#
- # verify_proguard_flags: Enables verification of expected merged proguard
- # flags based on a golden file.
+ # expected_proguard_config: Checks that the merged set of proguard flags
+ # matches the given config.
#
# version_code: Optional. Version code of the target.
#
# is_multi_abi: If true will add a library placeholder for the missing ABI
# if either the primary or the secondary ABI has no native libraries set.
#
- # verify_native_libs_and_assets: (optional): If true, will verify the list
- # of included native libraries and assets is consistent with an
+ # expected_libs_and_assets: (optional): Verify the list
+ # of included native libraries and assets is consistent with the given
# expectation file.
#
# default_modules_for_testing: (optional): A list of DFM that the wrapper
@@ -4669,28 +4689,22 @@ if (enable_java_templates) {
if (defined(invoker.min_sdk_version)) {
not_needed(invoker, [ "min_sdk_version" ])
}
- if (defined(proguard_jar_path)) {
- not_needed(invoker, [ "proguard_jar_path" ])
- }
} else {
- _verify_proguard_flags = defined(invoker.verify_proguard_flags) &&
- invoker.verify_proguard_flags
dex(_dex_target) {
forward_variables_from(invoker,
[
- "proguard_jar_path",
+ "expected_proguard_config",
"min_sdk_version",
])
+ if (defined(expected_proguard_config)) {
+ top_target_name = _target_name
+ }
enable_multidex = _enable_multidex
proguard_enabled = true
proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code"
build_config = _build_config
- if (_verify_proguard_flags) {
- verify_proguard_flags_target_name = _target_name
- }
-
deps = _module_java_targets + [ ":$_build_config_target" ]
modules = _modules
}
@@ -4725,6 +4739,7 @@ if (enable_java_templates) {
"is_multi_abi",
"min_sdk_version",
"uncompress_dex",
+ "proguard_enabled",
])
module_name = _module.name
build_config = _module_build_config
@@ -4732,9 +4747,9 @@ if (enable_java_templates) {
native_libraries_config = _native_libraries_config
if (module_name == "base" &&
- defined(invoker.verify_native_libs_and_assets) &&
- invoker.verify_native_libs_and_assets) {
- verify_native_libs_and_assets_target_name = "${_target_name}__base"
+ defined(invoker.expected_libs_and_assets)) {
+ top_target_name = _target_name
+ expected_libs_and_assets = invoker.expected_libs_and_assets
build_config_target = _module_build_config_target
native_libraries_config_target = ":$_native_libraries_config_target"
if (defined(android_app_secondary_abi)) {
@@ -4968,15 +4983,22 @@ if (enable_java_templates) {
android_lint(_android_lint_target) {
forward_variables_from(invoker,
[
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"manifest_package",
"min_sdk_version",
- "lint_suppressions_file",
])
build_config = _build_config
- deps = _module_java_targets + [ ":$_build_config_target" ]
+ build_config_dep = ":$_build_config_target"
+ deps = _module_java_targets
}
} else {
- not_needed(invoker, [ "manifest_package" ])
+ not_needed(invoker,
+ [
+ "manifest_package",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
+ ])
}
group(_target_name) {
@@ -5085,17 +5107,11 @@ template("generate_ui_locale_resources") {
_output_zip = "${root_out_dir}/resource_zips/${_rebased_output_zip_path}/" +
"${target_name}.zip"
- _locales = invoker.ui_locales
- _depfile = "$target_gen_dir/$target_name.d"
-
- action(_generating_target_name) {
+ action_with_pydeps(_generating_target_name) {
script = "//build/android/gyp/create_ui_locale_resources.py"
- depfile = _depfile
outputs = [ _output_zip ]
args = [
- "--locale-list=$_locales",
- "--depfile",
- rebase_path(_depfile, root_build_dir),
+ "--locale-list=${invoker.ui_locales}",
"--output-zip",
rebase_path(_output_zip, root_build_dir),
]