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