Commit b60e61ab authored by Russ Cox's avatar Russ Cox

cmd/dist: move cmd/go z files to cmd/go/internal/cfg

This is one CL in a long sequence of changes to break up the
go command from one package into a plausible group of packages.

This sequence is concerned only with moving code, not changing
or cleaning up code. There will still be more cleanup after this sequence.

The entire sequence will be submitted together: it is not a goal
for the tree to build at every step.

For #18653.

Change-Id: I6ee5b053683034ea9462a9a0a4ea4f5ad24fa5a1
Reviewed-on: https://go-review.googlesource.com/36192Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent a918864c
...@@ -31,8 +31,8 @@ _testmain.go ...@@ -31,8 +31,8 @@ _testmain.go
/pkg/ /pkg/
/src/*.*/ /src/*.*/
/src/cmd/cgo/zdefaultcc.go /src/cmd/cgo/zdefaultcc.go
/src/cmd/go/zdefaultcc.go /src/cmd/go/internal/cfg/zdefaultcc.go
/src/cmd/go/zosarch.go /src/cmd/go/internal/cfg/zosarch.go
/src/cmd/internal/obj/zbootstrap.go /src/cmd/internal/obj/zbootstrap.go
/src/go/build/zcgo.go /src/go/build/zcgo.go
/src/go/doc/headscan /src/go/doc/headscan
......
...@@ -471,7 +471,7 @@ var deptab = []struct { ...@@ -471,7 +471,7 @@ var deptab = []struct {
prefix string // prefix of target prefix string // prefix of target
dep []string // dependency tweaks for targets with that prefix dep []string // dependency tweaks for targets with that prefix
}{ }{
{"cmd/go", []string{ {"cmd/go/internal/cfg", []string{
"zdefaultcc.go", "zdefaultcc.go",
"zosarch.go", "zosarch.go",
}}, }},
...@@ -543,7 +543,7 @@ func install(dir string) { ...@@ -543,7 +543,7 @@ func install(dir string) {
path := pathf("%s/src/%s", goroot, dir) path := pathf("%s/src/%s", goroot, dir)
name := filepath.Base(dir) name := filepath.Base(dir)
ispkg := !strings.HasPrefix(dir, "cmd/") || strings.HasPrefix(dir, "cmd/internal/") || strings.HasPrefix(dir, "cmd/asm/internal/") ispkg := !strings.HasPrefix(dir, "cmd/") || strings.Contains(dir, "/internal/")
// Start final link command line. // Start final link command line.
// Note: code below knows that link.p[targ] is the target. // Note: code below knows that link.p[targ] is the target.
......
...@@ -25,7 +25,20 @@ import ( ...@@ -25,7 +25,20 @@ import (
// It is invoked to write cmd/go/zdefaultcc.go // It is invoked to write cmd/go/zdefaultcc.go
// but we also write cmd/cgo/zdefaultcc.go // but we also write cmd/cgo/zdefaultcc.go
func mkzdefaultcc(dir, file string) { func mkzdefaultcc(dir, file string) {
out := fmt.Sprintf( outGo := fmt.Sprintf(
"// auto generated by go tool dist\n"+
"\n"+
"package cfg\n"+
"\n"+
"const DefaultCC = `%s`\n"+
"const DefaultCXX = `%s`\n"+
"const DefaultPkgConfig = `%s`\n",
defaultcctarget, defaultcxxtarget, defaultpkgconfigtarget)
writefile(outGo, file, writeSkipSame)
// Convert file name to replace: turn go/internal/cfg into cgo.
outCgo := fmt.Sprintf(
"// auto generated by go tool dist\n"+ "// auto generated by go tool dist\n"+
"\n"+ "\n"+
"package main\n"+ "package main\n"+
...@@ -35,12 +48,9 @@ func mkzdefaultcc(dir, file string) { ...@@ -35,12 +48,9 @@ func mkzdefaultcc(dir, file string) {
"const defaultPkgConfig = `%s`\n", "const defaultPkgConfig = `%s`\n",
defaultcctarget, defaultcxxtarget, defaultpkgconfigtarget) defaultcctarget, defaultcxxtarget, defaultpkgconfigtarget)
writefile(out, file, writeSkipSame) i := len(file) - len("go/internal/cfg/zdefaultcc.go")
file = file[:i] + "cgo/zdefaultcc.go"
// Convert file name to replace: turn go into cgo. writefile(outCgo, file, writeSkipSame)
i := len(file) - len("go/zdefaultcc.go")
file = file[:i] + "c" + file[i:]
writefile(out, file, writeSkipSame)
} }
// mkzcgo writes zosarch.go for cmd/go. // mkzcgo writes zosarch.go for cmd/go.
...@@ -54,8 +64,8 @@ func mkzosarch(dir, file string) { ...@@ -54,8 +64,8 @@ func mkzosarch(dir, file string) {
var buf bytes.Buffer var buf bytes.Buffer
buf.WriteString("// auto generated by go tool dist\n\n") buf.WriteString("// auto generated by go tool dist\n\n")
buf.WriteString("package main\n\n") buf.WriteString("package cfg\n\n")
fmt.Fprintf(&buf, "var osArchSupportsCgo = map[string]bool{\n") fmt.Fprintf(&buf, "var OSArchSupportsCgo = map[string]bool{\n")
for _, plat := range list { for _, plat := range list {
fmt.Fprintf(&buf, "\t%q: %v,\n", plat, cgoEnabled[plat]) fmt.Fprintf(&buf, "\t%q: %v,\n", plat, cgoEnabled[plat])
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment