| # Copyright 2018 The Bazel Authors. All rights reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| """Bazel rule for Android local test.""" |
| |
| load("//rules:utils.bzl", "ANDROID_SDK_TOOLCHAIN_TYPE") |
| load("//rules:visibility.bzl", "PROJECT_VISIBILITY") |
| load(":attrs.bzl", "ATTRS") |
| load(":impl.bzl", "impl") |
| |
| visibility(PROJECT_VISIBILITY) |
| |
| def make_rule( |
| attrs = ATTRS, |
| implementation = impl, |
| additional_toolchains = []): |
| """Makes the rule. |
| |
| Args: |
| attrs: A dict. The attributes for the rule. |
| implementation: A function. The rule's implementation method. |
| |
| Returns: |
| A rule. |
| """ |
| return rule( |
| attrs = attrs, |
| implementation = implementation, |
| cfg = config_common.config_feature_flag_transition("feature_flags"), |
| fragments = [ |
| "android", |
| "bazel_android", # NOTE: Only exists for Bazel |
| "java", |
| ], |
| test = True, |
| outputs = dict( |
| deploy_jar = "%{name}_deploy.jar", |
| jar = "%{name}.jar", |
| ), |
| toolchains = [ |
| "//toolchains/android:toolchain_type", |
| ANDROID_SDK_TOOLCHAIN_TYPE, |
| "@bazel_tools//tools/jdk:toolchain_type", |
| ] + additional_toolchains, |
| ) |
| |
| android_local_test = make_rule() |