diff options
author | Romain Jobredeaux <jobredeaux@google.com> | 2023-04-17 22:03:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-17 22:03:11 +0000 |
commit | 8cfa27a8ba0254670dd358f462e6e199c4622850 (patch) | |
tree | 511605b77ecb290a4ec8bec4c91c2ed27d3b6f54 | |
parent | c0f340770a579bbc78696b514b8ad866f59b5db0 (diff) | |
parent | c3104659bb20f00e8733b48e3b7612da39a0eb15 (diff) | |
download | bazel-8cfa27a8ba0254670dd358f462e6e199c4622850.tar.gz |
Merge "Allow sdk transition wrappers in exports of aar_import." am: 146e4150d3 am: c3104659bb
Original change: https://android-review.googlesource.com/c/platform/build/bazel/+/2537759
Change-Id: I00ce03ef3aa02cc9bb41e54cb75fc85ff6f11cdc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | rules/android/aar_import.bzl | 2 | ||||
-rw-r--r-- | rules/android/aar_import_aosp_internal/BUILD.bazel | 0 | ||||
-rw-r--r-- | rules/android/aar_import_aosp_internal/attrs.bzl | 40 | ||||
-rw-r--r-- | rules/android/aar_import_aosp_internal/rule.bzl | 33 |
4 files changed, 74 insertions, 1 deletions
diff --git a/rules/android/aar_import.bzl b/rules/android/aar_import.bzl index e93a821f..76abef03 100644 --- a/rules/android/aar_import.bzl +++ b/rules/android/aar_import.bzl @@ -14,7 +14,7 @@ """Macro wrapping the aar_import for bp2build. """ -load("@rules_android//rules:rules.bzl", _aar_import = "aar_import") +load("//build/bazel/rules/android/aar_import_aosp_internal:rule.bzl", _aar_import = "aar_import") load("//build/bazel/rules/java:sdk_transition.bzl", "sdk_transition", "sdk_transition_attrs") # TODO(b/277801336): document these attributes. diff --git a/rules/android/aar_import_aosp_internal/BUILD.bazel b/rules/android/aar_import_aosp_internal/BUILD.bazel new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/rules/android/aar_import_aosp_internal/BUILD.bazel diff --git a/rules/android/aar_import_aosp_internal/attrs.bzl b/rules/android/aar_import_aosp_internal/attrs.bzl new file mode 100644 index 00000000..1b685b3f --- /dev/null +++ b/rules/android/aar_import_aosp_internal/attrs.bzl @@ -0,0 +1,40 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# 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. + +load( + "@rules_android//rules:attrs.bzl", + _attrs = "attrs", +) +load( + "@rules_android//rules/aar_import:attrs.bzl", + _BASE_ATTRS = "ATTRS", +) + +ATTRS = _attrs.replace( + _BASE_ATTRS, + exports = attr.label_list( + allow_files = False, + allow_rules = [ + "aar_import", + "java_import", + "kt_jvm_import", + "aar_import_sdk_transition", + "java_import_sdk_transition", + "kt_jvm_import_sdk_transition", + ], + doc = "The closure of all rules reached via `exports` attributes are considered " + + "direct dependencies of any rule that directly depends on the target with " + + "`exports`. The `exports` are not direct deps of the rule they belong to.", + ), +) diff --git a/rules/android/aar_import_aosp_internal/rule.bzl b/rules/android/aar_import_aosp_internal/rule.bzl new file mode 100644 index 00000000..79580f2a --- /dev/null +++ b/rules/android/aar_import_aosp_internal/rule.bzl @@ -0,0 +1,33 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# 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. + +"""aar_import rule.""" + +load(":attrs.bzl", _ATTRS = "ATTRS") +load("@rules_android//rules/aar_import:impl.bzl", _impl = "impl") +load("@rules_android//rules/aar_import:rule.bzl", "RULE_DOC") + +aar_import = rule( + attrs = _ATTRS, + fragments = ["android"], + implementation = _impl, + doc = RULE_DOC, + provides = [ + AndroidIdeInfo, + AndroidLibraryResourceClassJarProvider, + AndroidNativeLibsInfo, + JavaInfo, + ], + toolchains = ["@rules_android//toolchains/android:toolchain_type"], +) |