Skip to content

Commit

Permalink
go_list cleanup
Browse files Browse the repository at this point in the history
Summary:
Better layout.

#build_rule_type[go_library,go_binary,go_unittest,go_test]

Reviewed By: leoleovich

Differential Revision: D68721492

fbshipit-source-id: 278a72a33b5d64c35b7ff3dde53e3ab6cc2bf054
  • Loading branch information
echistyakov authored and facebook-github-bot committed Jan 28, 2025
1 parent 5885b58 commit 44d6040
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions go/go_list.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
load("@prelude//:paths.bzl", "paths")
load(":toolchain.bzl", "GoToolchainInfo", "get_toolchain_env_vars")

# Modeled after: https://pkg.go.dev/cmd/go/internal/list#pkg-variables
GoListOut = record(
name = field(str),
imports = field(list[str], default = []),
Expand Down Expand Up @@ -46,9 +47,28 @@ def go_list(ctx: AnalysisContext, pkg_name: str, srcs: list[Artifact], package_r
if asan:
all_tags.append("asan")

required_felds = "Name,Imports,GoFiles,CgoFiles,HFiles,CFiles,CXXFiles,SFiles,EmbedFiles,CgoCFLAGS,CgoCPPFLAGS,IgnoredGoFiles,IgnoredOtherFiles"
required_felds = [
"Name",
"Imports",
"GoFiles",
"CgoFiles",
"HFiles",
"CFiles",
"CXXFiles",
"SFiles",
"EmbedFiles",
"CgoCFLAGS",
"CgoCPPFLAGS",
"IgnoredGoFiles",
"IgnoredOtherFiles",
]
if with_tests:
required_felds += ",TestImports,XTestImports,TestGoFiles,XTestGoFiles"
required_felds += [
"TestImports",
"XTestImports",
"TestGoFiles",
"XTestGoFiles",
]

go_list_args = [
go_toolchain.go_wrapper,
Expand All @@ -57,7 +77,7 @@ def go_list(ctx: AnalysisContext, pkg_name: str, srcs: list[Artifact], package_r
["--output", go_list_out.as_output()],
"list",
"-e",
"-json=" + required_felds,
"-json=" + ",".join(required_felds),
["-tags", ",".join(all_tags) if all_tags else []],
".",
]
Expand Down

0 comments on commit 44d6040

Please sign in to comment.