1
0
mirror of https://github.com/golang/go synced 2024-11-22 17:54:45 -07:00

runtime/internal/sys: generate //go:build lines in gengoos.go

For #41184

Change-Id: If7a1c3980f47bc28d0a13fe497eaba6178c65c91
Reviewed-on: https://go-review.googlesource.com/c/go/+/323750
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Tobias Klauser 2021-06-01 12:22:12 +02:00 committed by Tobias Klauser
parent 84c0e5d47f
commit dc8f87b749

View File

@ -48,18 +48,21 @@ func main() {
if target == "nacl" {
continue
}
var buf bytes.Buffer
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
var tags []string
if target == "linux" {
fmt.Fprintf(&buf, "// +build !android\n") // must explicitly exclude android for linux
tags = append(tags, "!android") // must explicitly exclude android for linux
}
if target == "solaris" {
fmt.Fprintf(&buf, "// +build !illumos\n") // must explicitly exclude illumos for solaris
tags = append(tags, "!illumos") // must explicitly exclude illumos for solaris
}
if target == "darwin" {
fmt.Fprintf(&buf, "// +build !ios\n") // must explicitly exclude ios for darwin
tags = append(tags, "!ios") // must explicitly exclude ios for darwin
}
fmt.Fprintf(&buf, "// +build %s\n\n", target) // must explicitly include target for bootstrapping purposes
tags = append(tags, target) // must explicitly include target for bootstrapping purposes
var buf bytes.Buffer
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
fmt.Fprintf(&buf, "// +build %s\n\n", strings.Join(tags, ","))
fmt.Fprintf(&buf, "package sys\n\n")
fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
for _, goos := range gooses {
@ -81,6 +84,7 @@ func main() {
}
var buf bytes.Buffer
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
fmt.Fprintf(&buf, "//go:build %s\n", target)
fmt.Fprintf(&buf, "// +build %s\n\n", target) // must explicitly include target for bootstrapping purposes
fmt.Fprintf(&buf, "package sys\n\n")
fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)