Skip to content

Commit

Permalink
Adapt Go extractor to new -goroot flag (kythe#6134)
Browse files Browse the repository at this point in the history
rules_go may pass the GOROOT via the `-goroot` flag instead of an environment variable since bazel-contrib/rules_go@6f206ad.
  • Loading branch information
fmeum authored Aug 30, 2024
1 parent 75f63c5 commit e35bed7
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ type extractor struct {

func (e *extractor) checkAction(_ context.Context, info *bazel.ActionInfo) error {
e.compileArgs = parseCompileArgs(info.Arguments)
// rules_go may pass GOROOT as a flag instead of an environment variable.
e.goroot = e.compileArgs.goroot
for name, value := range info.Environment {
switch name {
case "GOOS":
Expand Down Expand Up @@ -196,6 +198,7 @@ type compileArgs struct {
include []string // additional include directories
importPath string // output package import path
trimPrefix string // prefix to trim from source paths
goroot string // goroot if passed via a flag
}

func parseCompileArgs(args []string) *compileArgs {
Expand Down Expand Up @@ -248,6 +251,8 @@ func parseCompileArgs(args []string) *compileArgs {
c.srcs = append(c.srcs, arg)
case "tags":
c.tags = append(c.tags, arg)
case "goroot":
c.goroot = arg
}
flag = "" // reset
}
Expand Down

0 comments on commit e35bed7

Please sign in to comment.