From c7e5b4bd67e0a80c07bf051654e7d28fb592cc39 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 18 Oct 2021 12:14:22 -0700 Subject: Add hook to add addition build tags PiperOrigin-RevId: 404025736 --- tools/nogo/nogo.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'tools/nogo/nogo.go') diff --git a/tools/nogo/nogo.go b/tools/nogo/nogo.go index 2f88f84db..a96cb400a 100644 --- a/tools/nogo/nogo.go +++ b/tools/nogo/nogo.go @@ -52,10 +52,11 @@ import ( // // This contains everything required for stdlib analysis. type StdlibConfig struct { - Srcs []string - GOOS string - GOARCH string - Tags []string + Srcs []string + GOOS string + GOARCH string + BuildTags []string + ReleaseTags []string // Use build.Default if nil. } // PackageConfig is serialized as the configuration. @@ -65,7 +66,8 @@ type PackageConfig struct { ImportPath string GoFiles []string NonGoFiles []string - Tags []string + BuildTags []string + ReleaseTags []string // Use build.Default if nil. GOOS string GOARCH string ImportMap map[string]string @@ -182,7 +184,10 @@ func (c *PackageConfig) shouldInclude(path string) (bool, error) { ctx := build.Default ctx.GOOS = c.GOOS ctx.GOARCH = c.GOARCH - ctx.BuildTags = c.Tags + ctx.BuildTags = c.BuildTags + if c.ReleaseTags != nil { + ctx.ReleaseTags = c.ReleaseTags + } return ctx.MatchFile(filepath.Dir(path), filepath.Base(path)) } @@ -333,10 +338,11 @@ func CheckStdlib(config *StdlibConfig, analyzers []*analysis.Analyzer) (allFindi c, ok := packages[pkg] if !ok { c = &PackageConfig{ - ImportPath: pkg, - GOOS: config.GOOS, - GOARCH: config.GOARCH, - Tags: config.Tags, + ImportPath: pkg, + GOOS: config.GOOS, + GOARCH: config.GOARCH, + BuildTags: config.BuildTags, + ReleaseTags: config.ReleaseTags, } packages[pkg] = c } -- cgit v1.2.3