1# Copyright 2020 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"""A rule that returns android.jar from the current android sdk.""" 16 17def _android_jar_impl(ctx): 18 return DefaultInfo( 19 files = depset([ctx.attr._sdk[AndroidSdkInfo].android_jar]), 20 ) 21 22android_jar = rule( 23 implementation = _android_jar_impl, 24 # TODO: Should use a toolchain instead of a configuration_field on 25 # --android_sdk as below, however that appears to be broken when used 26 # from an local_repository: b/183060658. 27 #toolchains = [ 28 # "//toolchains/android_sdk:toolchain_type", 29 #], 30 attrs = { 31 "_sdk": attr.label( 32 allow_rules = ["android_sdk"], 33 default = configuration_field( 34 fragment = "android", 35 name = "android_sdk_label", 36 ), 37 providers = [AndroidSdkInfo], 38 ), 39 }, 40) 41