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