From e86c0676cf90109094c8ff09e83b56492c1e628b Mon Sep 17 00:00:00 2001 From: Marvin Stenger Date: Thu, 31 Aug 2017 12:27:53 +0200 Subject: [PATCH] cmd/dist: use standard generated code header This belongs to a series of clean-up changes (see below) for cmd/dist. This is change (4). These changes include: (1) apply minor fixes (2) restore behavior of branchtag (3) unleash bootstrap optimization for windows (4) use standard generated code header (5) remove trivial variables + functions (6) move functions for the better (7) simplify code segments (8) use bytes.Buffer for code generation (9) rename variables + functions (10) remove doc.go Change-Id: I5e163f89a518f074e58bf2d44597e553c918d7e6 Reviewed-on: https://go-review.googlesource.com/61010 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/dist/buildgo.go | 8 ++++---- src/cmd/dist/buildruntime.go | 4 ++-- src/cmd/dist/buildtool.go | 6 ++++-- src/cmd/dist/deps.go | 2 +- src/cmd/dist/mkdeps.bash | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cmd/dist/buildgo.go b/src/cmd/dist/buildgo.go index 105451bbda..79a9efba9c 100644 --- a/src/cmd/dist/buildgo.go +++ b/src/cmd/dist/buildgo.go @@ -26,7 +26,7 @@ import ( // but we also write cmd/cgo/zdefaultcc.go func mkzdefaultcc(dir, file string) { outGo := fmt.Sprintf( - "// auto generated by go tool dist\n"+ + "// Code generated by go tool dist; DO NOT EDIT.\n"+ "\n"+ "package cfg\n"+ "\n"+ @@ -39,7 +39,7 @@ func mkzdefaultcc(dir, file string) { // Convert file name to replace: turn go/internal/cfg into cgo. outCgo := fmt.Sprintf( - "// auto generated by go tool dist\n"+ + "// Code generated by go tool dist; DO NOT EDIT.\n"+ "\n"+ "package main\n"+ "\n"+ @@ -63,7 +63,7 @@ func mkzosarch(dir, file string) { sort.Strings(list) var buf bytes.Buffer - buf.WriteString("// auto generated by go tool dist\n\n") + buf.WriteString("// Code generated by go tool dist; DO NOT EDIT.\n\n") buf.WriteString("package cfg\n\n") fmt.Fprintf(&buf, "var OSArchSupportsCgo = map[string]bool{\n") for _, plat := range list { @@ -92,7 +92,7 @@ func mkzcgo(dir, file string) { var buf bytes.Buffer fmt.Fprintf(&buf, - "// auto generated by go tool dist\n"+ + "// Code generated by go tool dist; DO NOT EDIT.\n"+ "\n"+ "package build\n"+ "\n"+ diff --git a/src/cmd/dist/buildruntime.go b/src/cmd/dist/buildruntime.go index 1467c59c6c..b885a79228 100644 --- a/src/cmd/dist/buildruntime.go +++ b/src/cmd/dist/buildruntime.go @@ -24,7 +24,7 @@ import ( // func mkzversion(dir, file string) { out := fmt.Sprintf( - "// auto generated by go tool dist\n"+ + "// Code generated by go tool dist; DO NOT EDIT.\n"+ "\n"+ "package sys\n"+ "\n"+ @@ -61,7 +61,7 @@ func mkzversion(dir, file string) { // original target (in this example, a Mac). func mkzbootstrap(file string) { out := fmt.Sprintf( - "// auto generated by go tool dist\n"+ + "// Code generated by go tool dist; DO NOT EDIT.\n"+ "\n"+ "package objabi\n"+ "\n"+ diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index 77cf41a3eb..52307a3dc4 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -227,7 +227,9 @@ func bootstrapRewriteFile(text, srcFile string) string { // binary that works for the current runtime.GOARCH. // This saves 6+ seconds of bootstrap. if archCaps, ok := isUnneededSSARewriteFile(srcFile); ok { - return fmt.Sprintf(`package ssa + return fmt.Sprintf(`// Code generated by go tool dist; DO NOT EDIT. + +package ssa func rewriteValue%s(v *Value) bool { panic("unused during bootstrap") } func rewriteBlock%s(b *Block) bool { panic("unused during bootstrap") } @@ -262,7 +264,7 @@ func bootstrapFixImports(text, srcFile string) string { } } - lines[0] = "// Do not edit. Bootstrap copy of " + srcFile + "\n\n//line " + srcFile + ":1\n" + lines[0] + lines[0] = "// Code generated by go tool dist; DO NOT EDIT.\n// This is a bootstrap copy of " + srcFile + "\n\n//line " + srcFile + ":1\n" + lines[0] return strings.Join(lines, "") } diff --git a/src/cmd/dist/deps.go b/src/cmd/dist/deps.go index 6e2169d6b6..f0de27b79c 100644 --- a/src/cmd/dist/deps.go +++ b/src/cmd/dist/deps.go @@ -1,4 +1,4 @@ -// generated by mkdeps.bash +// Code generated by mkdeps.bash; DO NOT EDIT. package main diff --git a/src/cmd/dist/mkdeps.bash b/src/cmd/dist/mkdeps.bash index 37ce6d6719..fe7611a5c6 100755 --- a/src/cmd/dist/mkdeps.bash +++ b/src/cmd/dist/mkdeps.bash @@ -32,7 +32,7 @@ all="$(deps_of cmd/go | awk '{print $2}') cmd/go" deps_of $all >tmp.all.deps ( - echo '// generated by mkdeps.bash' + echo '// Code generated by mkdeps.bash; DO NOT EDIT.' echo echo 'package main' echo