xref: /aosp_15_r20/external/bazelbuild-rules_cc/examples/experimental_cc_shared_library.bzl (revision eed53cd41c5909d05eedc7ad9720bb158fd93452)
1"""This is an experimental implementation of cc_shared_library.
2
3We may change the implementation at any moment or even delete this file. Do not
4rely on this. It requires bazel >1.2  and passing the flag
5--experimental_cc_shared_library
6"""
7
8# Add this as a tag to any target that can be linked by more than one
9# cc_shared_library because it doesn't have static initializers or anything
10# else that may cause issues when being linked more than once. This should be
11# used sparingly after making sure it's safe to use.
12LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"
13
14CcSharedLibraryPermissionsInfo = provider(
15    "Permissions for a cc shared library.",
16    fields = {
17        "targets": "Matches targets that can be exported.",
18    },
19)
20GraphNodeInfo = provider(
21    "Nodes in the graph of shared libraries.",
22    fields = {
23        "children": "Other GraphNodeInfo from dependencies of this target",
24        "label": "Label of the target visited",
25        "linkable_more_than_once": "Linkable into more than a single cc_shared_library",
26    },
27)
28CcSharedLibraryInfo = provider(
29    "Information about a cc shared library.",
30    fields = {
31        "dynamic_deps": "All shared libraries depended on transitively",
32        "exports": "cc_libraries that are linked statically and exported",
33        "link_once_static_libs": "All libraries linked statically into this library that should " +
34                                 "only be linked once, e.g. because they have static " +
35                                 "initializers. If we try to link them more than once, " +
36                                 "we will throw an error",
37        "linker_input": "the resulting linker input artifact for the shared library",
38        "preloaded_deps": "cc_libraries needed by this cc_shared_library that should" +
39                          " be linked the binary. If this is set, this cc_shared_library has to " +
40                          " be a direct dependency of the cc_binary",
41    },
42)
43
44def cc_shared_library_permissions(**kwargs):
45    native.cc_shared_library_permissions(**kwargs)
46
47def cc_shared_library(**kwargs):
48    native.cc_shared_library(**kwargs)
49