blob: 7e7d3f77b04999b17f2e0eb0fffa3eaa02167dd8 [file] [log] [blame]
load("@rules_python//python: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"],
)
alias(
name = "dexbuilder",
actual = ":d8_dexbuilder",
)
alias(
name = "dexbuilder_after_proguard",
actual = ":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"],
)
alias(
name = "dexmerger",
actual = ":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",
outs = ["desugared_java8_legacy_libs.jar"],
cmd = "echo > $@"
)
# 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",
":json_worker_wrapper",
],
)
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",
":json_worker_wrapper",
],
)
py_binary(
name = "aar_embedded_jars_extractor",
srcs = ["aar_embedded_jars_extractor.py"],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
":json_worker_wrapper",
],
)
py_binary(
name = "aar_resources_extractor",
srcs = ["aar_resources_extractor.py"],
python_version = "PY3",
deps = [
":junction_lib",
"//third_party/py/abseil",
":json_worker_wrapper",
],
)
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"],
)
py_library(
name = "json_worker_wrapper",
srcs = ["json_worker_wrapper.py"],
visibility = ["//visibility:private"],
srcs_version = "PY3",
)
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",
],
)
java_plugin(
name = "databinding_annotation_processor",
generates_api = True,
processor_class = "android.databinding.annotationprocessor.ProcessDataBinding",
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//src/tools/android/java/com/google/devtools/build/android:all_android_tools",
],
)
# 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__"],
)