• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_embedded_jars_extractor = attr.label(
23        allow_files = True,
24        cfg = "host",
25        default = "@bazel_tools//tools/android:aar_embedded_jars_extractor",
26        executable = True,
27    ),
28    aar_native_libs_zip_creator = attr.label(
29        allow_files = True,
30        cfg = "host",
31        default = "@bazel_tools//tools/android:aar_native_libs_zip_creator",
32        executable = True,
33    ),
34    aar_resources_extractor = attr.label(
35        allow_files = True,
36        cfg = "host",
37        default = "@bazel_tools//tools/android:aar_resources_extractor",
38        executable = True,
39    ),
40    adb = attr.label(
41        allow_files = True,
42        cfg = "host",
43        default = "@androidsdk//:platform-tools/adb",
44        executable = True,
45    ),
46    add_g3itr_xslt = attr.label(
47        cfg = "host",
48        default = Label("//tools/android/xslt:add_g3itr.xslt"),
49        allow_files = True,
50    ),
51    android_kit = attr.label(
52        allow_files = True,
53        cfg = "host",
54        default = "@androidsdk//:fail",  # TODO: "//src/tools/ak", needs Go
55        executable = True,
56    ),
57    android_resources_busybox = attr.label(
58        allow_files = True,
59        cfg = "host",
60        default = "@bazel_tools//src/tools/android/java/com/google/devtools/build/android:ResourceProcessorBusyBox_deploy.jar",
61        executable = True,
62    ),
63    apk_to_bundle_tool = attr.label(
64        allow_files = True,
65        cfg = "host",
66        default = "@androidsdk//:fail",
67        executable = True,
68    ),
69    bundletool = attr.label(
70        allow_files = True,
71        cfg = "host",
72        default = "@androidsdk//:fail",
73        executable = True,
74    ),
75    data_binding_annotation_processor = attr.label(
76        cfg = "host",
77        default = "@//tools/android:compiler_annotation_processor",  # TODO: processor rules should be moved into rules_android
78    ),
79    data_binding_annotation_template = attr.label(
80        default = "//rules:data_binding_annotation_template.txt",
81        allow_files = True,
82    ),
83    data_binding_exec = attr.label(
84        cfg = "host",
85        default = "@bazel_tools//tools/android:databinding_exec",
86        executable = True,
87    ),
88    desugar_java8_extra_bootclasspath = attr.label(
89        allow_files = True,
90        cfg = "host",
91        default = "@bazel_tools//tools/android:desugar_java8_extra_bootclasspath",
92        executable = True,
93    ),
94    idlclass = attr.label(
95        allow_files = True,
96        cfg = "host",
97        default = "@bazel_tools//tools/android:IdlClass",  # _deploy.jar?
98        executable = True,
99    ),
100    import_deps_checker = attr.label(
101        allow_files = True,
102        cfg = "host",
103        default = "@android_tools//:ImportDepsChecker_deploy.jar",
104        executable = True,
105    ),
106    jacocorunner = attr.label(
107        default = "@androidsdk//:fail",
108    ),
109    java_stub = attr.label(
110        allow_files = True,
111        # used in android_local_test
112        default = "@androidsdk//:fail",  # TODO: java_stub_template.txt gets embedded in bazel's jar, need a copy in @bazel_tools or similar
113    ),
114    jdeps_tool = attr.label(
115        allow_files = True,
116        cfg = "host",
117        # used in android_local_test
118        default = "@androidsdk//:fail",  # TODO: "//src/tools/jdeps", needs Go
119        executable = True,
120    ),
121    proguard_allowlister = attr.label(
122        cfg = "host",
123        default = "@bazel_tools//tools/jdk:proguard_whitelister",
124        executable = True,
125    ),
126    res_v3_dummy_manifest = attr.label(
127        allow_files = True,
128        default = "//rules:res_v3_dummy_AndroidManifest.xml",
129    ),
130    res_v3_dummy_r_txt = attr.label(
131        allow_files = True,
132        default = "//rules:res_v3_dummy_R.txt",
133    ),
134    robolectric_template = attr.label(
135        allow_files = True,
136        default = "//rules:robolectric_properties_template.txt",
137    ),
138    testsupport = attr.label(
139        default = "@androidsdk//:fail",
140    ),
141    unzip_tool = attr.label(
142        cfg = "host",
143        default = "//toolchains/android:unzip",
144        executable = True,
145    ),
146    xsltproc_tool = attr.label(
147        cfg = "host",
148        default = Label("//tools/android/xslt:xslt"),
149        allow_files = True,
150        executable = True,
151    ),
152    zip_tool = attr.label(
153        cfg = "host",
154        default = "//toolchains/android:zip",
155        executable = True,
156    ),
157)
158
159def _impl(ctx):
160    return [platform_common.ToolchainInfo(
161        **{name: getattr(ctx.attr, name) for name in _ATTRS.keys()}
162    )]
163
164android_toolchain = rule(
165    implementation = _impl,
166    attrs = _ATTRS,
167)
168