mirror of
https://github.com/golang/go
synced 2024-11-24 18:30:16 -07:00
cmd/dist, go/build: make cmd/dist generate cgoEnabled map for go/build
This reduces the amount of duplication. Now there is only one list of platforms supporting cgo. Update #12270. Change-Id: I5dcd55cb6be7c5bb6ce560383c71d90ab1189dc9 Reviewed-on: https://go-review.googlesource.com/14278 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
1e4e09612c
commit
733cae6acd
6
src/cmd/dist/build.go
vendored
6
src/cmd/dist/build.go
vendored
@ -463,6 +463,9 @@ var deptab = []struct {
|
||||
{"runtime/internal/sys", []string{
|
||||
"zversion.go",
|
||||
}},
|
||||
{"go/build", []string{
|
||||
"zcgo.go",
|
||||
}},
|
||||
}
|
||||
|
||||
// depsuffix records the allowed suffixes for source files.
|
||||
@ -478,6 +481,7 @@ var gentab = []struct {
|
||||
}{
|
||||
{"zdefaultcc.go", mkzdefaultcc},
|
||||
{"zversion.go", mkzversion},
|
||||
{"zcgo.go", mkzcgo},
|
||||
|
||||
// not generated anymore, but delete the file if we see it
|
||||
{"enam.c", nil},
|
||||
@ -1061,9 +1065,9 @@ func cmdbootstrap() {
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from go/build/build.go.
|
||||
// Cannot use go/build directly because cmd/dist for a new release
|
||||
// builds against an old release's go/build, which may be out of sync.
|
||||
// To reduce duplication, we generate the list for go/build from this.
|
||||
var cgoEnabled = map[string]bool{
|
||||
"darwin/386": true,
|
||||
"darwin/amd64": true,
|
||||
|
28
src/cmd/dist/buildgo.go
vendored
28
src/cmd/dist/buildgo.go
vendored
@ -4,7 +4,10 @@
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
/*
|
||||
* Helpers for building cmd/go and cmd/cgo.
|
||||
@ -37,3 +40,26 @@ func mkzdefaultcc(dir, file string) {
|
||||
file = file[:i] + "c" + file[i:]
|
||||
writefile(out, file, writeSkipSame)
|
||||
}
|
||||
|
||||
// mkzcgo writes zcgo.go for go/build package:
|
||||
//
|
||||
// package build
|
||||
// var cgoEnabled = map[string]bool{}
|
||||
//
|
||||
// It is invoked to write go/build/zcgo.go.
|
||||
func mkzcgo(dir, file string) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
fmt.Fprintf(&buf,
|
||||
"// auto generated by go tool dist\n"+
|
||||
"\n"+
|
||||
"package build\n"+
|
||||
"\n"+
|
||||
"var cgoEnabled = map[string]bool{\n")
|
||||
for plat := range cgoEnabled {
|
||||
fmt.Fprintf(&buf, "\t%q: true,\n", plat)
|
||||
}
|
||||
fmt.Fprintf(&buf, "}")
|
||||
|
||||
writefile(buf.String(), file, writeSkipSame)
|
||||
}
|
||||
|
@ -256,34 +256,6 @@ func (ctxt *Context) SrcDirs() []string {
|
||||
// if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
|
||||
var Default Context = defaultContext()
|
||||
|
||||
// Also known to cmd/dist/build.go.
|
||||
var cgoEnabled = map[string]bool{
|
||||
"darwin/386": true,
|
||||
"darwin/amd64": true,
|
||||
"darwin/arm": true,
|
||||
"darwin/arm64": true,
|
||||
"dragonfly/amd64": true,
|
||||
"freebsd/386": true,
|
||||
"freebsd/amd64": true,
|
||||
"freebsd/arm": true,
|
||||
"linux/386": true,
|
||||
"linux/amd64": true,
|
||||
"linux/arm": true,
|
||||
"linux/arm64": true,
|
||||
"linux/ppc64le": true,
|
||||
"android/386": true,
|
||||
"android/amd64": true,
|
||||
"android/arm": true,
|
||||
"netbsd/386": true,
|
||||
"netbsd/amd64": true,
|
||||
"netbsd/arm": true,
|
||||
"openbsd/386": true,
|
||||
"openbsd/amd64": true,
|
||||
"solaris/amd64": true,
|
||||
"windows/386": true,
|
||||
"windows/amd64": true,
|
||||
}
|
||||
|
||||
func defaultContext() Context {
|
||||
var c Context
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user