Commit d16b2b04 authored by Peter Wen's avatar Peter Wen Committed by Commit Bot

Android: Add __impl targets for java libraries

These __impl targets contain everything except the analysis steps (e.g.
errorprone, lint) so that other targets can depend on __impl rather than
the analysis steps finishing. The full target will depend on other full
targets to ensure that all analysis steps are run.

Improves base java signature change by 6.3s (171.9s -> 165.6s)

Bug: 906803
Change-Id: Ife1463b85be453a5f33aba97eaf3af7224e458ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132629
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755489}
parent 931140f1
...@@ -2912,7 +2912,7 @@ if (enable_java_templates) { ...@@ -2912,7 +2912,7 @@ if (enable_java_templates) {
_target_label = get_label_info(_dep, "label_no_toolchain") _target_label = get_label_info(_dep, "label_no_toolchain")
if (filter_exclude([ _target_label ], _java_lib_patterns) == [] && if (filter_exclude([ _target_label ], _java_lib_patterns) == [] &&
filter_exclude([ _target_label ], _java_lib_exceptions) != []) { filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
# This is a java dep, so replace it with its header. # This is a java dep, so replace it.
deps += [ "${_target_label}__header" ] deps += [ "${_target_label}__header" ]
} else { } else {
deps += [ _dep ] deps += [ _dep ]
...@@ -2922,6 +2922,25 @@ if (enable_java_templates) { ...@@ -2922,6 +2922,25 @@ if (enable_java_templates) {
} }
} }
template("java_impl_group") {
forward_variables_from(invoker, [ "testonly" ])
group(target_name) {
if (defined(invoker.deps)) {
deps = []
foreach(_dep, invoker.deps) {
_target_label = get_label_info(_dep, "label_no_toolchain")
if (filter_exclude([ _target_label ], _java_lib_patterns) == [] &&
filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
# This is a java dep, so replace it.
deps += [ "${_target_label}__impl" ]
} else {
deps += [ _dep ]
}
}
}
}
}
# Create an interface jar from a normal jar. # Create an interface jar from a normal jar.
# #
# Variables # Variables
...@@ -3193,6 +3212,7 @@ if (enable_java_templates) { ...@@ -3193,6 +3212,7 @@ if (enable_java_templates) {
_public_deps = [] _public_deps = []
_accumulated_deps = [] _accumulated_deps = []
_java_header_deps = [] _java_header_deps = []
_java_impl_deps = []
_java_full_deps = [] _java_full_deps = []
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
foreach(_dep, invoker.deps) { foreach(_dep, invoker.deps) {
...@@ -3201,6 +3221,7 @@ if (enable_java_templates) { ...@@ -3201,6 +3221,7 @@ if (enable_java_templates) {
filter_exclude([ _target_label ], _java_lib_exceptions) != []) { filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
# This is a java dep, so replace it with its header. # This is a java dep, so replace it with its header.
_java_header_deps += [ "${_target_label}__header" ] _java_header_deps += [ "${_target_label}__header" ]
_java_impl_deps += [ "${_target_label}__impl" ]
_java_full_deps += [ _dep ] _java_full_deps += [ _dep ]
} else { } else {
# Not a java header dep, so no need to replace it with its header. # Not a java header dep, so no need to replace it with its header.
...@@ -3220,6 +3241,8 @@ if (enable_java_templates) { ...@@ -3220,6 +3241,8 @@ if (enable_java_templates) {
[ "//build/android/buildhooks:build_hooks_android_java" ] [ "//build/android/buildhooks:build_hooks_android_java" ]
_java_header_deps += _java_header_deps +=
[ "//build/android/buildhooks:build_hooks_android_java__header" ] [ "//build/android/buildhooks:build_hooks_android_java__header" ]
_java_impl_deps +=
[ "//build/android/buildhooks:build_hooks_android_java__impl" ]
} }
if (_supports_android && if (_supports_android &&
...@@ -3228,6 +3251,8 @@ if (enable_java_templates) { ...@@ -3228,6 +3251,8 @@ if (enable_java_templates) {
_java_full_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ] _java_full_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
_java_header_deps += _java_header_deps +=
[ "//third_party/bazel/desugar:desugar_runtime_java__header" ] [ "//third_party/bazel/desugar:desugar_runtime_java__header" ]
_java_impl_deps +=
[ "//third_party/bazel/desugar:desugar_runtime_java__impl" ]
} }
# Don't enable coverage or lint unless the target has some non-generated # Don't enable coverage or lint unless the target has some non-generated
...@@ -3256,8 +3281,9 @@ if (enable_java_templates) { ...@@ -3256,8 +3281,9 @@ if (enable_java_templates) {
!invoker.jacoco_never_instrument && _jacoco_instrument !invoker.jacoco_never_instrument && _jacoco_instrument
} }
if (_jacoco_instrument) { if (_jacoco_instrument) {
_java_header_deps += [ "//third_party/jacoco:jacocoagent_java__header" ]
_java_full_deps += [ "//third_party/jacoco:jacocoagent_java" ] _java_full_deps += [ "//third_party/jacoco:jacocoagent_java" ]
_java_header_deps += [ "//third_party/jacoco:jacocoagent_java__header" ]
_java_impl_deps += [ "//third_party/jacoco:jacocoagent_java__impl" ]
} }
} }
...@@ -3386,8 +3412,10 @@ if (enable_java_templates) { ...@@ -3386,8 +3412,10 @@ if (enable_java_templates) {
# Don't need to depend on the apk-under-test to be packaged. # Don't need to depend on the apk-under-test to be packaged.
if (defined(invoker.apk_under_test)) { if (defined(invoker.apk_under_test)) {
_java_full_deps += [ "${invoker.apk_under_test}__java" ] # No need to add to _java_full_deps since that is only used for
# write_build_config.
_java_header_deps += [ "${invoker.apk_under_test}__java__header" ] _java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
_java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
} }
if (defined(invoker.android_manifest_dep)) { if (defined(invoker.android_manifest_dep)) {
_accumulated_deps += [ invoker.android_manifest_dep ] _accumulated_deps += [ invoker.android_manifest_dep ]
...@@ -3542,6 +3570,9 @@ if (enable_java_templates) { ...@@ -3542,6 +3570,9 @@ if (enable_java_templates) {
if (defined(_final_jar_path)) { if (defined(_final_jar_path)) {
if (_is_system_library) { if (_is_system_library) {
# These deps are only needed for the process_java_prebuilt template.
not_needed([ "_java_impl_deps" ])
_copy_system_library_target_name = "${target_name}__copy_system_library" _copy_system_library_target_name = "${target_name}__copy_system_library"
# Use copy_ex rather than copy to ensure that we copy symlink targets # Use copy_ex rather than copy to ensure that we copy symlink targets
...@@ -3576,7 +3607,7 @@ if (enable_java_templates) { ...@@ -3576,7 +3607,7 @@ if (enable_java_templates) {
java_sources_file = _java_sources_file java_sources_file = _java_sources_file
} }
output_jar_path = _final_jar_path output_jar_path = _final_jar_path
deps = _java_full_deps + _accumulated_deps + deps = _java_impl_deps + _accumulated_deps +
[ ":$_build_config_target_name" ] [ ":$_build_config_target_name" ]
if (_has_sources) { if (_has_sources) {
deps += [ ":$_compile_java_target" ] deps += [ ":$_compile_java_target" ]
...@@ -3644,16 +3675,24 @@ if (enable_java_templates) { ...@@ -3644,16 +3675,24 @@ if (enable_java_templates) {
_public_deps += [ ":${target_name}__java_binary_script" ] _public_deps += [ ":${target_name}__java_binary_script" ]
} }
# The __impl target contains all non-analysis steps for this template.
# Having this separated out from the main target (which contains analysis
# steps) allows analysis steps for this target to be run concurrently with
# the non-analysis steps of other targets that depend on this one.
group("${target_name}__impl") {
public_deps = _public_deps
}
group(target_name) { group(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"assert_no_deps", "assert_no_deps",
"data", "data",
"deps",
"data_deps", "data_deps",
"deps",
"visibility", "visibility",
]) ])
public_deps = _public_deps public_deps = [ ":${target_name}__impl" ]
if (defined(_analysis_public_deps)) { if (defined(_analysis_public_deps)) {
if (!defined(data_deps)) { if (!defined(data_deps)) {
data_deps = [] data_deps = []
......
...@@ -1133,6 +1133,9 @@ if (enable_java_templates) { ...@@ -1133,6 +1133,9 @@ if (enable_java_templates) {
java_header_group("${target_name}__header") { java_header_group("${target_name}__header") {
forward_variables_from(invoker, [ "deps" ]) forward_variables_from(invoker, [ "deps" ])
} }
java_impl_group("${target_name}__impl") {
forward_variables_from(invoker, [ "deps" ])
}
group(target_name) { group(target_name) {
forward_variables_from(invoker, "*") forward_variables_from(invoker, "*")
if (!defined(deps)) { if (!defined(deps)) {
......
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