blob: 7fa51a1fe46739b3c38d905595f583d1eeefe8c2 [file] [log] [blame]
load("//tools/python:private/defs.bzl", "py_binary", "py_library")
load(":defs.bzl", "run_ijar", "run_singlejar")
package(default_visibility = ["//visibility:public"])
# The toolchain type used to distinguish Android SDK toolchains.
toolchain_type(name = "sdk_toolchain_type")
alias(
name = "sdk",
actual = "//external:android/sdk",
)
android_tools_defaults_jar(name = "android_jar")
android_library(
name = "incremental_stub_application",
exports = ["//src/tools/android/java/com/google/devtools/build/android/incrementaldeployment:incremental_stub_application"],
)
android_library(
name = "incremental_split_stub_application",
exports = ["//src/tools/android/java/com/google/devtools/build/android/incrementaldeployment:incremental_split_stub_application"],
)
alias(
name = "busybox",
actual = "//src/tools/android/java/com/google/devtools/build/android:ResourceProcessorBusyBox",
)
alias(
name = "merge_dexzips",
actual = "//src/tools/android/java/com/google/devtools/build/android/ziputils:reducer",
)
alias(
name = "shuffle_jars",
actual = "//src/tools/android/java/com/google/devtools/build/android/ziputils:mapper",
)
# Defines d8_dexbuilder using @<repo>//:d8_jar_import generated by android_sdk_repository rule
# without needing the SDK repo's name (typically @androidsdk but not required).
java_binary(
name = "d8_dexbuilder",
main_class = "com.google.devtools.build.android.r8.CompatDexBuilder",
visibility = ["//visibility:private"],
runtime_deps = ["//src/tools/android/java/com/google/devtools/build/android/r8"],
)
# NOTE: d8 dex builder doesn't support the persistent worker mode at the moment. To use this config,
# without a build error, --nouse_workers_with_dexbuilder flag must also be specified.
config_setting(
name = "d8_incremental_dexing",
values = {
"define": "android_incremental_dexing_tool=d8_dexbuilder",
},
)
config_setting(
name = "dx_incremental_dexing",
values = {
"define": "android_incremental_dexing_tool=dx_dexbuilder",
},
)
alias(
name = "dexbuilder",
actual = select({
"d8_incremental_dexing": ":d8_dexbuilder",
"dx_incremental_dexing": "//src/tools/android/java/com/google/devtools/build/android/dexer:DexBuilder",
"//conditions:default": ":d8_dexbuilder",
}),
)
# Matches dx_standalone_dexer in android_sdk_repository_template.bzl. Not using
# the one there to avoid a dependency on the android sdk.
config_setting(
name = "dx_standalone_dexer",
values = {"define": "android_standalone_dexing_tool=dx_compat_dx"},
)
alias(
name = "dexbuilder_after_proguard",
actual = select({
":dx_standalone_dexer": "//src/tools/android/java/com/google/devtools/build/android/dexer:DexBuilder",
"//conditions:default": ":d8_dexbuilder",
}),
)
# Defines d8_dexmerger using @<repo>//:d8_jar_import generated by android_sdk_repository rule
# without needing the SDK repo's name (typically @androidsdk but not required).
java_binary(
name = "d8_dexmerger",
main_class = "com.google.devtools.build.android.r8.DexFileMerger",
visibility = ["//visibility:private"],
runtime_deps = ["//src/tools/android/java/com/google/devtools/build/android/r8"],
)
config_setting(
name = "use_dx_dexmerger",
values = {
"define": "android_dexmerger_tool=dx_dexmerger",
},
)
config_setting(
name = "use_d8_dexmerger",
values = {
"define": "android_dexmerger_tool=d8_dexmerger",
},
)
alias(
name = "dexmerger",
actual = select({
"use_d8_dexmerger": ":d8_dexmerger",
"use_dx_dexmerger": "//src/tools/android/java/com/google/devtools/build/android/dexer:DexFileMerger",
"//conditions:default": ":d8_dexmerger",
}),
)
alias(
name = "dexsharder",
actual = "//src/tools/android/java/com/google/devtools/build/android/dexer:DexFileSplitter",
)
config_setting(
name = "d8_desugaring",
values = {
"define": "android_desugaring_tool=d8",
},
)
config_setting(
name = "legacy_desugaring",
values = {
"define": "android_desugaring_tool=legacy",
},
)
sh_binary(
name = "desugar_java8",
srcs = select({
"legacy_desugaring": ["desugar.sh"],
"d8_desugaring": ["d8_desugar.sh"],
"//conditions:default": ["d8_desugar.sh"],
}),
deps = ["@bazel_tools//tools/bash/runfiles"],
data = select({
"legacy_desugaring": ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
"d8_desugaring": ["@bazel_tools//src/tools/android/java/com/google/devtools/build/android/r8:desugar", "chm_only_desugar_jdk_libs.json"],
"//conditions:default": ["@bazel_tools//src/tools/android/java/com/google/devtools/build/android/r8:desugar", "chm_only_desugar_jdk_libs.json"],
})
)
alias(
name = "aar_import_deps_checker",
actual = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker_embedded",
visibility = ["//visibility:public"],
)
alias(
name = "zip_filter",
actual = "//src/tools/android/java/com/google/devtools/build/android:ZipFilterAction",
)
# Bazel puts this on the bootclasspath of android_* targets to support Java 8
# if requested.
filegroup(
name = "desugar_java8_extra_bootclasspath",
srcs = ["java_base_extras.jar"],
visibility = ["//visibility:public"],
)
# javac needs this Jar to compile lambdas, method references, and type annotations.
# These classes are not part of the android.jar.
run_singlejar(
name = "gen_java_base_extras_jar",
srcs = [
"@bazel_tools//tools/jdk:platformclasspath",
],
out = "java_base_extras.jar",
include_prefixes = [
"java/lang/invoke/",
"java/lang/annotation/",
],
visibility = ["//visibility:private"],
)
java_import(
name = "desugared_java8_legacy_apis",
jars = [":ijar_desugared_java8_legacy_libs"],
neverlink = 1,
visibility = ["//visibility:public"],
)
run_ijar(
name = "ijar_desugared_java8_legacy_libs",
jar = "desugared_java8_legacy_libs.jar",
visibility = ["//visibility:private"],
)
sh_binary(
name = "build_java8_legacy_dex",
srcs = ["build_java8_legacy_dex.sh"],
data = [
"minify_java8_legacy_libs.cfg",
":desugared_java8_legacy_libs",
":dexer",
"@bazel_tools//src/tools/android/java/com/google/devtools/build/android/desugar/scan:KeepScanner",
"@bazel_tools//tools/jdk:proguard",
],
visibility = ["//visibility:public"],
)
sh_binary(
name = "merge_proguard_maps",
srcs = ["fail.sh"],
visibility = ["//visibility:public"],
)
genrule(
name = "java8_legacy_dex",
outs = ["java8_legacy.dex.zip"],
cmd = """$(location :build_java8_legacy_dex) --output $@""",
tools = [":build_java8_legacy_dex"],
visibility = ["//visibility:public"],
)
filegroup(
name = "desugared_java8_legacy_libs",
srcs = ["desugared_java8_legacy_libs.jar"],
visibility = ["//visibility:private"],
)
genrule(
name = "desugar_java8_legacy_libs",
srcs = ["@android_tools//:desugar_jdk_libs.jar"],
outs = ["desugared_java8_legacy_libs.jar"],
message = "Desugaring java8 legacy libs",
cmd = """
$(location :desugar_java8) \
--input $< \
--output $@ \
--classpath_entry "$(location @bazel_tools//tools/jdk:platformclasspath)" \
--core_library --allow_empty_bootclasspath \
--nobest_effort_tolerate_missing_deps \
--noemit_dependency_metadata_as_needed \
--nodesugar_try_with_resources_if_needed \
--desugar_supported_core_libs \
--rewrite_core_library_prefix java/time/ \
--rewrite_core_library_prefix java/lang/Double8 \
--rewrite_core_library_prefix java/lang/Integer8 \
--rewrite_core_library_prefix java/lang/Long8 \
--rewrite_core_library_prefix java/lang/Math8 \
--rewrite_core_library_prefix java/io/Desugar \
--rewrite_core_library_prefix java/io/UncheckedIOException \
--rewrite_core_library_prefix java/util/stream/ \
--rewrite_core_library_prefix java/util/function/ \
--rewrite_core_library_prefix java/util/Desugar \
--rewrite_core_library_prefix java/util/DoubleSummaryStatistics \
--rewrite_core_library_prefix java/util/IntSummaryStatistics \
--rewrite_core_library_prefix java/util/LongSummaryStatistics \
--rewrite_core_library_prefix java/util/Objects \
--rewrite_core_library_prefix java/util/Optional \
--rewrite_core_library_prefix java/util/PrimitiveIterator \
--rewrite_core_library_prefix java/util/Spliterator \
--rewrite_core_library_prefix java/util/StringJoiner \
--rewrite_core_library_prefix javadesugar/testing/ \
--rewrite_core_library_prefix java/util/concurrent/ConcurrentHashMap \
--rewrite_core_library_prefix java/util/concurrent/ThreadLocalRandom \
--rewrite_core_library_prefix java/util/concurrent/atomic/DesugarAtomic \
--auto_desugar_shadowed_api_use \
--emulate_core_library_interface java/util/Collection \
--emulate_core_library_interface java/util/Map \
--emulate_core_library_interface java/util/Map\\$$Entry \
--emulate_core_library_interface java/util/Iterator \
--emulate_core_library_interface java/util/Comparator \
--dont_rewrite_core_library_invocation "java/util/Iterator#remove" """,
tools = [
":desugar_java8",
"@bazel_tools//tools/jdk:platformclasspath",
],
visibility = ["//visibility:private"],
)
# No-one should depend on this but :desugared_java8_legacy_libs above
exports_files(
["desugar_jdk_libs.jar"],
visibility = ["//visibility:private"],
)
# Mirrors @<repo>//:dx_binary generated by android_sdk_repository rule without
# needing the SDK repo's name (typically @androidsdk but not required).
java_binary(
name = "dexer",
main_class = "com.android.dx.command.Main",
visibility = ["//visibility:private"],
runtime_deps = ["//external:android/dx_jar_import"],
)
alias(
name = "IdlClass",
actual = "//src/tools/android/java/com/google/devtools/build/android/idlclass:IdlClass",
)
py_binary(
name = "instrumentation_test_check",
srcs = ["instrumentation_test_check.py"],
python_version = "PY3",
deps = ["//third_party/py/abseil"],
)
py_binary(
name = "build_incremental_dexmanifest",
srcs = [":build_incremental_dexmanifest.py"],
python_version = "PY3",
deps = [],
)
py_binary(
name = "build_split_manifest",
srcs = ["build_split_manifest.py"],
python_version = "PY3",
deps = [
"//third_party/py/abseil",
],
)
py_binary(
name = "incremental_install",
srcs = ["incremental_install.py"],
python_version = "PY3",
deps = [
"//third_party/py/abseil",
],
)
py_binary(
name = "strip_resources",
srcs = ["strip_resources.py"],
python_version = "PY3",
deps = [
"//third_party/py/abseil",
],
)
py_binary(
name = "aar_native_libs_zip_creator",
srcs = [
"aar_native_libs_zip_creator.py",
],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
],
)
py_binary(
name = "stubify_manifest",
srcs = ["stubify_manifest.py"],
python_version = "PY3",
deps = [
"//third_party/py/abseil",
],
)
py_binary(
name = "aar_embedded_proguard_extractor",
srcs = ["aar_embedded_proguard_extractor.py"],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
],
)
py_binary(
name = "aar_embedded_jars_extractor",
srcs = ["aar_embedded_jars_extractor.py"],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
],
)
py_binary(
name = "aar_resources_extractor",
srcs = ["aar_resources_extractor.py"],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
],
)
py_binary(
name = "resource_extractor",
srcs = ["resource_extractor.py"],
python_version = "PY3",
)
py_library(
name = "junction_lib",
srcs = ["junction.py"],
# TODO(bazel-team): remove srcs_version = "PY2AND3" while fixing https://github.com/bazelbuild/bazel/issues/10127.
srcs_version = "PY2AND3",
visibility = ["//visibility:private"],
)
alias(
name = "android_runtest",
actual = "fail.sh",
)
alias(
name = "adb_static",
actual = "fail.sh",
)
alias(
name = "adb",
actual = "@androidsdk//:adb",
)
# If needed, this file can be regenerated by (validity is 30 * 365 days):
# keytool -genkeypair \
# -alias androiddebugkey \
# -dname "CN=Android Debug, O=Android, C=US" \
# -keystore cica \
# -sigalg SHA256withDSA \
# -validity 10950
filegroup(
name = "debug_keystore",
srcs = ["bazel_debug.keystore"],
)
java_binary(
name = "databinding_exec",
main_class = "android.databinding.AndroidDataBinding",
runtime_deps = [
"//src/tools/android/java/com/google/devtools/build/android:all_android_tools",
],
)
alias(
name = "databinding_annotation_processor",
actual = "//external:databinding_annotation_processor",
)
# This is the default value of databinding_annotation_processor if the user does
# not provide one. Also used by the bind rules in android.WORKSPACE.
filegroup(name = "empty")
alias(
name = "instrumentation_test_entry_point",
actual = "@android_test_support//:instrumentation_test_runner",
)
# This is the default binding of //external:android/sdk. If someone attempts to
# build a rule that depends on //external:android/sdk without setting up
# android_sdk_repository in their WORKSPACE, the genrule will fail with a
# helpful error message.
android_sdk(
name = "poison_pill_android_sdk",
aapt = ":error_message",
adb = ":error_message",
aidl = ":error_message",
android_jar = ":error_message.jar",
apksigner = ":error_message",
dx = ":error_message",
framework_aidl = ":error_message",
main_dex_classes = ":error_message",
main_dex_list_creator = ":error_message",
proguard = ":error_message",
shrinked_android_jar = ":error_message.jar",
zipalign = ":error_message",
)
genrule(
name = "no_android_sdk_repository_error",
outs = [
"error_message",
"error_message.jar",
],
cmd = """echo \
This build requires an Android SDK. Please add the android_sdk_repository \
rule to your WORKSPACE. ; \
exit 1 """,
)
# //external:has_androidsdk is bound to either
# @bazel_tools//tools/android:always_true or
# @bazel_tools//tools/android:always_false depending on whether
# android_sdk_repository has run and is valid. This allows targets to depend on
# targets from @androidsdk if and only if the user has an
# android_sdk_repository set up.
config_feature_flag(
name = "true",
allowed_values = [
"true",
"false",
],
default_value = "true",
)
config_setting(
name = "always_true",
flag_values = {
":true": "true",
},
)
config_setting(
name = "always_false",
flag_values = {
":true": "false",
},
)
package_group(
name = "android_device_allowlist",
packages = ["public"],
)
package_group(
name = "export_deps_allowlist",
packages = ["public"],
)
package_group(
name = "allow_android_library_deps_without_srcs_allowlist",
packages = ["public"],
)
sh_binary(
name = "dex_list_obfuscator",
srcs = ["dex_list_obfuscator.sh"],
visibility = ["//visibility:public"],
)
filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]),
visibility = ["//tools:__pkg__"],
)