mirror of
https://github.com/golang/go
synced 2024-11-12 09:20:22 -07:00
misc/dist: include godoc from go.tools
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12075045
This commit is contained in:
parent
c8d49cf56f
commit
87380415e0
58
misc/dist/bindist.go
vendored
58
misc/dist/bindist.go
vendored
@ -31,7 +31,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
tag = flag.String("tag", "release", "mercurial tag to check out")
|
tag = flag.String("tag", "release", "mercurial tag to check out")
|
||||||
repo = flag.String("repo", "https://code.google.com/p/go", "repo URL")
|
repo = flag.String("repo", "https://code.google.com/p/go", "repo URL")
|
||||||
tourPath = flag.String("tour", "code.google.com/p/go-tour", "Go tour repo import path")
|
|
||||||
verbose = flag.Bool("v", false, "verbose output")
|
verbose = flag.Bool("v", false, "verbose output")
|
||||||
upload = flag.Bool("upload", true, "upload resulting files to Google Code")
|
upload = flag.Bool("upload", true, "upload resulting files to Google Code")
|
||||||
wxsFile = flag.String("wxs", "", "path to custom installer.wxs")
|
wxsFile = flag.String("wxs", "", "path to custom installer.wxs")
|
||||||
@ -44,6 +43,8 @@ var (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
uploadURL = "https://go.googlecode.com/files"
|
uploadURL = "https://go.googlecode.com/files"
|
||||||
|
godocPath = "code.google.com/p/go.tools/cmd/godoc"
|
||||||
|
tourPath = "code.google.com/p/go-tour"
|
||||||
)
|
)
|
||||||
|
|
||||||
var preBuildCleanFiles = []string{
|
var preBuildCleanFiles = []string{
|
||||||
@ -173,11 +174,11 @@ func (b *Build) Do() error {
|
|||||||
b.gopath = work
|
b.gopath = work
|
||||||
|
|
||||||
// Clone Go distribution and update to tag.
|
// Clone Go distribution and update to tag.
|
||||||
_, err = b.run(work, "hg", "clone", "-q", *repo, b.root)
|
_, err = b.hgCmd(work, "clone", *repo, b.root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = b.run(b.root, "hg", "update", *tag)
|
_, err = b.hgCmd(b.root, "update", *tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ func (b *Build) Do() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Re-install std without -race, so that we're not left
|
// Re-install std without -race, so that we're not left
|
||||||
// with a slower, race-enabled cmd/go, cmd/godoc, etc.
|
// with a slower, race-enabled cmd/go, etc.
|
||||||
_, err = b.run(src, goCmd, "install", "-a", "std")
|
_, err = b.run(src, goCmd, "install", "-a", "std")
|
||||||
// Re-building go command leaves old versions of go.exe as go.exe~ on windows.
|
// Re-building go command leaves old versions of go.exe as go.exe~ on windows.
|
||||||
// See (*builder).copyFile in $GOROOT/src/cmd/go/build.go for details.
|
// See (*builder).copyFile in $GOROOT/src/cmd/go/build.go for details.
|
||||||
@ -226,6 +227,10 @@ func (b *Build) Do() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = b.godoc()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
err = b.tour()
|
err = b.tour()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -408,6 +413,28 @@ func (b *Build) Do() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Build) godoc() error {
|
||||||
|
defer func() {
|
||||||
|
// Clean work files from GOPATH directory.
|
||||||
|
for _, d := range []string{"bin", "pkg", "src"} {
|
||||||
|
os.RemoveAll(filepath.Join(b.gopath, d))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// go get the godoc package.
|
||||||
|
// The go tool knows to install to $GOROOT/bin.
|
||||||
|
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", godocPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy templates from go.tools/cmd/godoc/template to GOROOT/lib/godoc.
|
||||||
|
return cpDir(
|
||||||
|
filepath.Join(b.root, "lib", "godoc"),
|
||||||
|
filepath.Join(b.gopath, "src", filepath.FromSlash(godocPath), "template"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Build) tour() error {
|
func (b *Build) tour() error {
|
||||||
defer func() {
|
defer func() {
|
||||||
// Clean work files from GOPATH directory.
|
// Clean work files from GOPATH directory.
|
||||||
@ -417,13 +444,13 @@ func (b *Build) tour() error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// go get the gotour package.
|
// go get the gotour package.
|
||||||
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", *tourPath+"/gotour")
|
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", tourPath+"/gotour")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy all the tour content to $GOROOT/misc/tour.
|
// Copy all the tour content to $GOROOT/misc/tour.
|
||||||
importPath := filepath.FromSlash(*tourPath)
|
importPath := filepath.FromSlash(tourPath)
|
||||||
tourSrc := filepath.Join(b.gopath, "src", importPath)
|
tourSrc := filepath.Join(b.gopath, "src", importPath)
|
||||||
contentDir := filepath.Join(b.root, "misc", "tour")
|
contentDir := filepath.Join(b.root, "misc", "tour")
|
||||||
if err = cpAllDir(contentDir, tourSrc, tourContent...); err != nil {
|
if err = cpAllDir(contentDir, tourSrc, tourContent...); err != nil {
|
||||||
@ -436,16 +463,23 @@ func (b *Build) tour() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy gotour binary to tool directory as "tour"; invoked as "go tool tour".
|
// Copy gotour binary to tool directory as "tour"; invoked as "go tool tour".
|
||||||
ext := ""
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
ext = ".exe"
|
|
||||||
}
|
|
||||||
return cp(
|
return cp(
|
||||||
filepath.Join(b.root, "pkg", "tool", b.OS+"_"+b.Arch, "tour"+ext),
|
filepath.Join(b.root, "pkg", "tool", b.OS+"_"+b.Arch, "tour"+ext()),
|
||||||
filepath.Join(b.gopath, "bin", "gotour"+ext),
|
filepath.Join(b.gopath, "bin", "gotour"+ext()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ext() string {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return ".exe"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Build) hgCmd(dir string, args ...string) ([]byte, error) {
|
||||||
|
return b.run(dir, "hg", append([]string{"--config", "extensions.codereview=!"}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Build) run(dir, name string, args ...string) ([]byte, error) {
|
func (b *Build) run(dir, name string, args ...string) ([]byte, error) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
absName, err := lookPath(name)
|
absName, err := lookPath(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user