build.go (go1.19.src) | : | build.go (go1.19.1.src) | ||
---|---|---|---|---|
skipping to change at line 23 | skipping to change at line 23 | |||
// If we added this API to go/build directly, we wouldn't need this | // If we added this API to go/build directly, we wouldn't need this | |||
// file anymore, but this API is not terribly general-purpose and we | // file anymore, but this API is not terribly general-purpose and we | |||
// don't really want to commit to any public form of it, nor do we | // don't really want to commit to any public form of it, nor do we | |||
// want to move the core parts of go/build into a top-level internal package. | // want to move the core parts of go/build into a top-level internal package. | |||
// These details change very infrequently, so the copy is fine. | // These details change very infrequently, so the copy is fine. | |||
package imports | package imports | |||
import ( | import ( | |||
"bytes" | "bytes" | |||
"cmd/go/internal/cfg" | ||||
"errors" | "errors" | |||
"fmt" | "fmt" | |||
"go/build/constraint" | "go/build/constraint" | |||
"strings" | "strings" | |||
"unicode" | "unicode" | |||
) | ) | |||
var ( | var ( | |||
bSlashSlash = []byte("//") | bSlashSlash = []byte("//") | |||
bStarSlash = []byte("*/") | bStarSlash = []byte("*/") | |||
skipping to change at line 204 | skipping to change at line 205 | |||
} | } | |||
if tags["*"] && name != "" && name != "ignore" { | if tags["*"] && name != "" && name != "ignore" { | |||
// Special case for gathering all possible imports: | // Special case for gathering all possible imports: | |||
// if we put * in the tags map then all tags | // if we put * in the tags map then all tags | |||
// except "ignore" are considered both present and not | // except "ignore" are considered both present and not | |||
// (so we return true no matter how 'want' is set). | // (so we return true no matter how 'want' is set). | |||
return prefer | return prefer | |||
} | } | |||
have := tags[name] | if tags[name] { | |||
if name == "linux" { | return true | |||
have = have || tags["android"] | ||||
} | ||||
if name == "solaris" { | ||||
have = have || tags["illumos"] | ||||
} | } | |||
if name == "darwin" { | ||||
have = have || tags["ios"] | switch name { | |||
case "linux": | ||||
return tags["android"] | ||||
case "solaris": | ||||
return tags["illumos"] | ||||
case "darwin": | ||||
return tags["ios"] | ||||
case "unix": | ||||
return unixOS[cfg.BuildContext.GOOS] | ||||
default: | ||||
return false | ||||
} | } | |||
return have | ||||
} | } | |||
// eval is like | // eval is like | |||
// | // | |||
// x.Eval(func(tag string) bool { return matchTag(tag, tags) }) | // x.Eval(func(tag string) bool { return matchTag(tag, tags) }) | |||
// | // | |||
// except that it implements the special case for tags["*"] meaning | // except that it implements the special case for tags["*"] meaning | |||
// all tags are both true and false at the same time. | // all tags are both true and false at the same time. | |||
func eval(x constraint.Expr, tags map[string]bool, prefer bool) bool { | func eval(x constraint.Expr, tags map[string]bool, prefer bool) bool { | |||
switch x := x.(type) { | switch x := x.(type) { | |||
skipping to change at line 325 | skipping to change at line 331 | |||
"linux": true, | "linux": true, | |||
"nacl": true, // legacy; don't remove | "nacl": true, // legacy; don't remove | |||
"netbsd": true, | "netbsd": true, | |||
"openbsd": true, | "openbsd": true, | |||
"plan9": true, | "plan9": true, | |||
"solaris": true, | "solaris": true, | |||
"windows": true, | "windows": true, | |||
"zos": true, | "zos": true, | |||
} | } | |||
// unixOS is the set of GOOS values matched by the "unix" build tag. | ||||
// This is not used for filename matching. | ||||
// This is the same list as in go/build/syslist.go and cmd/dist/build.go. | ||||
var unixOS = map[string]bool{ | ||||
"aix": true, | ||||
"android": true, | ||||
"darwin": true, | ||||
"dragonfly": true, | ||||
"freebsd": true, | ||||
"hurd": true, | ||||
"illumos": true, | ||||
"ios": true, | ||||
"linux": true, | ||||
"netbsd": true, | ||||
"openbsd": true, | ||||
"solaris": true, | ||||
} | ||||
var KnownArch = map[string]bool{ | var KnownArch = map[string]bool{ | |||
"386": true, | "386": true, | |||
"amd64": true, | "amd64": true, | |||
"amd64p32": true, // legacy; don't remove | "amd64p32": true, // legacy; don't remove | |||
"arm": true, | "arm": true, | |||
"armbe": true, | "armbe": true, | |||
"arm64": true, | "arm64": true, | |||
"arm64be": true, | "arm64be": true, | |||
"ppc64": true, | "ppc64": true, | |||
"ppc64le": true, | "ppc64le": true, | |||
End of changes. 5 change blocks. | ||||
9 lines changed or deleted | 33 lines changed or added |