• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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"""Bazel rule for Android sdk."""
16
17load(":attrs.bzl", "ANDROID_SDK_ATTRS")
18
19def _impl(ctx):
20    proguard = ctx.attr._proguard if ctx.attr._proguard else ctx.attr.proguard
21    android_sdk_info = AndroidSdkInfo(
22        ctx.attr.build_tools_version,
23        ctx.file.framework_aidl,
24        ctx.attr.aidl_lib,
25        ctx.file.android_jar,
26        ctx.file.source_properties,
27        ctx.file.shrinked_android_jar,
28        ctx.file.main_dex_classes,
29        ctx.attr.adb.files_to_run,
30        ctx.attr.dx.files_to_run,
31        ctx.attr.main_dex_list_creator.files_to_run,
32        ctx.attr.aidl.files_to_run,
33        ctx.attr.aapt.files_to_run,
34        ctx.attr.aapt2.files_to_run,
35        ctx.attr.apkbuilder.files_to_run if ctx.attr.apkbuilder else None,
36        ctx.attr.apksigner.files_to_run,
37        proguard.files_to_run,
38        ctx.attr.zipalign.files_to_run,
39        # Passing the 'system' here is only necessary to support native android_binary.
40        # TODO(b/149114743): remove this after the migration to android_application.
41        ctx.attr._system[java_common.BootClassPathInfo] if ctx.attr._system and java_common.BootClassPathInfo in ctx.attr._system else None,
42    )
43    return [
44        android_sdk_info,
45        platform_common.ToolchainInfo(android_sdk_info = android_sdk_info),
46    ]
47
48android_sdk = rule(
49    attrs = ANDROID_SDK_ATTRS,
50    implementation = _impl,
51    fragments = ["java"],
52    provides = [AndroidSdkInfo],
53)
54