Skip to content

Commit

Permalink
gopackagesdriver: Descend into go_proto_compiler's deps (#3240)
Browse files Browse the repository at this point in the history
This lets the aspect generate .pkg.json files for well-known type
targets such as `@org_golang_google_protobuf//types/known/wrapperspb`.
  • Loading branch information
fmeum authored Jul 17, 2022
1 parent 8fe3a08 commit 54c6b9d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions go/tools/gopackagesdriver/aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ load(

GoPkgInfo = provider()

DEPS_ATTRS = [
"deps",
"embed",
]

PROTO_COMPILER_ATTRS = [
"compiler",
"compilers",
]

def _is_file_external(f):
return f.owner.workspace_root != ""

Expand Down Expand Up @@ -67,8 +77,8 @@ def _go_pkg_info_aspect_impl(target, ctx):
transitive_export_files = []
transitive_compiled_go_files = []

for attr in ["deps", "embed"]:
for dep in getattr(ctx.rule.attr, attr, []):
for attr in DEPS_ATTRS + PROTO_COMPILER_ATTRS:
for dep in getattr(ctx.rule.attr, attr, []) or []:
if GoPkgInfo in dep:
pkg_info = dep[GoPkgInfo]
transitive_json_files.append(pkg_info.pkg_json_files)
Expand Down Expand Up @@ -133,7 +143,7 @@ def _go_pkg_info_aspect_impl(target, ctx):

go_pkg_info_aspect = aspect(
implementation = _go_pkg_info_aspect_impl,
attr_aspects = ["embed", "deps"],
attr_aspects = DEPS_ATTRS + PROTO_COMPILER_ATTRS,
attrs = {
"_go_stdlib": attr.label(
default = "//:stdlib",
Expand Down

0 comments on commit 54c6b9d

Please sign in to comment.