mirror of https://github.com/bazelbuild/rules_cc
Adds exported_by function to cc_shared_library
This function is meant to be used for the tag containing exported_by. RELNOTES:none PiperOrigin-RevId: 298568236 Change-Id: Ia7b039d1764a3b79a3a0cc3f7f68a8eb17e6f0d5
This commit is contained in:
parent
f38419606c
commit
d4357efea4
|
@ -15,6 +15,14 @@ load("//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
|
|||
# used sparingly after making sure it's safe to use.
|
||||
LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"
|
||||
|
||||
_EXPORTED_BY_TAG_BEGINNING = "exported_by="
|
||||
|
||||
def exported_by(labels):
|
||||
str_builder = []
|
||||
for label in labels:
|
||||
str_builder.append(label)
|
||||
return _EXPORTED_BY_TAG_BEGINNING + ",".join(str_builder)
|
||||
|
||||
GraphNodeInfo = provider(
|
||||
fields = {
|
||||
"children": "Other GraphNodeInfo from dependencies of this target",
|
||||
|
@ -346,8 +354,8 @@ def _graph_structure_aspect_impl(target, ctx):
|
|||
linkable_more_than_once = False
|
||||
if hasattr(ctx.rule.attr, "tags"):
|
||||
for tag in ctx.rule.attr.tags:
|
||||
if tag.startswith("exported_by=") and len(tag) > 12:
|
||||
for target in tag[12:].split(","):
|
||||
if tag.startswith(_EXPORTED_BY_TAG_BEGINNING) and len(tag) > len(_EXPORTED_BY_TAG_BEGINNING):
|
||||
for target in tag[len(_EXPORTED_BY_TAG_BEGINNING):].split(","):
|
||||
# Only absolute labels allowed. Targets in same package
|
||||
# or subpackage can be exported anyway.
|
||||
if not target.startswith("//") and not target.startswith("@"):
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("@rules_cc//examples:experimental_cc_shared_library.bzl", "exported_by")
|
||||
|
||||
cc_library(
|
||||
name = "bar",
|
||||
srcs = ["bar.cc"],
|
||||
hdrs = ["bar.h"],
|
||||
tags = ["exported_by=@rules_cc//examples/test_cc_shared_library:bar_so"],
|
||||
tags = [exported_by(["@rules_cc//examples/test_cc_shared_library:bar_so"])],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue