Commit 23876e96 authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

Android: making system library deps apply transitively

Bug: 898251
Change-Id: Iaaffb966d4cd3da6563bcc321b7db201b124292c
Reviewed-on: https://chromium-review.googlesource.com/c/1312341
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605691}
parent 3548c6ee
...@@ -706,7 +706,9 @@ def _DepsFromPaths(dep_paths, target_type, filter_root_targets=True): ...@@ -706,7 +706,9 @@ def _DepsFromPaths(dep_paths, target_type, filter_root_targets=True):
include the .apk as a resource/asset, not to have the apk's classpath added. include the .apk as a resource/asset, not to have the apk's classpath added.
""" """
configs = [GetDepConfig(p) for p in dep_paths] configs = [GetDepConfig(p) for p in dep_paths]
groups = DepsOfType('group', configs)
configs = _ResolveGroups(configs) configs = _ResolveGroups(configs)
configs += groups
# Don't allow root targets to be considered as a dep. # Don't allow root targets to be considered as a dep.
if filter_root_targets: if filter_root_targets:
configs = [c for c in configs if c['type'] not in _ROOT_TYPES] configs = [c for c in configs if c['type'] not in _ROOT_TYPES]
...@@ -714,6 +716,7 @@ def _DepsFromPaths(dep_paths, target_type, filter_root_targets=True): ...@@ -714,6 +716,7 @@ def _DepsFromPaths(dep_paths, target_type, filter_root_targets=True):
# Don't allow java libraries to cross through assets/resources. # Don't allow java libraries to cross through assets/resources.
if target_type in _RESOURCE_TYPES: if target_type in _RESOURCE_TYPES:
configs = [c for c in configs if c['type'] in _RESOURCE_TYPES] configs = [c for c in configs if c['type'] in _RESOURCE_TYPES]
return Deps([c['path'] for c in configs]) return Deps([c['path'] for c in configs])
...@@ -971,6 +974,7 @@ def main(argv): ...@@ -971,6 +974,7 @@ def main(argv):
system_library_deps = deps.Direct('system_java_library') system_library_deps = deps.Direct('system_java_library')
direct_library_deps = deps.Direct('java_library') direct_library_deps = deps.Direct('java_library')
group_deps = deps.All('group')
all_library_deps = deps.All('java_library') all_library_deps = deps.All('java_library')
all_resources_deps = deps.All('android_resources') all_resources_deps = deps.All('android_resources')
...@@ -1168,6 +1172,12 @@ def main(argv): ...@@ -1168,6 +1172,12 @@ def main(argv):
if is_apk_or_module_target: if is_apk_or_module_target:
deps_dex_files = [c['dex_path'] for c in all_library_deps] deps_dex_files = [c['dex_path'] for c in all_library_deps]
if options.type == 'group':
if options.extra_classpath_jars:
# These are .jars to add to javac classpath but not to runtime classpath.
extra_jars = build_utils.ParseGnList(options.extra_classpath_jars)
deps_info['extra_classpath_jars'] = extra_jars
if is_java_target: if is_java_target:
# The classpath used to compile this target when annotation processors are # The classpath used to compile this target when annotation processors are
# present. # present.
...@@ -1185,6 +1195,12 @@ def main(argv): ...@@ -1185,6 +1195,12 @@ def main(argv):
javac_full_classpath = [ javac_full_classpath = [
c['unprocessed_jar_path'] for c in all_library_deps] c['unprocessed_jar_path'] for c in all_library_deps]
for dep in group_deps:
javac_classpath.extend(dep.get('extra_classpath_jars', []))
javac_full_classpath.extend(dep.get('extra_classpath_jars', []))
javac_interface_classpath.extend(dep.get('extra_classpath_jars', []))
javac_full_interface_classpath.extend(dep.get('extra_classpath_jars', []))
# Deps to add to the compile-time classpath (but not the runtime classpath). # Deps to add to the compile-time classpath (but not the runtime classpath).
# TODO(agrieve): Might be less confusing to fold these into bootclasspath. # TODO(agrieve): Might be less confusing to fold these into bootclasspath.
javac_extra_jars = [c['unprocessed_jar_path'] javac_extra_jars = [c['unprocessed_jar_path']
...@@ -1242,6 +1258,9 @@ def main(argv): ...@@ -1242,6 +1258,9 @@ def main(argv):
p for p in c.get('proguard_configs', []) if p not in all_configs) p for p in c.get('proguard_configs', []) if p not in all_configs)
extra_jars.extend( extra_jars.extend(
p for p in c.get('extra_classpath_jars', []) if p not in extra_jars) p for p in c.get('extra_classpath_jars', []) if p not in extra_jars)
for c in group_deps:
extra_jars.extend(
p for p in c.get('extra_classpath_jars', []) if p not in extra_jars)
if options.type == 'android_app_bundle': if options.type == 'android_app_bundle':
for c in deps.Direct('android_app_bundle_module'): for c in deps.Direct('android_app_bundle_module'):
all_configs.extend( all_configs.extend(
...@@ -1347,7 +1366,6 @@ def main(argv): ...@@ -1347,7 +1366,6 @@ def main(argv):
dex_config['path'] = options.final_dex_path dex_config['path'] = options.final_dex_path
if is_java_target: if is_java_target:
config['javac']['bootclasspath'] = system_jars
config['javac']['classpath'] = javac_classpath config['javac']['classpath'] = javac_classpath
config['javac']['interface_classpath'] = javac_interface_classpath config['javac']['interface_classpath'] = javac_interface_classpath
# Direct() will be of type 'java_annotation_processor'. # Direct() will be of type 'java_annotation_processor'.
......
...@@ -1019,7 +1019,11 @@ if (enable_java_templates) { ...@@ -1019,7 +1019,11 @@ if (enable_java_templates) {
# } # }
# } # }
template("java_group") { template("java_group") {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker,
[
"testonly",
"input_jars_paths",
])
write_build_config("${target_name}__build_config") { write_build_config("${target_name}__build_config") {
type = "group" type = "group"
build_config = "$target_gen_dir/${invoker.target_name}.build_config" build_config = "$target_gen_dir/${invoker.target_name}.build_config"
......
...@@ -39,14 +39,14 @@ if (enable_java_templates) { ...@@ -39,14 +39,14 @@ if (enable_java_templates) {
# and are linked by default on O and below. Starting in P, they # and are linked by default on O and below. Starting in P, they
# exist in their own libraries that are present on device and are # exist in their own libraries that are present on device and are
# available to be linked against but aren't linked by default. # available to be linked against but aren't linked by default.
android_system_java_prebuilt("android_test_base_java") { java_group("android_test_base_java") {
jar_path = "${android_sdk}/optional/android.test.base.jar" input_jars_paths = [ "${android_sdk}/optional/android.test.base.jar" ]
} }
android_system_java_prebuilt("android_test_mock_java") { java_group("android_test_mock_java") {
jar_path = "${android_sdk}/optional/android.test.mock.jar" input_jars_paths = [ "${android_sdk}/optional/android.test.mock.jar" ]
} }
android_system_java_prebuilt("android_test_runner_java") { java_group("android_test_runner_java") {
jar_path = "${android_sdk}/optional/android.test.runner.jar" input_jars_paths = [ "${android_sdk}/optional/android.test.runner.jar" ]
} }
android_library("android_support_chromium_java") { android_library("android_support_chromium_java") {
......
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