aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-03-03 18:21:37 -0800
committerIan Lance Taylor <iant@golang.org>2022-03-28 22:28:20 +0000
commitc3fcd0117784ac05e35120ac0de6c960b400a31e (patch)
tree958cdaf2764787e38b2d5e3c0f895d586bda1176 /src/cmd/dist
parent32fdad19a246143ae4f194d1b39886d778de1380 (diff)
downloadgo-c3fcd0117784ac05e35120ac0de6c960b400a31e.tar.xz
go/build: recognize "unix" build tag
The new "unix" build tag matches any Unix or Unix-like system. This is only recognized on go:build lines, not in file names. For #20322 Fixes #51572 Change-Id: I3a991f9e69353b25e259bc6462709cdcd83640fb Reviewed-on: https://go-review.googlesource.com/c/go/+/389934 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/build.go37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index ba09ce9a7b..4dfaf83ef7 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -976,12 +976,41 @@ func packagefile(pkg string) string {
return pathf("%s/pkg/%s_%s/%s.a", goroot, goos, goarch, pkg)
}
+// unixOS is the set of GOOS values matched by the "unix" build tag.
+// This is the same list as in go/build/syslist.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,
+}
+
// matchtag reports whether the tag matches this build.
func matchtag(tag string) bool {
- return tag == "gc" || tag == goos || tag == goarch || tag == "cmd_go_bootstrap" || tag == "go1.1" ||
- (goos == "android" && tag == "linux") ||
- (goos == "illumos" && tag == "solaris") ||
- (goos == "ios" && tag == "darwin")
+ switch tag {
+ case "gc", "cmd_go_bootstrap", "go1.1":
+ return true
+ case "linux":
+ return goos == "linux" || goos == "android"
+ case "solaris":
+ return goos == "solaris" || goos == "illumos"
+ case "darwin":
+ return goos == "darwin" || goos == "ios"
+ case goos, goarch:
+ return true
+ case "unix":
+ return unixOS[goos]
+ default:
+ return false
+ }
}
// shouldbuild reports whether we should build this file.