Android: Define paths to expectation files in leaf targets

This is easier to follow then deriving it in the templates.

Also changes webview expectations apk->bundle

Bug: 1095654
Change-Id: I5952ee9a660e4f32b22ef4100fea2f231d9eb96d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245880
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#780157}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 4a914f2106e06d3cee338fdd4ee46457e985df97
This commit is contained in:
Andrew Grieve 2020-06-19 03:47:46 +00:00 коммит произвёл Commit Bot
Родитель 3591130cc1
Коммит 7465bac9cb
2 изменённых файлов: 97 добавлений и 124 удалений

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

@ -1180,45 +1180,39 @@ if (enable_java_templates) {
_args += invoker.args
}
if (defined(invoker.verify_proguard_flags_target_name)) {
_expectations_target = "${invoker.verify_proguard_flags_target_name}" +
"_proguard_expectations"
if (defined(invoker.expected_proguard_config)) {
_expectations_target =
"${invoker.top_target_name}_validate_proguard_config"
action_with_pydeps(_expectations_target) {
_expected_configs_file =
get_label_info(":${invoker.verify_proguard_flags_target_name}",
"dir") +
"/java/${invoker.verify_proguard_flags_target_name}" +
".proguard_flags.expected"
_failed_proguard_expectation_file =
"$android_configuration_failure_dir/" +
string_replace(_expected_configs_file, "/", "_")
_expectation_stamp = "${target_gen_dir}/${_expectations_target}.stamp"
if (fail_on_android_expectations) {
args += [ "--fail-on-expectations" ]
}
script = _script
# Need to depend on all deps so that proguard.txt within .aar files get
# extracted.
deps = _deps
pool = _pool
depfile = "${target_gen_dir}/${target_name}.d"
inputs = [
invoker.build_config,
_expected_configs_file,
invoker.expected_proguard_config,
]
_failure_file =
"$android_configuration_failure_dir/" +
string_replace(invoker.expected_proguard_config, "/", "_")
_expectation_stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ _expectation_stamp ]
args = _args + [
"--depfile",
rebase_path(depfile, root_build_dir),
"--proguard-expectations-failure-file",
rebase_path(_failed_proguard_expectation_file, root_build_dir),
rebase_path(_failure_file, root_build_dir),
"--expected-configs-file",
rebase_path(_expected_configs_file, root_build_dir),
rebase_path(invoker.expected_proguard_config, root_build_dir),
"--stamp",
rebase_path(_expectation_stamp, root_build_dir),
"--only-verify-expectations",
]
if (fail_on_android_expectations) {
args += [ "--fail-on-expectations" ]
}
}
_deps += [ ":$_expectations_target" ]
}
@ -1355,13 +1349,14 @@ if (enable_java_templates) {
"deps",
"disable_checkdiscard",
"disable_r8_outlining",
"expected_proguard_config",
"is_static_library",
"modules",
"proguard_mapping_path",
"proguard_sourcefile_suffix",
"supports_jdk_library_desugaring",
"testonly",
"verify_proguard_flags_target_name",
"top_target_name",
"visibiity",
])
inputs = []
@ -2531,43 +2526,26 @@ if (enable_java_templates) {
_args += [ "--is-bundle-module" ]
}
if (defined(invoker.verify_manifest_target_name)) {
if (defined(invoker.expected_android_manifest)) {
_expectations_target =
"${invoker.verify_manifest_target_name}_manifest_expectations"
"${invoker.top_target_name}_validate_android_manifest"
action_with_pydeps(_expectations_target) {
_target_src_dir = get_label_info(":$target_name", "dir")
_normalized_output = "${invoker.android_manifest}.normalized"
_manifest_expectations_failure_filepath =
_failure_file =
"$android_configuration_failure_dir/" +
"${invoker.verify_manifest_target_name}.AndroidManifest.failed"
string_replace(invoker.expected_android_manifest, "/", "_")
inputs = [
invoker.android_manifest,
invoker.build_config,
invoker.expected_android_manifest,
]
if (defined(invoker.expected_manifest_base_expectation)) {
if (defined(invoker.expected_android_manifest_base)) {
_args += [
"--expected-manifest-base-expectation",
rebase_path(invoker.expected_manifest_base_expectation,
root_build_dir),
rebase_path(invoker.expected_android_manifest_base, root_build_dir),
]
inputs += [ invoker.expected_manifest_base_expectation ]
# When invoker.expected_manifest_base_expectation is defined, we use
# a different file extension to indicate that the expected file is a
# diff file.
# In addition, we set expected_manifest_base_expectation only for
# internal targets, therefore, the expected file is in a different
# directory.
_expected_file =
"$_target_src_dir/" +
"${invoker.verify_manifest_target_name}.AndroidManifest" +
".diff.expected"
} else {
_expected_file =
"$_target_src_dir/java/" +
"${invoker.verify_manifest_target_name}.AndroidManifest.expected"
inputs += [ invoker.expected_android_manifest_base ]
}
inputs += [ _expected_file ]
if (fail_on_android_expectations) {
_args += [ "--fail-on-expectations" ]
}
@ -2580,12 +2558,11 @@ if (enable_java_templates) {
script = _script
args = _args + [
"--expected-file",
rebase_path(_expected_file, root_build_dir),
rebase_path(invoker.expected_android_manifest, root_build_dir),
"--android-manifest-normalized",
rebase_path(_normalized_output, root_build_dir),
"--android-manifest-expectations-failure-file",
rebase_path(_manifest_expectations_failure_filepath,
root_build_dir),
rebase_path(_failure_file, root_build_dir),
"--only-verify-expectations",
]
}
@ -2700,9 +2677,8 @@ if (enable_java_templates) {
# keystore_password: Keystore password.
# uncompress_shared_libraries: (optional, default false) Whether to store
# native libraries inside the APK uncompressed and page-aligned.
# verify_native_libs_and_assets_target_name: (optional): If set, will verify
# the list of included native libraries and assets is consistent with an
# expectation file.
# expected_libs_and_assets: (optional): Verify the list of included native
# libraries and assets is consistent with the given expectation file.
template("package_apk") {
forward_variables_from(invoker,
[
@ -2828,43 +2804,33 @@ if (enable_java_templates) {
_args += [ "--secondary-native-lib-placeholders=$_secondary_native_lib_placeholders" ]
}
if (defined(invoker.verify_native_libs_and_assets_target_name)) {
if (defined(invoker.expected_libs_and_assets)) {
_expectations_target =
"${invoker.verify_native_libs_and_assets_target_name}" +
"_libs_and_assets_expectations"
"${invoker.top_target_name}_validate_libs_and_assets"
action_with_pydeps(_expectations_target) {
_stamp = "$target_gen_dir/$target_name.stamp"
_target_src_dir = get_label_info(":$target_name", "dir")
_expected_native_libs_and_assets =
"$_target_src_dir/java/" +
"${invoker.verify_native_libs_and_assets_target_name}." +
"${target_cpu}.native_libs_and_assets.expected"
_native_libs_and_assets_expectation_failure_filepath =
_failure_file =
"$android_configuration_failure_dir/" +
"${invoker.verify_native_libs_and_assets_target_name}." +
"${target_cpu}.native_libs_and_assets.failed"
if (fail_on_android_expectations) {
_args += [ "--fail-on-expectations" ]
}
string_replace(invoker.expected_libs_and_assets, "/", "_")
inputs = [
invoker.build_config,
_expected_native_libs_and_assets,
invoker.expected_libs_and_assets,
]
deps = [ invoker.build_config_dep ]
outputs = [ _stamp ]
script = _script
args =
_args + [
"--expected-native-libs-and-assets",
rebase_path(_expected_native_libs_and_assets, root_build_dir),
"--native-libs-and-assets-expectation-failure-file",
rebase_path(_native_libs_and_assets_expectation_failure_filepath,
root_build_dir),
"--stamp",
rebase_path(_stamp, root_build_dir),
"--only-verify-expectations",
]
args = _args + [
"--expected-native-libs-and-assets",
rebase_path(invoker.expected_libs_and_assets, root_build_dir),
"--native-libs-and-assets-expectation-failure-file",
rebase_path(_failure_file, root_build_dir),
"--stamp",
rebase_path(_stamp, root_build_dir),
"--only-verify-expectations",
]
if (fail_on_android_expectations) {
args += [ "--fail-on-expectations" ]
}
}
_deps += [ ":$_expectations_target" ]
}
@ -3880,9 +3846,8 @@ if (enable_java_templates) {
# packaged into each module.
# 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_target_name: (optional): If set, will verify
# the list of included native libraries and assets is consistent with an
# expectation file.
# expected_libs_and_assets: (optional): Verify the list of included native
# libraries and assets is consistent with the given expectation file.
# proguard_enabled: Optional. True if proguarding is enabled for this
# bundle. Default is to enable this only for release builds. Note that
# this will always perform synchronized proguarding.
@ -3976,26 +3941,14 @@ template("create_android_app_bundle_module") {
]
}
if (defined(invoker.verify_native_libs_and_assets_target_name)) {
_expectations_target =
"${invoker.verify_native_libs_and_assets_target_name}" +
"_libs_and_assets_expectations"
if (defined(invoker.expected_libs_and_assets)) {
_expectations_target = "${invoker.top_target_name}_validate_libs_and_assets"
action_with_pydeps(_expectations_target) {
_stamp = "$target_gen_dir/$target_name.stamp"
_target_src_dir = get_label_info(":$target_name", "dir")
_expected_native_libs_and_assets =
"$_target_src_dir/java/" +
"${invoker.verify_native_libs_and_assets_target_name}." +
"${target_cpu}.native_libs_and_assets.expected"
_native_libs_and_assets_expectation_failure_filepath =
"$android_configuration_failure_dir/" +
"${invoker.verify_native_libs_and_assets_target_name}." +
"${target_cpu}.native_libs_and_assets.failed"
if (fail_on_android_expectations) {
_args += [ "--fail-on-expectations" ]
}
_failure_file = "$android_configuration_failure_dir/" +
string_replace(invoker.expected_libs_and_assets, "/", "_")
inputs = [
_expected_native_libs_and_assets,
invoker.expected_libs_and_assets,
invoker.build_config,
invoker.native_libraries_config,
]
@ -4011,14 +3964,16 @@ template("create_android_app_bundle_module") {
script = _script
args = _args + [
"--expected-native-libs-and-assets",
rebase_path(_expected_native_libs_and_assets, root_build_dir),
rebase_path(invoker.expected_libs_and_assets, root_build_dir),
"--native-libs-and-assets-expectation-failure-file",
rebase_path(_native_libs_and_assets_expectation_failure_filepath,
root_build_dir),
rebase_path(_failure_file, root_build_dir),
"--stamp",
rebase_path(_stamp, root_build_dir),
"--only-verify-expectations",
]
if (fail_on_android_expectations) {
args += [ "--fail-on-expectations" ]
}
}
_deps += [ ":$_expectations_target" ]
}

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

@ -2094,6 +2094,8 @@ if (enable_java_templates) {
# 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.
@ -2132,8 +2134,8 @@ 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" ])
@ -2467,6 +2469,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",
@ -2490,11 +2494,22 @@ if (enable_java_templates) {
version_name = _version_name
min_sdk_version = _min_sdk_version
target_sdk_version = _target_sdk_version
# TODO(agrieve): Remove verify_manifest in favor of expected_android_manifest.
if (defined(invoker.verify_manifest) && invoker.verify_manifest &&
!is_java_debug) {
verify_manifest_target_name = _template_name
forward_variables_from(invoker,
[ "expected_manifest_base_expectation" ])
_target_src_dir = get_label_info(":$target_name", "dir")
expected_android_manifest =
"$_target_src_dir/java/$_template_name.AndroidManifest.expected"
if (defined(invoker.expected_manifest_base_expectation)) {
expected_android_manifest_base =
invoker.expected_manifest_base_expectation
expected_android_manifest =
"$_target_src_dir/$_template_name.AndroidManifest.diff.expected"
}
}
if (defined(expected_android_manifest)) {
top_target_name = _template_name
}
if (defined(_resource_ids_provider_dep)) {
@ -3144,6 +3159,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",
@ -3153,10 +3169,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
@ -3525,8 +3540,9 @@ if (enable_java_templates) {
"library_renames",
"use_chromium_linker",
"verify_manifest",
"expected_android_manifest",
"expected_manifest_base_expectation",
"verify_native_libs_and_assets",
"expected_libs_and_assets",
"version_code",
"version_name",
])
@ -3650,6 +3666,7 @@ if (enable_java_templates) {
"use_chromium_linker",
"use_modern_linker",
"verify_manifest",
"expected_android_manifest",
"expected_manifest_base_expectation",
"version_code",
"version_name",
@ -4464,16 +4481,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
@ -4695,20 +4712,21 @@ if (enable_java_templates) {
not_needed(invoker, [ "min_sdk_version" ])
}
} else {
_verify_proguard_flags = defined(invoker.verify_proguard_flags) &&
invoker.verify_proguard_flags
dex(_dex_target) {
forward_variables_from(invoker, [ "min_sdk_version" ])
forward_variables_from(invoker,
[
"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
}
@ -4751,9 +4769,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)) {