Commit 3c297214 authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

check_android_configuration no longer fails build

The check_android_configuration gn arg is only used by the
android-binary-size trybot. This cl changes the behavior of the arg to
instead of breaking the build to touch a stamp file that will be looked
for by the trybot. This allows the trybot to calculate the binary size
differences before failing.

Bug: 1011227
Change-Id: I5ac888c32e93264b38da707ad86a46b11c6cbb1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854499
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707868}
parent bc2f5ffd
...@@ -50,6 +50,8 @@ if (enable_java_templates) { ...@@ -50,6 +50,8 @@ if (enable_java_templates) {
"android_sdk_version=$android_sdk_version", "android_sdk_version=$android_sdk_version",
"android_ndk_root=" + rebase_path(android_ndk_root, root_build_dir), "android_ndk_root=" + rebase_path(android_ndk_root, root_build_dir),
"android_tool_prefix=" + rebase_path(android_tool_prefix, root_build_dir), "android_tool_prefix=" + rebase_path(android_tool_prefix, root_build_dir),
"android_configuration_failure_dir=" +
rebase_path(android_configuration_failure_dir, root_build_dir),
] ]
if (defined(android_secondary_abi_cpu)) { if (defined(android_secondary_abi_cpu)) {
_secondary_label_info = _secondary_label_info =
......
...@@ -69,11 +69,9 @@ def _ParseArgs(args): ...@@ -69,11 +69,9 @@ def _ParseArgs(args):
input_opts.add_argument( input_opts.add_argument(
'--android-manifest-normalized', help='Normalized manifest.') '--android-manifest-normalized', help='Normalized manifest.')
input_opts.add_argument( input_opts.add_argument(
'--fail-if-unexpected-android-manifest', '--android-manifest-expectations-failure-file',
action='store_true', help='Write to this file if expected manifest contents do not match '
help= 'final manifest contents.')
'Fail if expected manifest contents do not match final manifest contents.'
)
input_opts.add_argument( input_opts.add_argument(
'--r-java-root-package-name', '--r-java-root-package-name',
default='base', default='base',
...@@ -476,18 +474,26 @@ def _FixManifest(options, temp_dir): ...@@ -476,18 +474,26 @@ def _FixManifest(options, temp_dir):
def _VerifyManifest(actual_manifest, expected_manifest, normalized_manifest, def _VerifyManifest(actual_manifest, expected_manifest, normalized_manifest,
fail_if_unexpected_manifest): unexpected_manifest_failure_file):
with build_utils.AtomicOutput(normalized_manifest) as normalized_output: with build_utils.AtomicOutput(normalized_manifest) as normalized_output:
normalized_output.write(manifest_utils.NormalizeManifest(actual_manifest)) normalized_output.write(manifest_utils.NormalizeManifest(actual_manifest))
msg = diff_utils.DiffFileContents(expected_manifest, normalized_manifest) msg = diff_utils.DiffFileContents(expected_manifest, normalized_manifest)
if msg: if not msg:
sys.stderr.write("""\ return
msg_header = """\
AndroidManifest.xml expectations file needs updating. For details see: AndroidManifest.xml expectations file needs updating. For details see:
https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/android/java/README.md https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/android/java/README.md
""") """
sys.stderr.write(msg) sys.stderr.write(msg_header)
if fail_if_unexpected_manifest: sys.stderr.write(msg)
sys.exit(1) if unexpected_manifest_failure_file:
build_utils.MakeDirectory(os.path.dirname(unexpected_manifest_failure_file))
with open(unexpected_manifest_failure_file, 'w') as f:
f.write(msg_header)
f.write(msg)
#TODO(mheikal): remove once trybot recipe handles failure files.
sys.exit(1)
def _CreateKeepPredicate(resource_blacklist_regex, def _CreateKeepPredicate(resource_blacklist_regex,
...@@ -741,7 +747,7 @@ def _PackageApk(options, build): ...@@ -741,7 +747,7 @@ def _PackageApk(options, build):
if options.android_manifest_expected: if options.android_manifest_expected:
_VerifyManifest(fixed_manifest, options.android_manifest_expected, _VerifyManifest(fixed_manifest, options.android_manifest_expected,
options.android_manifest_normalized, options.android_manifest_normalized,
options.fail_if_unexpected_android_manifest) options.android_manifest_expectations_failure_file)
link_command += [ link_command += [
'--manifest', fixed_manifest, '--rename-manifest-package', '--manifest', fixed_manifest, '--rename-manifest-package',
......
...@@ -93,10 +93,9 @@ def _ParseOptions(): ...@@ -93,10 +93,9 @@ def _ParseOptions():
'--expected-configs-file', '--expected-configs-file',
help='Path to a file containing the expected merged ProGuard configs') help='Path to a file containing the expected merged ProGuard configs')
parser.add_argument( parser.add_argument(
'--verify-expected-configs', '--proguard-expectations-failure-file',
action='store_true', help='Path to file written to if the expected merged ProGuard configs '
help='Fail if the expected merged ProGuard configs differ from the ' 'differ from the generated merged ProGuard configs.')
'generated merged ProGuard configs.')
parser.add_argument( parser.add_argument(
'--classpath', '--classpath',
action='append', action='append',
...@@ -137,17 +136,23 @@ def _ParseOptions(): ...@@ -137,17 +136,23 @@ def _ParseOptions():
return options return options
def _VerifyExpectedConfigs(expected_path, actual_path, fail_on_exit): def _VerifyExpectedConfigs(expected_path, actual_path, failure_file_path):
msg = diff_utils.DiffFileContents(expected_path, actual_path) msg = diff_utils.DiffFileContents(expected_path, actual_path)
if not msg: if not msg:
return return
sys.stderr.write("""\ msg_header = """\
ProGuard flag expectations file needs updating. For details see: ProGuard flag expectations file needs updating. For details see:
https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/android/java/README.md https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/android/java/README.md
""") """
sys.stderr.write(msg_header)
sys.stderr.write(msg) sys.stderr.write(msg)
if fail_on_exit: if failure_file_path:
build_utils.MakeDirectory(os.path.dirname(failure_file_path))
with open(failure_file_path, 'w') as f:
f.write(msg_header)
f.write(msg)
#TODO(mheikal): remove once trybot reciepe handles the failure files.
sys.exit(1) sys.exit(1)
...@@ -394,7 +399,7 @@ def main(): ...@@ -394,7 +399,7 @@ def main():
if options.expected_configs_file: if options.expected_configs_file:
_VerifyExpectedConfigs(options.expected_configs_file, _VerifyExpectedConfigs(options.expected_configs_file,
options.output_config, options.output_config,
options.verify_expected_configs) options.proguard_expectations_failure_file)
if options.r8_path: if options.r8_path:
_OptimizeWithR8(options, options.proguard_configs, libraries, _OptimizeWithR8(options, options.proguard_configs, libraries,
......
...@@ -206,6 +206,9 @@ if (is_android || is_chromeos) { ...@@ -206,6 +206,9 @@ if (is_android || is_chromeos) {
# Checks that proguard flags have not changed (!is_java_debug only). # Checks that proguard flags have not changed (!is_java_debug only).
check_android_configuration = false check_android_configuration = false
# Where to write failed expectations if check_android_configuration is true.
android_configuration_failure_dir = "$root_build_dir/failed_expectations"
# Enable the chrome build for devices without touchscreens. # Enable the chrome build for devices without touchscreens.
notouch_build = false notouch_build = false
......
...@@ -1030,7 +1030,13 @@ if (enable_java_templates) { ...@@ -1030,7 +1030,13 @@ if (enable_java_templates) {
rebase_path(_expected_configs_file, root_build_dir), rebase_path(_expected_configs_file, root_build_dir),
] ]
if (check_android_configuration) { if (check_android_configuration) {
args += [ "--verify-expected-configs" ] _failed_proguard_expectation_file =
"$android_configuration_failure_dir/" +
"${invoker.failed_proguard_expectation_file}"
args += [
"--proguard-expectations-failure-file",
rebase_path(_failed_proguard_expectation_file, root_build_dir),
]
} }
} }
} }
...@@ -1172,6 +1178,7 @@ if (enable_java_templates) { ...@@ -1172,6 +1178,7 @@ if (enable_java_templates) {
"build_config", "build_config",
"disable_r8_outlining", "disable_r8_outlining",
"deps", "deps",
"failed_proguard_expectation_file",
"proguard_expectations_file", "proguard_expectations_file",
"proguard_jar_path", "proguard_jar_path",
"proguard_mapping_path", "proguard_mapping_path",
...@@ -2400,7 +2407,14 @@ if (enable_java_templates) { ...@@ -2400,7 +2407,14 @@ if (enable_java_templates) {
rebase_path(_normalized_output, root_build_dir), rebase_path(_normalized_output, root_build_dir),
] ]
if (check_android_configuration) { if (check_android_configuration) {
args += [ "--fail-if-unexpected-android-manifest" ] _manfiest_expectations_failure_filepath =
"$android_configuration_failure_dir/" +
"${invoker.failed_manifest_expectation_file}"
args += [
"--android-manifest-expectations-failure-file",
rebase_path(_manfiest_expectations_failure_filepath,
root_build_dir),
]
} }
} }
if (defined(invoker.manifest_package)) { if (defined(invoker.manifest_package)) {
......
...@@ -2424,6 +2424,7 @@ if (enable_java_templates) { ...@@ -2424,6 +2424,7 @@ if (enable_java_templates) {
[ [
"aapt_locale_whitelist", "aapt_locale_whitelist",
"app_as_shared_lib", "app_as_shared_lib",
"failed_manifest_expectation_file",
"manifest_package", "manifest_package",
"max_sdk_version", "max_sdk_version",
"no_xml_namespaces", "no_xml_namespaces",
...@@ -3467,6 +3468,8 @@ if (enable_java_templates) { ...@@ -3467,6 +3468,8 @@ if (enable_java_templates) {
"deps", "deps",
"enable_chromium_linker_tests", "enable_chromium_linker_tests",
"enable_multidex", "enable_multidex",
"failed_manifest_expectation_file",
"failed_proguard_expectation_file",
"generate_buildconfig_java", "generate_buildconfig_java",
"generate_final_jni", "generate_final_jni",
"input_jars_paths", "input_jars_paths",
...@@ -4560,6 +4563,7 @@ if (enable_java_templates) { ...@@ -4560,6 +4563,7 @@ if (enable_java_templates) {
proguard_mapping_path = _proguard_mapping_path proguard_mapping_path = _proguard_mapping_path
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"failed_proguard_expectation_file",
"proguard_jar_path", "proguard_jar_path",
"min_sdk_version", "min_sdk_version",
]) ])
......
...@@ -1730,6 +1730,8 @@ template("monochrome_public_apk_or_module_tmpl") { ...@@ -1730,6 +1730,8 @@ template("monochrome_public_apk_or_module_tmpl") {
"target_type", "target_type",
"use_trichrome_library", "use_trichrome_library",
"verify_manifest", "verify_manifest",
"failed_manifest_expectation_file",
"failed_proguard_expectation_file",
"version_code", "version_code",
"version_name", "version_name",
]) ])
...@@ -2329,6 +2331,8 @@ template("monochrome_or_trichrome_public_bundle_tmpl") { ...@@ -2329,6 +2331,8 @@ template("monochrome_or_trichrome_public_bundle_tmpl") {
if (defined(invoker.verify_android_configuration) && if (defined(invoker.verify_android_configuration) &&
invoker.verify_android_configuration) { invoker.verify_android_configuration) {
verify_manifest = true verify_manifest = true
failed_manifest_expectation_file =
"monochrome_public_bundle.android_manifest.failed"
} }
if (_is_trichrome && trichrome_synchronized_proguard) { if (_is_trichrome && trichrome_synchronized_proguard) {
...@@ -2355,6 +2359,8 @@ template("monochrome_or_trichrome_public_bundle_tmpl") { ...@@ -2355,6 +2359,8 @@ template("monochrome_or_trichrome_public_bundle_tmpl") {
if (defined(invoker.verify_android_configuration) && if (defined(invoker.verify_android_configuration) &&
invoker.verify_android_configuration) { invoker.verify_android_configuration) {
verify_proguard_flags = true verify_proguard_flags = true
failed_proguard_expectation_file =
"monochrome_public_bundle.proguard_flags.failed"
} }
} }
......
...@@ -53,6 +53,7 @@ template("chrome_bundle") { ...@@ -53,6 +53,7 @@ template("chrome_bundle") {
"base_module_target", "base_module_target",
"bundle_name", "bundle_name",
"compress_shared_libraries", "compress_shared_libraries",
"failed_proguard_expectation_file",
"keystore_name", "keystore_name",
"keystore_password", "keystore_password",
"keystore_path", "keystore_path",
......
...@@ -326,6 +326,8 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -326,6 +326,8 @@ template("monochrome_public_common_apk_or_module_tmpl") {
chrome_public_common_apk_or_module_tmpl(target_name) { chrome_public_common_apk_or_module_tmpl(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"failed_manifest_expectation_file",
"failed_proguard_expectation_file",
"version_code", "version_code",
"verify_manifest", "verify_manifest",
]) ])
......
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