Skip to content

Commit

Permalink
Rename attribute to "deps"
Browse files Browse the repository at this point in the history
This hack allows us to support native cc_shared_library aspect
propagation along the "deps" attribute.

See
bazelbuild/bazel#16296 (comment)
for details.

Test: mixed_droid, both at HEAD and after a rollback of the referenced
Bazel commit

Change-Id: I2247b974a5cd7cc105ec1d674569d9eacdbc302b
  • Loading branch information
c-parsons committed Oct 7, 2022
1 parent dc3f311 commit 42e949c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rules/cc/cc_stub_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,23 @@ def cc_stub_library_shared(name, stubs_symbol_file, version, export_includes, so
name = name,
stub_target = name + "_files",
library_target = name + "_so",
root_target = name + "_root",
deps = [name + "_root"],
source_library = source_library,
tags = tags,
)

def _cc_stub_library_shared_impl(ctx):
# Using a "deps" label_list instead of a single mandatory label attribute
# is a hack to support aspect propagation of graph_aspect of the native
# cc_shared_library. The aspect will only be applied and propagated along
# a label_list attribute named "deps".
if len(ctx.attr.deps) != 1:
fail("Exactly one 'deps' must be specified for cc_stub_library_shared")
return [
ctx.attr.library_target[DefaultInfo],
ctx.attr.library_target[CcSharedLibraryInfo],
ctx.attr.stub_target[CcStubInfo],
ctx.attr.root_target[CcInfo],
ctx.attr.deps[0][CcInfo],
CcStubLibrariesInfo(has_stubs = True),
OutputGroupInfo(rule_impl_debug_files = depset()),
CcStubLibrarySharedInfo(source_library = ctx.attr.source_library),
Expand All @@ -175,7 +181,9 @@ _cc_stub_library_shared = rule(
attrs = {
"stub_target": attr.label(mandatory = True),
"library_target": attr.label(mandatory = True),
"root_target": attr.label(mandatory = True),
# "deps" should be a single element: the root target of the stub library.
# See _cc_stub_library_shared_impl comment for explanation.
"deps": attr.label_list(mandatory = True),
"source_library": attr.label(mandatory = True),
},
)
Expand Down

0 comments on commit 42e949c

Please sign in to comment.