mirror of
https://github.com/golang/go.git
synced 2025-05-18 22:04:38 +00:00
cmd/go: add IgnoredOtherFiles to go list; pass IgnoredFiles to vet
Show constraint-ignored non-.go files in go list, as Package.IgnoredOtherFiles (same as go/build's IgnoredOtherFiles). Pass full list of ignored files to vet, to help buildtag checker. For #41184. Change-Id: I749868de9082cbbc1efbc59370783c8c82fe735f Reviewed-on: https://go-review.googlesource.com/c/go/+/240553 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
8b289a15e4
commit
7b77ff4c88
@ -75,19 +75,20 @@ type PackagePublic struct {
|
|||||||
// Source files
|
// Source files
|
||||||
// If you add to this list you MUST add to p.AllFiles (below) too.
|
// If you add to this list you MUST add to p.AllFiles (below) too.
|
||||||
// Otherwise file name security lists will not apply to any new additions.
|
// Otherwise file name security lists will not apply to any new additions.
|
||||||
GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||||
CgoFiles []string `json:",omitempty"` // .go source files that import "C"
|
CgoFiles []string `json:",omitempty"` // .go source files that import "C"
|
||||||
CompiledGoFiles []string `json:",omitempty"` // .go output from running cgo on CgoFiles
|
CompiledGoFiles []string `json:",omitempty"` // .go output from running cgo on CgoFiles
|
||||||
IgnoredGoFiles []string `json:",omitempty"` // .go source files ignored due to build constraints
|
IgnoredGoFiles []string `json:",omitempty"` // .go source files ignored due to build constraints
|
||||||
CFiles []string `json:",omitempty"` // .c source files
|
IgnoredOtherFiles []string `json:",omitempty"` // non-.go source files ignored due to build constraints
|
||||||
CXXFiles []string `json:",omitempty"` // .cc, .cpp and .cxx source files
|
CFiles []string `json:",omitempty"` // .c source files
|
||||||
MFiles []string `json:",omitempty"` // .m source files
|
CXXFiles []string `json:",omitempty"` // .cc, .cpp and .cxx source files
|
||||||
HFiles []string `json:",omitempty"` // .h, .hh, .hpp and .hxx source files
|
MFiles []string `json:",omitempty"` // .m source files
|
||||||
FFiles []string `json:",omitempty"` // .f, .F, .for and .f90 Fortran source files
|
HFiles []string `json:",omitempty"` // .h, .hh, .hpp and .hxx source files
|
||||||
SFiles []string `json:",omitempty"` // .s source files
|
FFiles []string `json:",omitempty"` // .f, .F, .for and .f90 Fortran source files
|
||||||
SwigFiles []string `json:",omitempty"` // .swig files
|
SFiles []string `json:",omitempty"` // .s source files
|
||||||
SwigCXXFiles []string `json:",omitempty"` // .swigcxx files
|
SwigFiles []string `json:",omitempty"` // .swig files
|
||||||
SysoFiles []string `json:",omitempty"` // .syso system object files added to package
|
SwigCXXFiles []string `json:",omitempty"` // .swigcxx files
|
||||||
|
SysoFiles []string `json:",omitempty"` // .syso system object files added to package
|
||||||
|
|
||||||
// Cgo directives
|
// Cgo directives
|
||||||
CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler
|
CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler
|
||||||
@ -127,6 +128,7 @@ func (p *Package) AllFiles() []string {
|
|||||||
p.CgoFiles,
|
p.CgoFiles,
|
||||||
// no p.CompiledGoFiles, because they are from GoFiles or generated by us
|
// no p.CompiledGoFiles, because they are from GoFiles or generated by us
|
||||||
p.IgnoredGoFiles,
|
p.IgnoredGoFiles,
|
||||||
|
p.IgnoredOtherFiles,
|
||||||
p.CFiles,
|
p.CFiles,
|
||||||
p.CXXFiles,
|
p.CXXFiles,
|
||||||
p.MFiles,
|
p.MFiles,
|
||||||
@ -330,6 +332,7 @@ func (p *Package) copyBuild(pp *build.Package) {
|
|||||||
p.GoFiles = pp.GoFiles
|
p.GoFiles = pp.GoFiles
|
||||||
p.CgoFiles = pp.CgoFiles
|
p.CgoFiles = pp.CgoFiles
|
||||||
p.IgnoredGoFiles = pp.IgnoredGoFiles
|
p.IgnoredGoFiles = pp.IgnoredGoFiles
|
||||||
|
p.IgnoredOtherFiles = pp.IgnoredOtherFiles
|
||||||
p.CFiles = pp.CFiles
|
p.CFiles = pp.CFiles
|
||||||
p.CXXFiles = pp.CXXFiles
|
p.CXXFiles = pp.CXXFiles
|
||||||
p.MFiles = pp.MFiles
|
p.MFiles = pp.MFiles
|
||||||
|
@ -922,12 +922,13 @@ func (b *Builder) loadCachedSrcFiles(a *Action) error {
|
|||||||
|
|
||||||
// vetConfig is the configuration passed to vet describing a single package.
|
// vetConfig is the configuration passed to vet describing a single package.
|
||||||
type vetConfig struct {
|
type vetConfig struct {
|
||||||
ID string // package ID (example: "fmt [fmt.test]")
|
ID string // package ID (example: "fmt [fmt.test]")
|
||||||
Compiler string // compiler name (gc, gccgo)
|
Compiler string // compiler name (gc, gccgo)
|
||||||
Dir string // directory containing package
|
Dir string // directory containing package
|
||||||
ImportPath string // canonical import path ("package path")
|
ImportPath string // canonical import path ("package path")
|
||||||
GoFiles []string // absolute paths to package source files
|
GoFiles []string // absolute paths to package source files
|
||||||
NonGoFiles []string // absolute paths to package non-Go files
|
NonGoFiles []string // absolute paths to package non-Go files
|
||||||
|
IgnoredFiles []string // absolute paths to ignored source files
|
||||||
|
|
||||||
ImportMap map[string]string // map import path in source code to package path
|
ImportMap map[string]string // map import path in source code to package path
|
||||||
PackageFile map[string]string // map package path to .a file with export data
|
PackageFile map[string]string // map package path to .a file with export data
|
||||||
@ -951,20 +952,23 @@ func buildVetConfig(a *Action, srcfiles []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignored := str.StringList(a.Package.IgnoredGoFiles, a.Package.IgnoredOtherFiles)
|
||||||
|
|
||||||
// Pass list of absolute paths to vet,
|
// Pass list of absolute paths to vet,
|
||||||
// so that vet's error messages will use absolute paths,
|
// so that vet's error messages will use absolute paths,
|
||||||
// so that we can reformat them relative to the directory
|
// so that we can reformat them relative to the directory
|
||||||
// in which the go command is invoked.
|
// in which the go command is invoked.
|
||||||
vcfg := &vetConfig{
|
vcfg := &vetConfig{
|
||||||
ID: a.Package.ImportPath,
|
ID: a.Package.ImportPath,
|
||||||
Compiler: cfg.BuildToolchainName,
|
Compiler: cfg.BuildToolchainName,
|
||||||
Dir: a.Package.Dir,
|
Dir: a.Package.Dir,
|
||||||
GoFiles: mkAbsFiles(a.Package.Dir, gofiles),
|
GoFiles: mkAbsFiles(a.Package.Dir, gofiles),
|
||||||
NonGoFiles: mkAbsFiles(a.Package.Dir, nongofiles),
|
NonGoFiles: mkAbsFiles(a.Package.Dir, nongofiles),
|
||||||
ImportPath: a.Package.ImportPath,
|
IgnoredFiles: mkAbsFiles(a.Package.Dir, ignored),
|
||||||
ImportMap: make(map[string]string),
|
ImportPath: a.Package.ImportPath,
|
||||||
PackageFile: make(map[string]string),
|
ImportMap: make(map[string]string),
|
||||||
Standard: make(map[string]bool),
|
PackageFile: make(map[string]string),
|
||||||
|
Standard: make(map[string]bool),
|
||||||
}
|
}
|
||||||
a.vetCfg = vcfg
|
a.vetCfg = vcfg
|
||||||
for i, raw := range a.Package.Internal.RawImports {
|
for i, raw := range a.Package.Internal.RawImports {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user