1# Copyright 2019 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Android toolchain.""" 16 17_ATTRS = dict( 18 aapt2 = attr.label( 19 allow_files = True, 20 default = "@androidsdk//:aapt2_binary", 21 ), 22 aar_import_checks = attr.label( 23 allow_single_file = True, 24 cfg = "exec", 25 default = "//src/validations/aar_import_checks", 26 executable = True, 27 ), 28 aar_embedded_jars_extractor = attr.label( 29 allow_files = True, 30 cfg = "exec", 31 default = "@bazel_tools//tools/android:aar_embedded_jars_extractor", 32 executable = True, 33 ), 34 aar_embedded_proguard_extractor = attr.label( 35 allow_files = True, 36 cfg = "exec", 37 default = "@bazel_tools//tools/android:aar_embedded_proguard_extractor", 38 executable = True, 39 ), 40 aar_native_libs_zip_creator = attr.label( 41 allow_files = True, 42 cfg = "exec", 43 default = "@bazel_tools//tools/android:aar_native_libs_zip_creator", 44 executable = True, 45 ), 46 aar_resources_extractor = attr.label( 47 allow_files = True, 48 cfg = "exec", 49 default = "@bazel_tools//tools/android:aar_resources_extractor", 50 executable = True, 51 ), 52 adb = attr.label( 53 allow_files = True, 54 cfg = "exec", 55 default = "@androidsdk//:platform-tools/adb", 56 executable = True, 57 ), 58 add_g3itr_xslt = attr.label( 59 cfg = "exec", 60 default = Label("//tools/android/xslt:add_g3itr.xslt"), 61 allow_files = True, 62 ), 63 android_archive_jar_optimization_inputs_validator = attr.label( 64 allow_files = True, 65 default = "@androidsdk//:fail", 66 cfg = "exec", 67 executable = True, 68 ), 69 android_archive_manifest_package_validator = attr.label( 70 allow_files = True, 71 default = "@androidsdk//:fail", 72 cfg = "exec", 73 executable = True, 74 ), 75 android_archive_packages_validator = attr.label( 76 allow_files = True, 77 default = "@androidsdk//:fail", 78 cfg = "exec", 79 executable = True, 80 ), 81 android_kit = attr.label( 82 allow_files = True, 83 cfg = "exec", 84 default = "@androidsdk//:fail", # TODO: "//src/tools/ak", needs Go 85 executable = True, 86 ), 87 android_resources_busybox = attr.label( 88 allow_files = True, 89 cfg = "exec", 90 default = "@bazel_tools//src/tools/android/java/com/google/devtools/build/android:ResourceProcessorBusyBox_deploy.jar", 91 executable = True, 92 ), 93 apk_to_bundle_tool = attr.label( 94 allow_files = True, 95 cfg = "exec", 96 default = "@androidsdk//:fail", 97 executable = True, 98 ), 99 bundletool = attr.label( 100 allow_files = True, 101 cfg = "exec", 102 default = "//tools/android:bundletool_deploy.jar", 103 executable = True, 104 ), 105 data_binding_annotation_processor = attr.label( 106 cfg = "exec", 107 default = "@//tools/android:compiler_annotation_processor", # TODO: processor rules should be moved into rules_android 108 ), 109 data_binding_annotation_template = attr.label( 110 default = "//rules:data_binding_annotation_template.txt", 111 allow_files = True, 112 ), 113 data_binding_exec = attr.label( 114 cfg = "exec", 115 default = "@bazel_tools//tools/android:databinding_exec", 116 executable = True, 117 ), 118 desugar_java8_extra_bootclasspath = attr.label( 119 allow_files = True, 120 cfg = "exec", 121 default = "@bazel_tools//tools/android:desugar_java8_extra_bootclasspath", 122 executable = True, 123 ), 124 idlclass = attr.label( 125 allow_files = True, 126 cfg = "exec", 127 default = "@bazel_tools//tools/android:IdlClass", # _deploy.jar? 128 executable = True, 129 ), 130 import_deps_checker = attr.label( 131 allow_files = True, 132 cfg = "exec", 133 default = "@android_tools//:ImportDepsChecker_deploy.jar", 134 executable = True, 135 ), 136 jacocorunner = attr.label( 137 default = "@androidsdk//:fail", 138 ), 139 java_stub = attr.label( 140 allow_files = True, 141 # used in android_local_test 142 default = "@androidsdk//:fail", # TODO: java_stub_template.txt gets embedded in bazel's jar, need a copy in @bazel_tools or similar 143 ), 144 jdeps_tool = attr.label( 145 allow_files = True, 146 cfg = "exec", 147 # used in android_local_test 148 default = "@androidsdk//:fail", # TODO: "//src/tools/jdeps", needs Go 149 executable = True, 150 ), 151 proguard_allowlister = attr.label( 152 cfg = "exec", 153 default = "@bazel_tools//tools/jdk:proguard_whitelister", 154 executable = True, 155 ), 156 proto_map_generator = attr.label( 157 cfg = "exec", 158 default = "@androidsdk//:fail", 159 allow_files = True, 160 executable = True, 161 ), 162 res_v3_dummy_manifest = attr.label( 163 allow_files = True, 164 default = "//rules:res_v3_dummy_AndroidManifest.xml", 165 ), 166 res_v3_dummy_r_txt = attr.label( 167 allow_files = True, 168 default = "//rules:res_v3_dummy_R.txt", 169 ), 170 robolectric_template = attr.label( 171 allow_files = True, 172 default = "//rules:robolectric_properties_template.txt", 173 ), 174 testsupport = attr.label( 175 default = "@androidsdk//:fail", 176 ), 177 unzip_tool = attr.label( 178 cfg = "exec", 179 default = "//toolchains/android:unzip", 180 executable = True, 181 ), 182 xsltproc_tool = attr.label( 183 cfg = "exec", 184 default = Label("//tools/android/xslt:xslt"), 185 allow_files = True, 186 executable = True, 187 ), 188 zip_tool = attr.label( 189 cfg = "exec", 190 default = "//toolchains/android:zip", 191 executable = True, 192 ), 193) 194 195def _impl(ctx): 196 return [platform_common.ToolchainInfo( 197 **{name: getattr(ctx.attr, name) for name in _ATTRS.keys()} 198 )] 199 200android_toolchain = rule( 201 implementation = _impl, 202 attrs = _ATTRS, 203) 204