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

Android: Add host_jar_path vs device_jar_path to build logic

Fixes desugared .jar files incorrectly being used in java_binary() /
junit_binary().

Bug: 1078484
Change-Id: Ia49a10d3e907844ed75ee658604e8eeaa2993fb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241865
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778433}
parent 278601b1
......@@ -356,7 +356,6 @@ group("gn_all") {
"//tools/android:push_apps_to_background",
"//tools/android/audio_focus_grabber:audio_focus_grabber_apk",
"//tools/android/customtabs_benchmark:customtabs_benchmark_apk",
"//tools/android/errorprone_plugin:errorprone_plugin_java",
"//tools/android/kerberos/SpnegoAuthenticator:spnego_authenticator_apk",
"//ui/android:ui_junit_tests",
"//weblayer/public/java:client_aar",
......
......@@ -17,5 +17,4 @@ java_binary("bytecode_processor") {
]
wrapper_script_name = "helper/bytecode_processor"
enable_bytecode_checks = false
enable_desugar = false
}
......@@ -20,6 +20,12 @@ also have a default `jar_excluded_patterns` set (more on that later):
All target names must end with "_java" so that the build system can distinguish
them from non-java targets (or [other variations](https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?rcl=ec2c17d7b4e424e060c3c7972842af87343526a1&l=20)).
Most targets produce two separate `.jar` files:
* Device `.jar`: Used to produce `.dex.jar`, which is used on-device.
* Host `.jar`: For use on the host machine (`junit_binary` / `java_binary`).
* Host `.jar` files live in `lib.java/` so that they are archived in
builder/tester bots (which do not archive `obj/`).
## From Source to Final Dex
### Step 1: Create interface .jar with turbine or ijar
......@@ -72,15 +78,24 @@ This step can be disabled via GN arg: `use_errorprone_java_compiler = false`
[ErrorProne]: https://errorprone.info/
[ep_plugins]: /tools/android/errorprone_plugin/
### Step 3: Desugaring
### Step 3: Desugaring (Device .jar Only)
This step happens only when targets have `supports_android = true`.
This step happens only when targets have `supports_android = true`. It is not
applied to `.jar` files used by `junit_binary`.
* `//third_party/bazel/desugar` converts certain Java 8 constructs, such as
lambdas and default interface methods, into constructs that are compatible
with Java 7.
### Step 4: Filtering
### Step 4: Instrumenting (Device .jar Only)
This step happens only when this GN arg is set: `use_jacoco_coverage = true`
* [Jacoco] adds instrumentation hooks to methods.
[Jacoco]: https://www.eclemma.org/jacoco/
### Step 5: Filtering
This step happens only when targets that have `jar_excluded_patterns` or
`jar_included_patterns` set (e.g. all `android_` targets).
......@@ -97,27 +112,12 @@ This step happens only when targets that have `jar_excluded_patterns` or
[Android Resources]: life_of_a_resource.md
[apphooks]: /chrome/android/java/src/org/chromium/chrome/browser/AppHooksImpl.java
### Step 5: Instrumentation
This step happens only when this GN arg is set: `use_jacoco_coverage = true`
* [Jacoco] adds instrumentation hooks to methods.
[Jacoco]: https://www.eclemma.org/jacoco/
### Step 6: Copy to lib.java
* The `.jar` is copied into `$root_build_dir/lib.java` (under target-specific
subdirectories) so that it will be included by bot archive steps.
* These `.jar` files are the ones used when running `java_binary` and
`junit_binary` targets.
### Step 7: Per-Library Dexing
### Step 6: Per-Library Dexing
This step happens only when targets have `supports_android = true`.
* [d8] converts `.jar` files containing `.class` files into `.dex.jar` files
containing `.dex` files.
containing `classes.dex` files.
* Dexing is incremental - it will reuse dex'ed classes from a previous build if
the corresponding `.class` file is unchanged.
* These per-library `.dex.jar` files are used directly by [incremental install],
......@@ -128,7 +128,7 @@ This step happens only when targets have `supports_android = true`.
[d8]: https://developer.android.com/studio/command-line/d8
[incremental install]: /build/android/incremental_install/README.md
### Step 8: Apk / Bundle Module Compile
### Step 7: Apk / Bundle Module Compile
* Each `android_apk` and `android_bundle_module` template has a nested
`java_library` target. The nested library includes final copies of files
......@@ -139,7 +139,7 @@ This step happens only when targets have `supports_android = true`.
[JNI glue]: /base/android/jni_generator/README.md
### Step 9: Final Dexing
### Step 8: Final Dexing
This step is skipped when building using [Incremental Install].
......@@ -149,19 +149,11 @@ When `is_java_debug = true`:
When `is_java_debug = false`:
* [R8] performs whole-program optimization on all library `lib.java` `.jar`
files and outputs a final `.r8dex.jar`.
* For App Bundles, R8 creates a single `.r8dex.jar` with the code from all
modules.
* For App Bundles, R8 creates a `.r8dex.jar` for each module.
[Incremental Install]: /build/android/incremental_install/README.md
[R8]: https://r8.googlesource.com/r8
### Step 10: Bundle Module Dex Splitting
This step happens only when `is_java_debug = false`.
* [dexsplitter.py] splits the single `*dex.jar` into per-module `*dex.jar`
files.
## Test APKs with apk_under_test
Test APKs are normal APKs that contain an `<instrumentation>` tag within their
......
......@@ -14,7 +14,7 @@ import sys
import tempfile
import zipfile
from filter_zip import CreatePathTransform
import filter_zip
from util import build_utils
......@@ -117,8 +117,8 @@ def main(args):
build_utils.AddToZipHermetic(
z, 'AndroidManifest.xml', src_path=options.android_manifest)
path_transform = CreatePathTransform(options.jar_excluded_globs,
options.jar_included_globs, [])
path_transform = filter_zip.CreatePathTransform(
options.jar_excluded_globs, options.jar_included_globs, [])
with tempfile.NamedTemporaryFile() as jar_file:
build_utils.MergeZips(
jar_file.name, options.jars, path_transform=path_transform)
......
......@@ -5,6 +5,7 @@
# found in the LICENSE file.
import argparse
import shutil
import sys
from util import build_utils
......@@ -20,6 +21,21 @@ _RESOURCE_CLASSES = [
def CreatePathTransform(exclude_globs, include_globs,
strip_resource_classes_for):
"""Returns a function to strip paths for the given patterns.
Args:
exclude_globs: List of globs that if matched should be excluded.
include_globs: List of globs that if not matched should be excluded.
strip_resource_classes_for: List of Java packages for which to strip
R.java classes from.
Returns:
* None if no filters are needed.
* A function "(path) -> path" that returns None when |path| should be
stripped, or |path| otherwise.
"""
if not (exclude_globs or include_globs or strip_resource_classes_for):
return None
exclude_globs = list(exclude_globs or [])
if strip_resource_classes_for:
exclude_globs.extend(p.replace('.', '/') + '/' + f
......@@ -52,19 +68,18 @@ def main():
argv = build_utils.ExpandFileArgs(sys.argv[1:])
args = parser.parse_args(argv)
if args.exclude_globs:
args.exclude_globs = build_utils.ParseGnList(args.exclude_globs)
if args.include_globs:
args.include_globs= build_utils.ParseGnList(args.include_globs)
if args.strip_resource_classes_for:
args.include_globs = build_utils.ParseGnList(args.include_globs)
args.strip_resource_classes_for = build_utils.ParseGnList(
args.strip_resource_classes_for)
path_transform = CreatePathTransform(args.exclude_globs, args.include_globs,
args.strip_resource_classes_for)
with build_utils.AtomicOutput(args.output) as f:
build_utils.MergeZips(
f.name, [args.input], path_transform=path_transform)
if path_transform:
build_utils.MergeZips(f.name, [args.input], path_transform=path_transform)
else:
shutil.copy(args.input, f.name)
if __name__ == '__main__':
......
......@@ -242,18 +242,22 @@ through Proguard or other tools. For most targets this is generated
from sources, with a name like `$target_name.javac.jar`. However, when using
a prebuilt jar, this will point to the source archive directly.
* `deps_info['jar_path']`:
* `deps_info['device_jar_path']`:
Path to a file that is the result of processing
`deps_info['unprocessed_jar_path']` with various tools.
`deps_info['unprocessed_jar_path']` with various tools (ready to be dexed).
* `deps_info['host_jar_path']`:
Path to a file that is the result of processing
`deps_info['unprocessed_jar_path']` with various tools (use by java_binary).
* `deps_info['interface_jar_path']:
Path to the interface jar generated for this library. This corresponds to
a jar file that only contains declarations. Generated by running the `ijar` on
`deps_info['jar_path']` or the `turbine` tool on source files.
`deps_info['unprocessed_jar_path']` or the `turbine` tool on source files.
* `deps_info['dex_path']`:
Path to the `.dex` file generated for this target, from `deps_info['jar_path']`
unless this comes from a prebuilt `.aar` archive.
Path to the `.dex` file generated for this target, from
`deps_info['device_jar_path']` unless this comes from a prebuilt `.aar` archive.
* `deps_info['is_prebuilt']`:
True to indicate that this target corresponds to a prebuilt `.jar` file.
......@@ -323,10 +327,10 @@ all entries from the `java_library` type, and adds:
* `deps_info['main_class']`:
Name of the main Java class that serves as an entry point for the binary.
* `deps_info['java_runtime_classpath']`:
* `deps_info['device_classpath']`:
The classpath used when running a Java or Android binary. Essentially the
collection of all `deps_info['jar_path']` entries for the target and all its
dependencies.
collection of all `deps_info['device_jar_path']` entries for the target and all
its dependencies.
## <a name="target_junit_binary">Target type `junit_binary`</a>:
......@@ -885,7 +889,8 @@ def main(argv):
help='Consider the assets as locale paks in BuildConfig.java')
# java library options
parser.add_option('--jar-path', help='Path to target\'s jar output.')
parser.add_option('--device-jar-path', help='Path to .jar for dexing.')
parser.add_option('--host-jar-path', help='Path to .jar for java_binary.')
parser.add_option('--unprocessed-jar-path',
help='Path to the .jar to use for javac classpath purposes.')
parser.add_option(
......@@ -1048,11 +1053,13 @@ def main(argv):
if options.fail:
parser.error('\n'.join(build_utils.ParseGnList(options.fail)))
jar_path_options = ['jar_path', 'unprocessed_jar_path', 'interface_jar_path']
lib_options = ['unprocessed_jar_path', 'interface_jar_path']
device_lib_options = ['device_jar_path', 'dex_path']
required_options_map = {
'android_apk': ['build_config', 'dex_path'] + jar_path_options,
'android_app_bundle_module': ['build_config', 'dex_path',
'final_dex_path', 'res_size_info'] + jar_path_options,
'android_apk': ['build_config'] + lib_options + device_lib_options,
'android_app_bundle_module':
['build_config', 'final_dex_path', 'res_size_info'] + lib_options +
device_lib_options,
'android_assets': ['build_config'],
'android_resources': ['build_config', 'resources_zip'],
'dist_aar': ['build_config'],
......@@ -1060,9 +1067,9 @@ def main(argv):
'group': ['build_config'],
'java_annotation_processor': ['build_config', 'main_class'],
'java_binary': ['build_config'],
'java_library': ['build_config'] + jar_path_options,
'java_library': ['build_config', 'host_jar_path'] + lib_options,
'junit_binary': ['build_config'],
'system_java_library': ['build_config'],
'system_java_library': ['build_config', 'unprocessed_jar_path'],
'android_app_bundle': ['build_config', 'module_build_configs'],
}
required_options = required_options_map.get(options.type)
......@@ -1102,10 +1109,10 @@ def main(argv):
'--library-renames can only be used with --type=android_apk or '
'--type=android_app_bundle_module')
if options.jar_path and options.supports_android and not options.dex_path:
if options.device_jar_path and not options.dex_path:
raise Exception('java_library that supports Android requires a dex path.')
if any(getattr(options, x) for x in jar_path_options):
for attr in jar_path_options:
if any(getattr(options, x) for x in lib_options):
for attr in lib_options:
if not getattr(options, attr):
raise('Expected %s to be set.' % attr)
......@@ -1270,10 +1277,13 @@ def main(argv):
if is_java_target:
# Classpath values filled in below (after applying tested_apk_config).
config['javac'] = {}
if options.jar_path:
deps_info['jar_path'] = options.jar_path
if options.unprocessed_jar_path:
deps_info['unprocessed_jar_path'] = options.unprocessed_jar_path
deps_info['interface_jar_path'] = options.interface_jar_path
if options.device_jar_path:
deps_info['device_jar_path'] = options.device_jar_path
if options.host_jar_path:
deps_info['host_jar_path'] = options.host_jar_path
if options.enable_jetify:
deps_info['jetified_jar_path'] = options.jetified_jar_path
else:
......@@ -1469,15 +1479,24 @@ def main(argv):
if is_java_target or options.type == 'android_app_bundle':
# The classpath to use to run this target (or as an input to ProGuard).
java_full_classpath = []
if is_java_target and options.jar_path:
java_full_classpath.append(options.jar_path)
java_full_classpath.extend(c['jar_path'] for c in all_library_deps)
device_classpath = []
if is_java_target and options.device_jar_path:
device_classpath.append(options.device_jar_path)
device_classpath.extend(
c.get('device_jar_path') for c in all_library_deps
if c.get('device_jar_path'))
if options.type == 'android_app_bundle':
for d in deps.Direct('android_app_bundle_module'):
java_full_classpath.extend(
c for c in d.get('java_runtime_classpath', [])
if c not in java_full_classpath)
device_classpath.extend(c for c in d.get('device_classpath', [])
if c not in device_classpath)
if options.type in ('dist_jar', 'java_binary', 'junit_binary'):
# The classpath to use to run this target.
host_classpath = []
if options.host_jar_path:
host_classpath.append(options.host_jar_path)
host_classpath.extend(c['host_jar_path'] for c in all_library_deps)
deps_info['host_classpath'] = host_classpath
all_configs = build_utils.ParseGnList(options.proguard_configs)
deps_info['proguard_configs'] = list(all_configs)
......@@ -1573,7 +1592,7 @@ def main(argv):
if dep_config['type'] == 'android_app_bundle':
base_config = GetDepConfig(dep_config['base_module_config'])
extra_main_r_text_files.append(base_config['r_text_path'])
static_lib_jar_paths[config_path] = base_config['jar_path']
static_lib_jar_paths[config_path] = base_config['device_jar_path']
all_configs.extend(dep_config['proguard_all_configs'])
extra_proguard_classpath_jars.extend(
dep_config['proguard_classpath_jars'])
......@@ -1588,19 +1607,19 @@ def main(argv):
for package in base_config['extra_package_names']:
if package not in extra_package_names:
extra_package_names.append(package)
for cp_entry in dep_config['java_runtime_classpath']:
for cp_entry in dep_config['device_classpath']:
configs_by_classpath_entry[cp_entry].append(config_path)
for cp_entry in java_full_classpath:
for cp_entry in device_classpath:
configs_by_classpath_entry[cp_entry].append(options.build_config)
for cp_entry, candidate_configs in configs_by_classpath_entry.iteritems():
config_path = (candidate_configs[0]
if len(candidate_configs) == 1 else options.build_config)
classpath_entries_by_owning_config[config_path].append(cp_entry)
java_full_classpath.append(cp_entry)
device_classpath.append(cp_entry)
java_full_classpath = sorted(set(java_full_classpath))
device_classpath = sorted(set(device_classpath))
deps_info['static_library_proguard_mapping_output_paths'] = sorted([
d['proguard_mapping_path']
......@@ -1645,7 +1664,7 @@ def main(argv):
deps_proguard_enabled = []
deps_proguard_disabled = []
for d in deps.Direct('android_app_bundle_module'):
if not d['java_runtime_classpath']:
if not d['device_classpath']:
# We don't care about modules that have no Java code for proguarding.
continue
if d['proguard_enabled']:
......@@ -1695,10 +1714,10 @@ def main(argv):
# Add all tested classes to the test's classpath to ensure that the test's
# java code is a superset of the tested apk's java code
java_full_classpath_extended = list(java_full_classpath)
java_full_classpath_extended.extend(
p for p in tested_apk_config['java_runtime_classpath']
if p not in java_full_classpath)
device_classpath_extended = list(device_classpath)
device_classpath_extended.extend(
p for p in tested_apk_config['device_classpath']
if p not in device_classpath)
# Include in the classpath classes that are added directly to the apk under
# test (those that are not a part of a java_library).
javac_classpath.append(tested_apk_config['unprocessed_jar_path'])
......@@ -1721,9 +1740,9 @@ def main(argv):
tested_apk_library_deps = tested_apk_deps.All('java_library')
tested_apk_dex_files = {c['dex_path'] for c in tested_apk_library_deps}
all_dex_files = [p for p in all_dex_files if p not in tested_apk_dex_files]
tested_apk_jar_files = set(tested_apk_config['java_runtime_classpath'])
java_full_classpath = [
p for p in java_full_classpath if p not in tested_apk_jar_files
tested_apk_jar_files = set(tested_apk_config['device_classpath'])
device_classpath = [
p for p in device_classpath if p not in tested_apk_jar_files
]
if options.type in ('android_apk', 'dist_aar', 'dist_jar',
......@@ -1744,10 +1763,16 @@ def main(argv):
if is_java_target:
config['javac']['classpath'] = javac_classpath
config['javac']['interface_classpath'] = javac_interface_classpath
# Direct() will be of type 'java_annotation_processor'.
# Direct() will be of type 'java_annotation_processor', and so not included
# in All('java_library').
# Annotation processors run as part of the build, so need host_jar_path.
config['javac']['processor_classpath'] = [
c['jar_path'] for c in processor_deps.Direct() if c.get('jar_path')] + [
c['jar_path'] for c in processor_deps.All('java_library')]
c['host_jar_path'] for c in processor_deps.Direct()
if c.get('host_jar_path')
]
config['javac']['processor_classpath'] += [
c['host_jar_path'] for c in processor_deps.All('java_library')
]
config['javac']['processor_classes'] = [
c['main_class'] for c in processor_deps.Direct()]
deps_info['javac_full_classpath'] = javac_full_classpath
......@@ -1758,19 +1783,18 @@ def main(argv):
javac_full_classpath = set()
for d in deps.Direct('android_app_bundle_module'):
javac_full_classpath.update(p for p in d['javac_full_classpath'])
javac_full_classpath.add(d['jar_path'])
javac_full_classpath.add(d['unprocessed_jar_path'])
deps_info['javac_full_classpath'] = sorted(javac_full_classpath)
if options.type in ('android_apk', 'dist_jar', 'java_binary', 'junit_binary',
'android_app_bundle_module', 'android_app_bundle'):
deps_info['java_runtime_classpath'] = java_full_classpath
if options.type in ('android_apk', 'dist_jar', 'android_app_bundle_module',
'android_app_bundle'):
deps_info['device_classpath'] = device_classpath
if options.tested_apk_config:
deps_info['java_runtime_classpath_extended'] = (
java_full_classpath_extended)
deps_info['java_runtime_classpath_extended'] = (device_classpath_extended)
if options.type in ('android_apk', 'dist_jar'):
all_interface_jars = []
if options.jar_path:
if options.interface_jar_path:
all_interface_jars.append(options.interface_jar_path)
all_interface_jars.extend(c['interface_jar_path'] for c in all_library_deps)
......@@ -1862,7 +1886,7 @@ def main(argv):
# are not duplicated on the feature module.
if base_module_build_config:
base = base_module_build_config
RemoveObjDups(config, base, 'deps_info', 'java_runtime_classpath')
RemoveObjDups(config, base, 'deps_info', 'device_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath')
RemoveObjDups(config, base, 'deps_info', 'jetified_full_jar_classpath')
......
......@@ -28,6 +28,7 @@ template("copy_ex") {
[
"data",
"deps",
"public_deps",
"testonly",
"visibility",
])
......
......@@ -78,6 +78,7 @@ _java_target_patterns = _java_library_patterns + _java_resource_patterns
_r8_path = "//third_party/r8/lib/r8.jar"
_desugar_jdk_libs_json = "//third_party/r8/desugar_jdk_libs.json"
_desugar_jdk_libs_jar = "//third_party/android_deps/libs/com_android_tools_desugar_jdk_libs/desugar_jdk_libs-1.0.5.jar"
_desugar_runtime_jar = "$root_build_dir/obj/third_party/bazel/desugar/Desugar_runtime.processed.jar"
_dexdump_path = "$android_sdk_build_tools/dexdump"
_dexlayout_path = "//third_party/android_build_tools/art/dexlayout"
......@@ -219,10 +220,16 @@ template("write_build_config") {
args += [ "--non-chromium-code" ]
}
if (defined(invoker.jar_path)) {
if (defined(invoker.device_jar_path)) {
args += [
"--device-jar-path",
rebase_path(invoker.device_jar_path, root_build_dir),
]
}
if (defined(invoker.host_jar_path)) {
args += [
"--jar-path",
rebase_path(invoker.jar_path, root_build_dir),
"--host-jar-path",
rebase_path(invoker.host_jar_path, root_build_dir),
]
}
if (defined(invoker.unprocessed_jar_path)) {
......@@ -1098,7 +1105,7 @@ if (enable_java_templates) {
_args += [
"--feature-name=${_feature_module.name}",
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
"--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)",
"--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)",
]
_deps += [ _feature_module.build_config_target ]
}
......@@ -1263,7 +1270,9 @@ if (enable_java_templates) {
"--main-class",
_main_class,
]
args += [ "--classpath=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ]
args += [
"--classpath=@FileArg($_rebased_build_config:deps_info:host_classpath)",
]
if (use_jacoco_coverage) {
args += [
......@@ -1373,12 +1382,15 @@ if (enable_java_templates) {
if (defined(invoker.has_apk_under_test) && invoker.has_apk_under_test) {
args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath_extended)" ]
} else {
args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ]
args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
}
if (enable_bazel_desugar) {
deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
inputs += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
args += [ "--input-paths=lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
inputs += [ _desugar_runtime_jar ]
args += [
"--input-paths",
rebase_path(_desugar_runtime_jar, root_build_dir),
]
}
if (defined(invoker.proguard_args)) {
args += invoker.proguard_args
......@@ -1433,7 +1445,7 @@ if (enable_java_templates) {
# It would be more efficient to use the pre-dex'ed copy of the runtime,
# but it's easier to add it in this way.
_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
_input_class_jars += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
_input_class_jars += [ _desugar_runtime_jar ]
}
if (_input_class_jars != []) {
_rebased_input_class_jars =
......@@ -1704,43 +1716,19 @@ if (enable_java_templates) {
}
}
# TODO(digit): Document this!
#
# Variables:
# testonly:
# build_config:
# enable_jetify: A boolean to enable jetifying.
# input_jar_path:
# output_jar_path:
# supports_android:
# jacoco_instrument: Use Jacoco-instrumented classes to generate Java
# coverage data.
# jar_excluded_patterns: Optional list of .class file patterns to exclude
# from the final .jar file.
# jar_included_patterns: Optional list of .class file patterns to include
# in the final .jar file. jar_excluded_patterns take precedence over this.
# strip_resource_classes:
# deps:
# java_files:
# java_sources_file:
# inputs:
# data_deps:
# visibility:
#
template("process_java_prebuilt") {
set_sources_assignment_filter([])
forward_variables_from(invoker, [ "testonly" ])
assert(invoker.build_config != "")
_build_config = invoker.build_config
_rebased_build_config = rebase_path(_build_config, root_build_dir)
assert(_rebased_build_config != "" || true) # Mark used.
_input_jar_path = invoker.input_jar_path
_output_jar_path = invoker.output_jar_path
_jacoco_instrument = invoker.jacoco_instrument
_enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
template("filter_jar") {
action_with_pydeps(target_name) {
script = "//build/android/gyp/filter_zip.py"
forward_variables_from(invoker,
[
"deps",
"testonly",
])
inputs = [ invoker.input_jar ]
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}
outputs = [ invoker.output_jar ]
_jar_excluded_patterns = []
if (defined(invoker.jar_excluded_patterns)) {
......@@ -1752,11 +1740,33 @@ if (enable_java_templates) {
}
_strip_resource_classes = defined(invoker.strip_resource_classes) &&
invoker.strip_resource_classes
_filter_jar = _jar_excluded_patterns != [] ||
_jar_included_patterns != [] || _strip_resource_classes
args = [
"--input",
rebase_path(invoker.input_jar, root_build_dir),
"--output",
rebase_path(invoker.output_jar, root_build_dir),
"--exclude-globs=${_jar_excluded_patterns}",
"--include-globs=${_jar_included_patterns}",
]
if (_strip_resource_classes) {
inputs += [ invoker.build_config ]
_rebased_build_config =
rebase_path(invoker.build_config, root_build_dir)
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
}
}
_deps = []
_previous_output_jar = _input_jar_path
template("process_java_prebuilt") {
forward_variables_from(invoker, [ "testonly" ])
_rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
not_needed([ "_rebased_build_config" ])
not_needed(invoker, [ "build_config_dep" ])
_enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
_deps = invoker.jar_deps
_previous_output_jar = invoker.input_jar_path
if (_enable_jetify) {
_jetify_target = "${target_name}__jetify"
......@@ -1766,9 +1776,6 @@ if (enable_java_templates) {
action_with_pydeps(_jetify_target) {
script = "//build/android/gyp/jetify_jar.py"
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
_jetify_jar_path =
"//third_party/jetifier_standalone/bin/jetifier-standalone"
_jetify_config_path =
......@@ -1796,23 +1803,45 @@ if (enable_java_templates) {
_previous_output_jar = _jetify_output_jar
}
# Create the .jar in lib.java for use by java_binary.
if (defined(invoker.host_jar_path)) {
filter_jar("${target_name}_host") {
forward_variables_from(invoker,
[
"jar_excluded_patterns",
"jar_included_patterns",
"strip_resource_classes",
])
deps = _deps
input_jar = _previous_output_jar
output_jar = invoker.host_jar_path
inputs = []
if (defined(strip_resource_classes) && strip_resource_classes) {
inputs += [ invoker.build_config ]
deps += [ invoker.build_config_dep ]
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
if (defined(invoker.inputs)) {
inputs += invoker.inputs
deps += invoker.input_deps
}
}
}
if (defined(invoker.device_jar_path)) {
if (invoker.enable_desugar) {
_desugar_target = "${target_name}__desugar"
_desugar_input_jar = _previous_output_jar
_desugar_target = "${target_name}_device__desugar"
_desugar_output_jar = "$target_out_dir/$target_name.desugar.jar"
action_with_pydeps(_desugar_target) {
script = "//build/android/gyp/desugar.py"
deps = _deps
deps = _deps + invoker.classpath_deps
depfile = "$target_gen_dir/$target_name.d"
if (defined(invoker.deps)) {
deps += invoker.deps
}
_desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
inputs = [
_build_config,
_desugar_input_jar,
invoker.build_config,
_previous_output_jar,
_desugar_jar,
]
outputs = [ _desugar_output_jar ]
......@@ -1820,7 +1849,7 @@ if (enable_java_templates) {
"--desugar-jar",
rebase_path(_desugar_jar, root_build_dir),
"--input-jar",
rebase_path(_desugar_input_jar, root_build_dir),
rebase_path(_previous_output_jar, root_build_dir),
"--output-jar",
rebase_path(_desugar_output_jar, root_build_dir),
......@@ -1838,59 +1867,20 @@ if (enable_java_templates) {
_previous_output_jar = _desugar_output_jar
}
if (_filter_jar) {
_filter_target = "${target_name}__filter"
_filter_input_jar = _previous_output_jar
_filter_output_jar = "$target_out_dir/$target_name.filtered.jar"
action_with_pydeps(_filter_target) {
script = "//build/android/gyp/filter_zip.py"
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
inputs = [
_build_config,
_filter_input_jar,
]
outputs = [ _filter_output_jar ]
args = [
"--input",
rebase_path(_filter_input_jar, root_build_dir),
"--output",
rebase_path(_filter_output_jar, root_build_dir),
"--exclude-globs=$_jar_excluded_patterns",
"--include-globs=$_jar_included_patterns",
]
if (_strip_resource_classes) {
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
}
_deps = []
_deps = [ ":$_filter_target" ]
_previous_output_jar = _filter_output_jar
}
if (_jacoco_instrument) {
if (invoker.jacoco_instrument) {
# Jacoco must run after desugar (or else desugar sometimes fails).
_jacoco_target = "${target_name}__jacoco"
_jacoco_input_jar = _previous_output_jar
_jacoco_target = "${target_name}_device__jacoco"
_jacoco_output_jar = "$target_out_dir/$target_name.instrumented.jar"
jacoco_instr(_jacoco_target) {
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
deps = _deps + invoker.jar_deps
forward_variables_from(invoker,
[
"java_files",
"java_sources_file",
])
input_jar_path = _jacoco_input_jar
input_jar_path = _previous_output_jar
output_jar_path = _jacoco_output_jar
}
......@@ -1899,29 +1889,27 @@ if (enable_java_templates) {
_previous_output_jar = _jacoco_output_jar
}
_output_jar_target = "${target_name}__copy"
# This is copy_ex rather than copy to ensure that JARs (rather than
# possibly broken symlinks to them) get copied into the output
# directory.
copy_ex(_output_jar_target) {
forward_variables_from(invoker, [ "inputs" ])
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
dest = _output_jar_path
sources = [ _previous_output_jar ]
outputs = [ _output_jar_path ]
}
group(target_name) {
filter_jar("${target_name}_device") {
forward_variables_from(invoker,
[
"data_deps",
"visibility",
"jar_excluded_patterns",
"jar_included_patterns",
"strip_resource_classes",
])
public_deps = [ ":$_output_jar_target" ]
deps = _deps
input_jar = _previous_output_jar
output_jar = invoker.device_jar_path
inputs = []
if (defined(strip_resource_classes) && strip_resource_classes) {
inputs += [ invoker.build_config ]
deps += [ invoker.build_config_dep ]
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
if (!defined(invoker.host_jar_path) && defined(invoker.inputs)) {
inputs += invoker.inputs
deps += invoker.input_deps
}
}
}
}
......@@ -3088,16 +3076,14 @@ if (enable_java_templates) {
if (invoker.enable_errorprone) {
# Our custom plugin pulls in the main errorprone dep transitively.
_errorprone_dep =
"//tools/android/errorprone_plugin:errorprone_plugin_java"
_errorprone_dep = "//tools/android/errorprone_plugin:errorprone_plugin"
deps += [ _errorprone_dep ]
_dep_gen_dir = get_label_info(_errorprone_dep, "target_gen_dir")
_dep_name = get_label_info(_errorprone_dep, "name")
_rebased_errorprone_buildconfig =
rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir)
args += [
"--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:jar_path)",
"--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:javac_full_classpath)",
"--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:host_classpath)",
"--enable-errorprone",
]
}
......@@ -3220,12 +3206,8 @@ if (enable_java_templates) {
# java_files is empty. If not
# jar_path: Optional path to a prebuilt .jar file for this target.
# Mutually exclusive with java_files and srcjar_deps.
# final_jar_path: Optional path to the final output .jar file (after
# processing). If not provided, the output will go under
# $root_build_dir/lib.java/
# output_name: Optional output name for the final jar path. Ignored if
# final_jar_path is provided. Otherwise, used to determine the name
# of the final jar. If not provided, the default is to use the same
# output_name: Optional output name for the final jar path. Used to
# determine the name of the final jar. Default is to use the same
# name as jar_path, if provided, or main_target_name.
# main_class: Main Java class name for 'java_binary', 'junit_binary' and
# 'java_annotation_processor' target types. Should not be set for other
......@@ -3318,7 +3300,6 @@ if (enable_java_templates) {
_is_annotation_processor = invoker.type == "java_annotation_processor"
_is_java_binary =
invoker.type == "java_binary" || invoker.type == "junit_binary"
_is_system_library = invoker.type == "system_java_library"
_supports_android =
defined(invoker.supports_android) && invoker.supports_android
_requires_android =
......@@ -3379,6 +3360,8 @@ if (enable_java_templates) {
"${_main_target_name}$build_config_target_suffix"
# The only target that might have no prebuilt and no sources is a java_binary.
_build_host_jar = false
_build_device_jar = false
if (_is_prebuilt || _has_sources) {
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
......@@ -3388,13 +3371,25 @@ if (enable_java_templates) {
_output_name = _main_target_name
}
_build_host_jar = _is_java_binary || _is_annotation_processor ||
invoker.type == "java_library"
_build_device_jar =
invoker.type != "system_java_library" && _supports_android
if (_build_host_jar) {
# Jar files can be needed at runtime (by Robolectric tests or java binaries),
# so do not put them under obj/.
# TODO(agrieve): I suspect it would be better to use dist_jar for java_binary
# rather than archiving unnecessary .jar files within lib.java.
_target_dir_name = get_label_info(":$_main_target_name", "dir")
_final_jar_path =
_host_processed_jar_path =
"$root_out_dir/lib.java$_target_dir_name/$_output_name.jar"
if (defined(invoker.final_jar_path)) {
_final_jar_path = invoker.final_jar_path
}
if (_build_device_jar) {
_device_processed_jar_path =
"$target_out_dir/$_output_name.processed.jar"
_dex_path = "$target_out_dir/$_main_target_name.dex.jar"
_enable_desugar =
!defined(invoker.enable_desugar) || !invoker.enable_desugar
}
# For static libraries, the javac jar output is created at the intermediate
......@@ -3402,13 +3397,10 @@ if (enable_java_templates) {
# spot that the .build_config knows about. Technically this should be done
# for the ijar as well, but this is only used for APK targets where
# the ijar path isn't actually used.
_build_config_jar_path = _final_jar_path
_final_ijar_path = get_path_info(_final_jar_path, "dir") + "/" +
get_path_info(_final_jar_path, "name")
if (_has_sources) {
_final_ijar_path += ".turbine.jar"
_final_ijar_path = "$target_out_dir/$_output_name.turbine.jar"
} else {
_final_ijar_path += ".ijar.jar"
_final_ijar_path = "$target_out_dir/$_output_name.ijar.jar"
}
if (_has_sources) {
......@@ -3422,12 +3414,9 @@ if (enable_java_templates) {
} else {
_unprocessed_jar_path = _javac_jar_path
}
if (_supports_android) {
_dex_path = "$target_out_dir/$_main_target_name.dex.jar"
}
}
if (_is_prebuilt || _has_sources) {
_java_header_deps = []
_java_impl_deps = []
_non_java_deps = []
......@@ -3435,7 +3424,8 @@ if (enable_java_templates) {
foreach(_dep, invoker.deps) {
_target_label = get_label_info(_dep, "label_no_toolchain")
if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
filter_exclude([ _target_label ], _java_resource_patterns) != []) {
filter_exclude([ _target_label ], _java_resource_patterns) !=
[]) {
# This is a java dep, so replace it with its header.
_java_header_deps += [ "${_target_label}__header" ]
_java_impl_deps += [ "${_target_label}__impl" ]
......@@ -3445,19 +3435,16 @@ if (enable_java_templates) {
}
}
_extra_java_deps = []
# TODO(crbug.com/1078484): Don't use desugared .jar files for java binaries.
if (_is_java_binary && enable_bazel_desugar &&
(!defined(invoker.enable_desugar) || invoker.enable_desugar)) {
_extra_java_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
# Don't need to depend on the apk-under-test to be packaged.
if (defined(invoker.apk_under_test)) {
_java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
_java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
}
if (_is_prebuilt || _has_sources) {
_extra_java_deps = []
_jacoco_instrument =
use_jacoco_coverage && _chromium_code && _java_files != [] &&
!_is_java_binary && !_is_annotation_processor &&
(!defined(invoker.testonly) || !invoker.testonly)
_build_device_jar && (!defined(invoker.testonly) || !invoker.testonly)
if (defined(invoker.jacoco_never_instrument)) {
_jacoco_instrument =
!invoker.jacoco_never_instrument && _jacoco_instrument
......@@ -3465,15 +3452,8 @@ if (enable_java_templates) {
if (_jacoco_instrument) {
_extra_java_deps += [ "//third_party/jacoco:jacocoagent_java" ]
}
}
# Don't need to depend on the apk-under-test to be packaged.
if (defined(invoker.apk_under_test)) {
_java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
_java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
}
_include_android_sdk = !_is_system_library && _supports_android
_include_android_sdk = _build_device_jar
if (defined(invoker.include_android_sdk)) {
_include_android_sdk = invoker.include_android_sdk
}
......@@ -3489,8 +3469,10 @@ if (enable_java_templates) {
_classpath_deps = _java_header_deps + _non_java_deps + _extra_java_deps +
[ ":$_build_config_target_name" ]
_full_classpath_deps = _java_impl_deps + _non_java_deps + _extra_java_deps +
_full_classpath_deps =
_java_impl_deps + _non_java_deps + _extra_java_deps +
[ ":$_build_config_target_name" ]
}
# Often needed, but too hard to figure out when ahead of time.
not_needed([
......@@ -3506,9 +3488,6 @@ if (enable_java_templates) {
write_file(_java_sources_file, rebase_path(_java_files, root_build_dir))
}
_jetified_jar_path =
"$target_out_dir/${target_name}__process_prebuilt.jetified.jar"
write_build_config(_build_config_target_name) {
forward_variables_from(invoker,
[
......@@ -3564,10 +3543,14 @@ if (enable_java_templates) {
}
chromium_code = _chromium_code
build_config = _build_config
enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
is_prebuilt = _is_prebuilt
jetified_jar_path = _jetified_jar_path
enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
jetified_jar_path = "$target_out_dir/${invoker.target_name}__process_prebuilt.jetified.jar"
possible_config_deps = []
if (defined(_extra_java_deps)) {
possible_config_deps = _extra_java_deps
}
if (defined(invoker.deps)) {
possible_config_deps += invoker.deps
}
......@@ -3580,11 +3563,14 @@ if (enable_java_templates) {
invoker.bypass_platform_checks
if (_is_prebuilt || _has_sources) {
jar_path = _build_config_jar_path
ijar_path = _final_ijar_path
unprocessed_jar_path = _unprocessed_jar_path
}
if (defined(_dex_path)) {
if (_build_host_jar) {
host_jar_path = _host_processed_jar_path
}
if (_build_device_jar) {
device_jar_path = _device_processed_jar_path
dex_path = _dex_path
}
if (_java_files != []) {
......@@ -3599,12 +3585,12 @@ if (enable_java_templates) {
}
if (defined(invoker.include_java_resources) &&
invoker.include_java_resources) {
java_resources_jar = _unprocessed_jar_path
if (defined(invoker.jar_path)) {
# Use original jar_path because _jar_path points to a library without
# resources.
java_resources_jar = invoker.jar_path
} else {
java_resources_jar = _final_jar_path
java_resources_jar = _device_processed_jar_path
}
}
}
......@@ -3613,6 +3599,7 @@ if (enable_java_templates) {
_header_target_name = "${target_name}__header"
}
_public_deps = []
_analysis_public_deps = []
if (_has_sources) {
if (defined(invoker.enable_errorprone)) {
......@@ -3674,6 +3661,7 @@ if (enable_java_templates) {
generated_jar_path = _generated_jar_path
deps = _annotation_processor_deps
}
_public_deps += [ ":$_header_target_name" ]
_compile_java_target = "${_main_target_name}__compile_java"
compile_java_helper(_compile_java_target) {
......@@ -3701,8 +3689,6 @@ if (enable_java_templates) {
}
} # _has_sources
_public_deps = []
if (_is_prebuilt || _has_sources) {
if (_is_prebuilt) {
generate_interface_jar(_header_target_name) {
# Always used the unfiltered .jar to create the interface jar so that
......@@ -3721,27 +3707,11 @@ if (enable_java_templates) {
deps += [ ":$_compile_java_target" ]
}
}
}
_public_deps += [ ":$_header_target_name" ]
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"
# Use copy_ex rather than copy to ensure that we copy symlink targets
# rather than the symlink itself.
copy_ex(_copy_system_library_target_name) {
sources = [ _unprocessed_jar_path ]
dest = _final_jar_path
outputs = [ _final_jar_path ]
}
_public_deps += [ ":$_copy_system_library_target_name" ]
} else {
_enable_desugar = (!defined(invoker.enable_desugar) ||
!invoker.enable_desugar) && _supports_android
_process_prebuilt_target_name = "${target_name}__process_prebuilt"
if (_build_host_jar || _build_device_jar) {
_process_prebuilt_target_name = "${target_name}_process"
process_java_prebuilt(_process_prebuilt_target_name) {
forward_variables_from(invoker,
[
......@@ -3749,18 +3719,27 @@ if (enable_java_templates) {
"jar_excluded_patterns",
"jar_included_patterns",
])
enable_desugar = _enable_desugar && enable_bazel_desugar
build_config = _build_config
build_config_dep = ":$_build_config_target_name"
input_jar_path = _unprocessed_jar_path
jar_deps = _non_java_deps
if (_has_sources) {
jar_deps += [ ":$_compile_java_target" ]
}
if (_build_host_jar) {
host_jar_path = _host_processed_jar_path
}
if (_build_device_jar) {
device_jar_path = _device_processed_jar_path
jacoco_instrument = _jacoco_instrument
if (_jacoco_instrument) {
java_files = _java_files
java_sources_file = _java_sources_file
}
output_jar_path = _final_jar_path
deps = _full_classpath_deps
if (_has_sources) {
deps += [ ":$_compile_java_target" ]
enable_desugar = _enable_desugar && enable_bazel_desugar
if (enable_desugar) {
classpath_deps = _full_classpath_deps
}
}
# proguard_configs listed on java_library targets need to be marked
......@@ -3770,38 +3749,17 @@ if (enable_java_templates) {
# https://crbug.com/827197
if (defined(invoker.proguard_configs)) {
inputs = invoker.proguard_configs
if (!defined(deps)) {
deps = []
input_deps = _non_java_deps + _srcjar_deps # For the aapt-generated
# proguard rules.
}
deps += _srcjar_deps # For the aapt-generated proguard rules.
}
if (_build_host_jar) {
_public_deps += [ ":${_process_prebuilt_target_name}_host" ]
}
_public_deps += [ ":$_process_prebuilt_target_name" ]
if (defined(_dex_path)) {
dex("${target_name}__dex") {
input_class_jars = [ _final_jar_path ]
enable_desugar = _enable_desugar
# There's no value in per-class dexing prebuilts since they never
# change just one class at a time.
disable_incremental = _is_prebuilt
output = _dex_path
deps = [ ":$_process_prebuilt_target_name" ]
if (enable_desugar && !enable_bazel_desugar) {
# Desugaring with D8 requires full classpath.
build_config = _build_config
final_ijar_path = _final_ijar_path
deps += _classpath_deps + [ ":$_header_target_name" ]
if (_build_device_jar) {
_public_deps += [ ":${_process_prebuilt_target_name}_device" ]
}
enable_multidex = false
is_library = true
}
_public_deps += [ ":${target_name}__dex" ]
}
if (!defined(invoker.enable_bytecode_checks) ||
invoker.enable_bytecode_checks) {
_bytecode_checks_target = "${target_name}__validate_classpath"
......@@ -3821,6 +3779,29 @@ if (enable_java_templates) {
_analysis_public_deps += [ ":$_bytecode_checks_target" ]
}
}
if (_build_device_jar) {
dex("${target_name}__dex") {
input_class_jars = [ _device_processed_jar_path ]
enable_desugar = _enable_desugar
# There's no value in per-class dexing prebuilts since they never
# change just one class at a time.
disable_incremental = _is_prebuilt
output = _dex_path
deps = [ ":${_process_prebuilt_target_name}_device" ]
if (enable_desugar && !enable_bazel_desugar) {
# Desugaring with D8 requires full classpath.
build_config = _build_config
final_ijar_path = _final_ijar_path
deps += _classpath_deps + [ ":$_header_target_name" ]
}
enable_multidex = false
is_library = true
}
_public_deps += [ ":${target_name}__dex" ]
}
if (_is_java_binary) {
......@@ -4098,7 +4079,7 @@ template("dexsplitter") {
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
]
if (!defined(invoker.feature_jars_args)) {
args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)" ]
args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)" ]
}
deps += [ _feature_module.build_config_target ]
}
......
......@@ -1624,7 +1624,7 @@ 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 = []
......@@ -2139,8 +2139,7 @@ if (enable_java_templates) {
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"
......@@ -2153,9 +2152,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 =
......@@ -2352,8 +2348,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) {
......@@ -2800,7 +2795,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
}
......@@ -2932,7 +2926,8 @@ if (enable_java_templates) {
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:java_runtime_classpath)"
input_classes_filearg =
"@FileArg($_rebased_build_config:deps_info:device_classpath)"
}
if (_is_static_library_provider) {
......
......@@ -4,7 +4,11 @@
import("//build/config/android/rules.gni")
java_library("errorprone_plugin_java") {
java_binary("errorprone_plugin") {
# main_class and wrapper script are not actually used.
# This target is referenced directly from java_library_impl().
main_class = "<ignore>"
wrapper_script_name = "bin/helper/errorprone_plugin"
sources = [
# Turned off because of existing code which fails the check
# "src/org/chromium/tools/errorprone/plugin/NoContextGetApplicationContext.java",
......@@ -21,9 +25,6 @@ java_library("errorprone_plugin_java") {
enable_errorprone = false
enable_bytecode_checks = false
# So that we don't need to inject jacoco runtime into the compiler's classpath.
jacoco_never_instrument = true
annotation_processor_deps =
[ "//third_party/android_deps:auto_service_processor" ]
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