blob: 38fd9ed40e16c8d497ea523a2773302fb80b2838 [file] [log] [blame]
load("@rules_android//toolchains/android:toolchain.bzl", "android_toolchain")
android_sdk(
name = "android_sdk",
aapt = "//prebuilts/sdk/tools:linux/bin/aapt",
aapt2 = "//prebuilts/sdk/tools:linux/bin/aapt2",
adb = ":fail", # TODO: use system/core/adb ?
aidl = "//prebuilts/sdk/tools:linux/bin/aidl",
android_jar = "30/public/android.jar",
apksigner = ":apksigner",
dx = "//prebuilts/sdk/tools:dx", # TODO: add D8
framework_aidl = "30/public/framework.aidl",
main_dex_classes = "//prebuilts/sdk/tools:mainDexClasses.rules",
main_dex_list_creator = ":fail",
proguard = ":fail", # TODO: add R8
shrinked_android_jar = "30/public/android.jar",
visibility = ["//visibility:public"],
zipalign = "//prebuilts/sdk/tools:linux/bin/zipalign",
)
java_import(
name = "dx_jar_import",
jars = ["//prebuilts/sdk/tools:lib/dx.jar"],
visibility = ["//visibility:public"],
)
java_binary(
name = "apksigner",
main_class = "com.android.apksigner.ApkSignerTool",
runtime_deps = ["//prebuilts/sdk/tools:linux/lib/apksigner.jar"],
)
toolchain(
name = "android_sdk_tools",
exec_compatible_with = [
"//build/bazel/platforms/arch:x86_64",
"//build/bazel/platforms/os:linux",
],
# TODO(b/175833893): This causes the toolchain to not be selected, so
# disable for now.
#target_compatible_with = [
# "//build/bazel/platforms/os:android",
#],
toolchain = ":android_sdk",
toolchain_type = "@rules_android//toolchains/android_sdk:toolchain_type",
visibility = ["//visibility:public"],
)
java_import(
name = "public_current_android_sdk_java_import",
jars = ["//prebuilts/sdk/current:public/android.jar"],
visibility = ["//visibility:public"],
neverlink = True,
)
android_toolchain(
name = "android_default",
aapt2 = "//prebuilts/sdk/tools:linux/bin/aapt2",
adb = ":fail",
android_archive_jar_optimization_inputs_validator = ":fail",
android_archive_manifest_package_validator = ":fail",
android_archive_packages_validator = ":fail",
android_kit = ":fail",
apk_to_bundle_tool = ":fail",
bundletool = ":fail",
data_binding_annotation_processor = ":compiler_annotation_processor",
jacocorunner = ":fail",
java_stub = ":fail",
jdeps_tool = ":fail",
proto_map_generator = ":fail",
testsupport = ":fail",
)
toolchain(
name = "android_default_toolchain",
toolchain = ":android_default",
toolchain_type = "@rules_android//toolchains/android:toolchain_type",
)
# The native version of android_binary specifies a different toolchain_type
# from the Starlark rules, so it needs a separate toolchain to point
# android_binary to the android_sdk.
toolchain(
name = "android_sdk_tools_for_native_android_binary",
exec_compatible_with = [
"//build/bazel/platforms/arch:x86_64",
"//build/bazel/platforms/os:linux",
],
# TODO(b/175833893): This causes the toolchain to not be selected, so
# disable for now.
#target_compatible_with = [
# "//build/bazel/platforms/os:android",
#],
toolchain = ":android_sdk",
toolchain_type = "@bazel_tools//tools/android:sdk_toolchain_type",
visibility = ["//visibility:public"],
)
# TODO: all_android_tools comes from Android remote tools which should be
# put into AOSP instead of downloaded.
java_plugin(
name = "compiler_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",
],
)
# Stubs for tools dependencies that are currently unused.
genrule(
name = "gen_fail",
outs = ["fail.sh"],
cmd = "echo 'exit 1' > $@",
executable = 1,
)
sh_binary(
name = "fail",
srcs = [":fail.sh"],
)