xref: /aosp_15_r20/external/bazelbuild-rules_android/mobile_install/debug.bzl (revision 9e965d6fece27a77de5377433c2f7e6999b8cc0b)
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"""Module that enables debugging for mobile-install."""
15
16def _make_output_groups(infos):
17    output_groups = dict()
18    for info in infos:
19        if hasattr(info, "info"):
20            output_group = dict(
21                mi_java_info = info.info.runtime_output_jars,
22            )
23        elif hasattr(info, "transitive_java_resources"):
24            output_group = dict(
25                mi_java_resources_info = info.transitive_java_resources,
26            )
27        elif hasattr(info, "transitive_native_libs"):
28            output_group = dict(
29                mi_aar_native_libs_info = info.transitive_native_libs,
30            )
31        elif hasattr(info, "transitive_dex_shards"):
32            output_group = dict(
33                mi_android_dex_info = depset(
34                    transitive = info.transitive_dex_shards,
35                ),
36            )
37        else:
38            fail("Unsupported provider %s" % info)
39        output_groups.update(output_group)
40    return output_groups
41
42debug = struct(
43    make_output_groups = _make_output_groups,
44)
45