Skip to content

Commit

Permalink
cmd/release: don't include godoc in releases in Go 1.13+
Browse files Browse the repository at this point in the history
Tested that it's still present in Go 1.12:

$ release -version=go1.12.999 -target=linux-amd64 -watch -skip_tests -rev=release-branch.go1.12 -tools=release-branch.go1.12 -net=release-branch.go1.12
...
$ ls -lh go1.12.999.linux-amd64.tar.gz
-rw-r--r-- 1 bradfitz bradfitz 122M Apr 29 19:28 go1.12.999.linux-amd64.tar.gz
$ tar -ztf go1.12.999.linux-amd64.tar.gz | grep godoc
go/bin/godoc
go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread
go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread.string

But not with Go 1.13:

$ release -version=go1.13beta0 -target=linux-amd64 -watch -skip_tests -rev=8c1f78524e421ac01e35e8805dd7a45bf98c2a79
...
$ ls -lh go1.13beta0.linux-amd64.tar.gz
-rw-r--r-- 1 bradfitz bradfitz 115M Apr 29 19:00 go1.13beta0.linux-amd64.tar.gz
$ tar -ztf go1.13beta0.linux-amd64.tar.gz | grep godoc
$

Fixes golang/go#30029
Updates golang/go#27151

Change-Id: I9ac5c1b2bc76f184bf05fdcac86bb2e37b57c77c
Reviewed-on: https://go-review.googlesource.com/c/build/+/174322
Reviewed-by: Dmitri Shuralyov <[email protected]>
  • Loading branch information
bradfitz committed Apr 29, 2019
1 parent 61a567e commit 5bd9893
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
36 changes: 26 additions & 10 deletions cmd/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ func main() {
}

if (*rev == "" && *tarball == "") || (*rev != "" && *tarball != "") {
log.Fatal("must specify one of -rev and -tarball")
}
if *toolsRev == "" {
log.Fatal("must specify -tools flag")
log.Fatal("must specify one of -rev or -tarball")
}
if *version == "" {
log.Fatal("must specify -version flag")
log.Fatal(`must specify -version flag (such as "go1.12" or "go1.13beta1")`)
}
if *toolsRev == "" && (versionIncludesGodoc(*version) || versionIncludesTour(*version)) {
log.Fatal("must specify -tools flag")
}

coordClient = coordinatorClient()
Expand Down Expand Up @@ -317,6 +317,9 @@ func (b *Build) make() error {
if r.repo == "tour" && !versionIncludesTour(*version) {
continue
}
if (r.repo == "net" || r.repo == "tools") && !versionIncludesGodoc(*version) {
continue
}
dir := goPath + "/src/golang.org/x/" + r.repo
tar := "https://go.googlesource.com/" + r.repo + "/+archive/" + r.rev + ".tar.gz"
if err := client.PutTarFromURL(tar, dir); err != nil {
Expand Down Expand Up @@ -442,15 +445,18 @@ func (b *Build) make() error {
}
}

toolPaths := []string{
"golang.org/x/tools/cmd/godoc",
var toolPaths []string
if versionIncludesGodoc(*version) {
toolPaths = append(toolPaths, "golang.org/x/tools/cmd/godoc")
}
if versionIncludesTour(*version) {
toolPaths = append(toolPaths, "golang.org/x/tour")
}
b.logf("Building %v.", strings.Join(toolPaths, ", "))
if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
return err
if len(toolPaths) > 0 {
b.logf("Building %v.", strings.Join(toolPaths, ", "))
if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
return err
}
}

// postBuildCleanFiles are the list of files to remove in the go/ directory
Expand Down Expand Up @@ -839,3 +845,13 @@ func versionIncludesTour(goVer string) bool {
return strings.HasPrefix(goVer, "go1.10.") ||
strings.HasPrefix(goVer, "go1.11.")
}

// versionIncludesGodoc reports whether the provided Go version (of the
// form "go1.N" or "go1.N.M" includes the godoc binary.
func versionIncludesGodoc(goVer string) bool {
// We don't do releases of Go 1.10 and earlier, so this only
// needs to recognize the two current past releases. From Go
// 1.13 and on, we won't ship the godoc binary (see Issue 30029).
return strings.HasPrefix(goVer, "go1.11.") ||
strings.HasPrefix(goVer, "go1.12.")
}
10 changes: 10 additions & 0 deletions cmd/release/releaselet.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ func archDir() string {
return ""
}

// godoc copies the godoc binary into place for Go 1.12 and earlier.
//
// TODO: remove this function once Go 1.14 is released (when Go 1.12
// is no longer supported).
func godoc() error {
_, version, _ := environ()
verMajor, verMinor, _ := splitVersion(version)
if verMajor > 1 || verMinor >= 13 {
return nil // Only include the godoc binary in go1.12.x and earlier releases; Issue 30029
}

// Pre Go 1.7, the godoc binary is placed here by cmd/go.
// After Go 1.7, we need to copy the binary from GOPATH/bin to GOROOT/bin.
// TODO(cbro): Remove after Go 1.6 is no longer supported.
Expand Down

0 comments on commit 5bd9893

Please sign in to comment.