C++: Remove linked_statically_by from cc_shared_library
RELNOTES:none
PiperOrigin-RevId: 295131987
Change-Id: I507106a7553da61f706b64c9232e4b7ea9a180d9
diff --git a/examples/experimental_cc_shared_library.bzl b/examples/experimental_cc_shared_library.bzl
index 4b41fd7..49b9b8e 100644
--- a/examples/experimental_cc_shared_library.bzl
+++ b/examples/experimental_cc_shared_library.bzl
@@ -9,18 +9,10 @@
# TODO(#5200): Add export_define to library_to_link and cc_library
-# TODO(plf): Even though at the begining the idea was to completely forbid
-# anyone to link a library statically without permission from the library owner,
-# there have been complaints about this. linked_statically_by is hard to use
-# and too restrictive. static_deps will completely replace linked_statically_by.
-# Library authors will still have control of who exports them by using exported_by.
-
GraphNodeInfo = provider(
fields = {
"children": "Other GraphNodeInfo from dependencies of this target",
"label": "Label of the target visited",
- # TODO(plf): Completely remove linked_statically_by.
- "linked_statically_by": "The value of this attribute if the target has it",
},
)
CcSharedLibraryInfo = provider(
@@ -52,9 +44,9 @@
node_label = str(node.label)
if node_label in can_be_linked_dynamically:
- link_dynamically_labels[node_label] = None
+ link_dynamically_labels[node_label] = True
elif node_label not in preloaded_deps_direct_labels:
- link_statically_labels[node_label] = node.linked_statically_by
+ link_statically_labels[node_label] = True
all_children.extend(node.children)
return (link_statically_labels, link_dynamically_labels)
@@ -211,21 +203,13 @@
else:
can_be_linked_statically = False
- # TODO(plf): This loop will go away when linked_statically_by is
- # replaced completely by static_deps.
- for linked_statically_by in link_statically_labels[owner]:
- if linked_statically_by == str(ctx.label):
+ for static_dep_path in ctx.attr.static_deps:
+ target_specified = _is_target_specified(static_dep_path)
+ static_dep_path_label = ctx.label.relative(static_dep_path)
+ owner_label = linker_input.owner
+ if _check_if_target_under_path(linker_input.owner, static_dep_path_label, target_specified):
can_be_linked_statically = True
break
-
- if not can_be_linked_statically:
- for static_dep_path in ctx.attr.static_deps:
- target_specified = _is_target_specified(static_dep_path)
- static_dep_path_label = ctx.label.relative(static_dep_path)
- owner_label = linker_input.owner
- if _check_if_target_under_path(linker_input.owner, static_dep_path_label, target_specified):
- can_be_linked_statically = True
- break
if can_be_linked_statically:
static_linker_inputs.append(linker_input)
else:
@@ -364,13 +348,8 @@
if GraphNodeInfo in dep:
children.append(dep[GraphNodeInfo])
- linked_statically_by = []
- if hasattr(ctx.rule.attr, "linked_statically_by"):
- linked_statically_by = [str(label) for label in ctx.rule.attr.linked_statically_by]
-
return [GraphNodeInfo(
label = ctx.label,
- linked_statically_by = linked_statically_by,
children = children,
)]
@@ -385,9 +364,6 @@
"dynamic_deps": attr.label_list(providers = [CcSharedLibraryInfo]),
"exports": attr.label_list(providers = [CcInfo], aspects = [graph_structure_aspect]),
"preloaded_deps": attr.label_list(providers = [CcInfo]),
- # TODO(plf): Replaces linked_statically_by attribute. Instead of
- # linked_statically_by attribute in each cc_library we will have the
- # attribute exported_by which will restrict exportability.
"static_deps": attr.string_list(),
"user_link_flags": attr.string_list(),
"visibility_file": attr.label(allow_single_file = True),