gopackagesdriver: Descend into go_proto_compiler's deps (#3240)
This lets the aspect generate .pkg.json files for well-known type
targets such as `@org_golang_google_protobuf//types/known/wrapperspb`.
diff --git a/go/tools/gopackagesdriver/aspect.bzl b/go/tools/gopackagesdriver/aspect.bzl
index a2da8f0..5cce8b1 100644
--- a/go/tools/gopackagesdriver/aspect.bzl
+++ b/go/tools/gopackagesdriver/aspect.bzl
@@ -24,6 +24,16 @@
GoPkgInfo = provider()
+DEPS_ATTRS = [
+ "deps",
+ "embed",
+]
+
+PROTO_COMPILER_ATTRS = [
+ "compiler",
+ "compilers",
+]
+
def _is_file_external(f):
return f.owner.workspace_root != ""
@@ -67,8 +77,8 @@
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)
@@ -133,7 +143,7 @@
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",