blob: 3669a9a4e14890b482c379322e6f68d4fff13195 [file] [log] [blame]
Alex Humesky9f4c9e72021-03-18 01:32:40 -04001load("@rules_android//toolchains/android:toolchain.bzl", "android_toolchain")
2
Alex Humesky9f4c9e72021-03-18 01:32:40 -04003android_sdk(
4 name = "android_sdk",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -04005 aapt = "//prebuilts/sdk/tools:linux/bin/aapt",
6 aapt2 = "//prebuilts/sdk/tools:linux/bin/aapt2",
Alex Humesky9f4c9e72021-03-18 01:32:40 -04007 adb = ":fail", # TODO: use system/core/adb ?
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -04008 aidl = "//prebuilts/sdk/tools:linux/bin/aidl",
Alex Humesky9f4c9e72021-03-18 01:32:40 -04009 android_jar = "30/public/android.jar",
10 apksigner = ":apksigner",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040011 dx = "//prebuilts/sdk/tools:linux/bin/dx", # TODO: add D8
Alex Humesky9f4c9e72021-03-18 01:32:40 -040012 framework_aidl = "30/public/framework.aidl",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040013 main_dex_classes = "//prebuilts/sdk/tools:mainDexClasses.rules",
Alex Humesky9f4c9e72021-03-18 01:32:40 -040014 main_dex_list_creator = ":fail",
15 proguard = ":fail", # TODO: add R8
16 shrinked_android_jar = "30/public/android.jar",
17 visibility = ["//visibility:public"],
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040018 zipalign = "//prebuilts/sdk/tools:linux/bin/zipalign",
Alex Humesky9f4c9e72021-03-18 01:32:40 -040019)
20
21java_import(
22 name = "dx_jar_import",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040023 jars = ["//prebuilts/sdk/tools:linux/lib/dx.jar"],
Alex Humesky9f4c9e72021-03-18 01:32:40 -040024 visibility = ["//visibility:public"],
25)
26
27java_binary(
28 name = "apksigner",
29 main_class = "com.android.apksigner.ApkSignerTool",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040030 runtime_deps = ["//prebuilts/sdk/tools:linux/lib/apksigner.jar"],
Alex Humesky9f4c9e72021-03-18 01:32:40 -040031)
32
33toolchain(
34 name = "android_sdk_tools",
35 exec_compatible_with = [
36 "@bazel_tools//platforms:x86_64",
37 "@bazel_tools//platforms:linux",
38 ],
39 # TODO(b/175833893): This causes the toolchain to not be selected, so
40 # disable for now.
41 #target_compatible_with = [
42 # "@bazel_tools//platforms:android",
43 #],
44 toolchain = "@//prebuilts/sdk:android_sdk",
45 toolchain_type = "@rules_android//toolchains/android_sdk:toolchain_type",
46 visibility = ["//visibility:public"],
47)
48
49android_toolchain(
50 name = "android_default",
Rupert Shuttleworth72eb91b2021-04-15 19:41:20 -040051 aapt2 = "//prebuilts/sdk/tools:linux/bin/aapt2",
Alex Humesky9f4c9e72021-03-18 01:32:40 -040052 adb = ":fail",
53 android_kit = ":fail",
54 apk_to_bundle_tool = ":fail",
55 bundletool = ":fail",
56 data_binding_annotation_processor = ":compiler_annotation_processor",
57 jacocorunner = ":fail",
58 java_stub = ":fail",
59 jdeps_tool = ":fail",
60 testsupport = ":fail",
61)
62
63toolchain(
64 name = "android_default_toolchain",
65 toolchain = ":android_default",
66 toolchain_type = "@rules_android//toolchains/android:toolchain_type",
67)
68
69# The native version of android_binary specifies a different toolchain_type
70# from the Starlark rules, so it needs a separate toolchain to point
71# android_binary to the android_sdk.
72toolchain(
73 name = "android_sdk_tools_for_native_android_binary",
74 exec_compatible_with = [
75 "@bazel_tools//platforms:x86_64",
76 "@bazel_tools//platforms:linux",
77 ],
78 target_compatible_with = [
79 "@bazel_tools//platforms:android",
80 ],
81 toolchain = ":android_sdk",
82 toolchain_type = "@bazel_tools//tools/android:sdk_toolchain_type",
83 visibility = ["//visibility:public"],
84)
85
86# TODO: all_android_tools comes from Android remote tools which should be
87# put into AOSP instead of downloaded.
88java_plugin(
89 name = "compiler_annotation_processor",
90 generates_api = True,
91 processor_class = "android.databinding.annotationprocessor.ProcessDataBinding",
92 visibility = ["//visibility:public"],
93 deps = [
94 "@bazel_tools//src/tools/android/java/com/google/devtools/build/android:all_android_tools",
95 ],
96)
97
98# Stubs for tools dependencies that are currently unused.
99genrule(
100 name = "gen_fail",
101 outs = ["fail.sh"],
102 cmd = "echo 'exit 1' > $@",
103 executable = 1,
104)
105
106sh_binary(
107 name = "fail",
108 srcs = [":fail.sh"],
109)