Skip to content

Commit dadc49e

Browse files
c-parsonscopybara-github
authored andcommitted
Apply graph_structure aspect across all edges
RELNOTES: None. PiperOrigin-RevId: 454171951 Change-Id: Idcf4a0c0ab6e4a784b54bb740812b13b747710d9
1 parent c2d50de commit dadc49e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl

+15-5
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,21 @@ def _cc_shared_library_impl(ctx):
546546
def _graph_structure_aspect_impl(target, ctx):
547547
children = []
548548

549-
# For now ignore cases when deps is of type label instead of label_list.
550-
if hasattr(ctx.rule.attr, "deps") and type(ctx.rule.attr.deps) != "Target":
551-
for dep in ctx.rule.attr.deps:
552-
if GraphNodeInfo in dep:
553-
children.append(dep[GraphNodeInfo])
549+
# Collect graph structure info from any possible deplike attribute. The aspect
550+
# itself applies across every deplike attribute (attr_aspects is *), so enumerate
551+
# over all attributes and consume GraphNodeInfo if available.
552+
for fieldname in dir(ctx.rule.attr):
553+
if fieldname == "_cc_toolchain" or fieldname == "target_compatible_with":
554+
continue
555+
deps = getattr(ctx.rule.attr, fieldname, None)
556+
if type(deps) == "list":
557+
for dep in deps:
558+
if type(dep) == "Target" and GraphNodeInfo in dep:
559+
children.append(dep[GraphNodeInfo])
560+
561+
# Single dep.
562+
elif type(deps) == "Target" and GraphNodeInfo in deps:
563+
children.append(deps[GraphNodeInfo])
554564

555565
# TODO(bazel-team): Add flag to Bazel that can toggle the initialization of
556566
# linkable_more_than_once.

0 commit comments

Comments
 (0)