Commit b95af8b7 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Don't fail builds for warnings when is_debug=true

Adds GN arg: java_warnings_as_errors = !is_java_debug

And sets the arg on our trybot that runs errorprone.

TBR=jbudorick  # Expedite fixing local dev flow.

Bug: 1029357
Change-Id: I817931328dc56ca67d7047d711fa60ba38e21fd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943014
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720074}
parent 8005c0d3
...@@ -477,6 +477,10 @@ def _ParseOptions(argv): ...@@ -477,6 +477,10 @@ def _ParseOptions(argv):
'--enable-errorprone', '--enable-errorprone',
action='store_true', action='store_true',
help='Enable errorprone checks') help='Enable errorprone checks')
parser.add_option(
'--warnings-as-errors',
action='store_true',
help='Treat all warnings as errors.')
parser.add_option('--jar-path', help='Jar output path.') parser.add_option('--jar-path', help='Jar output path.')
parser.add_option( parser.add_option(
'--javac-arg', '--javac-arg',
...@@ -550,6 +554,8 @@ def main(argv): ...@@ -550,6 +554,8 @@ def main(argv):
errorprone_flags.append('-Xep:{}:OFF'.format(warning)) errorprone_flags.append('-Xep:{}:OFF'.format(warning))
for warning in ERRORPRONE_WARNINGS_TO_ERROR: for warning in ERRORPRONE_WARNINGS_TO_ERROR:
errorprone_flags.append('-Xep:{}:ERROR'.format(warning)) errorprone_flags.append('-Xep:{}:ERROR'.format(warning))
if not options.warnings_as_errors:
errorprone_flags.append('-XepAllErrorsAsWarnings')
javac_cmd += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)] javac_cmd += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)]
if options.java_version: if options.java_version:
...@@ -561,7 +567,7 @@ def main(argv): ...@@ -561,7 +567,7 @@ def main(argv):
# Android's boot jar doesn't contain all java 8 classes. # Android's boot jar doesn't contain all java 8 classes.
options.bootclasspath.append(build_utils.RT_JAR_PATH) options.bootclasspath.append(build_utils.RT_JAR_PATH)
if options.chromium_code: if options.warnings_as_errors:
javac_cmd.extend(['-Werror']) javac_cmd.extend(['-Werror'])
else: else:
# XDignore.symbol.file makes javac compile against rt.jar instead of # XDignore.symbol.file makes javac compile against rt.jar instead of
......
...@@ -224,6 +224,9 @@ if (is_android || is_chromeos) { ...@@ -224,6 +224,9 @@ if (is_android || is_chromeos) {
# Use hashed symbol names to reduce JNI symbol overhead. # Use hashed symbol names to reduce JNI symbol overhead.
use_hashed_jni_names = !is_java_debug use_hashed_jni_names = !is_java_debug
# For local development, it's nice to not fail builds on warnings.
java_warnings_as_errors = !is_java_debug
} }
# Path to where selected build variables are written to. # Path to where selected build variables are written to.
......
...@@ -968,7 +968,6 @@ if (enable_java_templates) { ...@@ -968,7 +968,6 @@ if (enable_java_templates) {
rebase_path(invoker.build_config, root_build_dir) rebase_path(invoker.build_config, root_build_dir)
args += [ args += [
"--srcjars=@FileArg($_rebased_build_config:gradle:bundled_srcjars)", "--srcjars=@FileArg($_rebased_build_config:gradle:bundled_srcjars)",
"--can-fail-build",
] ]
if (invoker.requires_android) { if (invoker.requires_android) {
args += [ args += [
...@@ -976,6 +975,9 @@ if (enable_java_templates) { ...@@ -976,6 +975,9 @@ if (enable_java_templates) {
"--resource-sources=@FileArg($_rebased_build_config:deps_info:owned_resources_zips)", "--resource-sources=@FileArg($_rebased_build_config:deps_info:owned_resources_zips)",
] ]
} }
if (java_warnings_as_errors) {
args += [ "--can-fail-build" ]
}
} }
if (defined(invoker.manifest_package)) { if (defined(invoker.manifest_package)) {
...@@ -2820,6 +2822,9 @@ if (enable_java_templates) { ...@@ -2820,6 +2822,9 @@ if (enable_java_templates) {
} }
if (_chromium_code) { if (_chromium_code) {
args += [ "--chromium-code=1" ] args += [ "--chromium-code=1" ]
if (java_warnings_as_errors) {
args += [ "--warnings-as-errors" ]
}
} }
if (defined(invoker.jar_excluded_patterns)) { if (defined(invoker.jar_excluded_patterns)) {
args += [ "--jar-info-exclude-globs=${invoker.jar_excluded_patterns}" ] args += [ "--jar-info-exclude-globs=${invoker.jar_excluded_patterns}" ]
......
...@@ -1120,7 +1120,7 @@ ...@@ -1120,7 +1120,7 @@
], ],
'android_debug_trybot_compile_only': [ 'android_debug_trybot_compile_only': [
'android', 'debug_trybot', 'compile_only', 'android', 'debug_trybot', 'compile_only', 'java_warnings_as_errors',
], ],
'android_debug_trybot_compile_only_arm64_fastbuild': [ 'android_debug_trybot_compile_only_arm64_fastbuild': [
...@@ -2280,6 +2280,10 @@ ...@@ -2280,6 +2280,10 @@
'gn_args': 'skip_archive_compression=false', 'gn_args': 'skip_archive_compression=false',
}, },
'java_warnings_as_errors': {
'gn_args': ('java_warnings_as_errors=true'),
},
'enable_vulkan': { 'enable_vulkan': {
'gn_args': 'enable_vulkan=true', 'gn_args': 'enable_vulkan=true',
}, },
......
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