summaryrefslogtreecommitdiffhomepage
path: root/tools/nogo/nogo.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-10-18 12:14:22 -0700
committergVisor bot <gvisor-bot@google.com>2021-10-18 12:16:53 -0700
commitc7e5b4bd67e0a80c07bf051654e7d28fb592cc39 (patch)
tree7eebb8f638322768ac6616bfa96a39fa53fd60dd /tools/nogo/nogo.go
parenteafa3f19e4d2c0a490af78dbe77289c7b5edbb76 (diff)
Add hook to add addition build tags
PiperOrigin-RevId: 404025736
Diffstat (limited to 'tools/nogo/nogo.go')
-rw-r--r--tools/nogo/nogo.go26
1 files changed, 16 insertions, 10 deletions
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
}