Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix math/bits go build tags #935

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions dependency/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,21 @@ type PkgInfo struct {
Loc PkgLoc
}

// PackagesAddedToStdlib is the list of packages added to the go standard lib
// at various points.
var PackagesAddedToStdlib = map[string]struct{}{
// context and net/http/httptrace are packages being added to
// the Go 1.7 standard library. Some packages, such as golang.org/x/net
// are importing it with build flags in files for go1.7.
"context": struct{}{},
"net/http/httptrace": struct{}{},

// math.bits are packages being added to the Go 1.9 standard library.
// Some packages, such as github.com/RoaringBitmap/roaring are importing
// it with build flags in files for go1.9.
"math/bits": struct{}{},
}

// FindPkg takes a package name and attempts to find it on the filesystem
//
// The resulting PkgInfo will indicate where it was found.
Expand Down Expand Up @@ -1052,11 +1067,9 @@ func (r *Resolver) FindPkg(name string) *PkgInfo {
// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath
info.Loc = LocAppengine
r.findCache[name] = info
} else if name == "context" || name == "net/http/httptrace" {
// context and net/http/httptrace are packages being added to
// the Go 1.7 standard library. Some packages, such as golang.org/x/net
// are importing it with build flags in files for go1.7. Need to detect
// this and handle it.
} else if _, ok := PackagesAddedToStdlib[name]; ok {
// Various packages are being added to the Go standard library, and being imported
// with build flags. Need to detect this and handle it.
info.Loc = LocGoroot
r.findCache[name] = info
}
Expand Down
8 changes: 3 additions & 5 deletions tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ func findPkg(b *util.BuildCtxt, name, cwd string) *dependency.PkgInfo {
// where Google products are playing with each other.
// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath
info.Loc = dependency.LocAppengine
} else if name == "context" || name == "net/http/httptrace" {
// context and net/http/httptrace are packages being added to
// the Go 1.7 standard library. Some packages, such as golang.org/x/net
// are importing it with build flags in files for go1.7. Need to detect
// this and handle it.
} else if _, ok := dependency.PackagesAddedToStdlib[name]; ok {
// Various packages are being added to the Go standard library, and being imported
// with build flags. Need to detect this and handle it.
info.Loc = dependency.LocGoroot
}

Expand Down