Allow collection of generated_go_srcs from any rule that outputs them.
This change is expanding the scope of where it can look at a go_generated_srcs
OutputGroupInfo to be any rule. And at the same time, it will not filter them
too restrictively.
Merge by mtoader.
@@ -322,16 +322,17 @@ def collect_py_info(target, ctx, semantics, ide_info, ide_info_file, output_grou
update_sync_output_groups(output_groups, "intellij-resolve-py", to_build)
return True
-def _collect_generated_proto_go_sources(target):
- """Returns a depset of proto go source files generated by this target."""
+def _collect_generated_go_sources(target):
+ """Returns a depset of go source files generated by this target."""
if hasattr(target, "proto_go_api_info"):
go_proto_info = target.proto_go_api_info
files = getattr(go_proto_info, "files_to_build", depset()).to_list()
+ return [f for f in files if f.basename.endswith(".pb.go")]
elif hasattr(target[OutputGroupInfo], "go_generated_srcs"):
files = target[OutputGroupInfo].go_generated_srcs.to_list()
+ return [f for f in files if f.basename.endswith(".go")]
else:
return None
- return [f for f in files if f.basename.endswith(".pb.go")]
def collect_go_info(target, ctx, semantics, ide_info, ide_info_file, output_groups):
"""Updates Go-specific output groups, returns false if not a recognized Go target."""
@@ -359,11 +360,11 @@ def collect_go_info(target, ctx, semantics, ide_info, ide_info_file, output_grou
# if the .go file isn't in 'files', build the .a and .x files instead
generated = genfiles
else:
- proto_sources = _collect_generated_proto_go_sources(target)
- if not proto_sources:
+ generated_sources = _collect_generated_go_sources(target)
+ if not generated_sources:
return False
- sources = proto_sources
- generated = proto_sources
+ sources = generated_sources
+ generated = generated_sources
import_path = None
go_semantics = getattr(semantics, "go", None)
