FAQ
Reviewers: minux, adg,

Message:
Hello minux.ma@gmail.com, adg@golang.org (cc:
golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
misc/dashboard/builder: set GOPATH before building subrepos

This proposal updates the dashboard builder to avoid relying on the
(soon to be removed) support for using go get to download to $GOROOT.
The result is

WORKSPACE=$(the value of the -buildRoot flag + hg revision)
GOROOT=$WORKSPACE/go
GOPATH=$WORKSPACE

Required for CL 6941058.

Please review this at https://codereview.appspot.com/7034049/

Affected files:
M misc/dashboard/builder/main.go


Index: misc/dashboard/builder/main.go
===================================================================
--- a/misc/dashboard/builder/main.go
+++ b/misc/dashboard/builder/main.go
@@ -281,7 +281,9 @@
}

// build Go sub-repositories
- b.buildSubrepos(filepath.Join(workpath, "go"), hash)
+ goRoot := filepath.Join(workpath, "go")
+ goPath := workpath
+ b.buildSubrepos(goRoot, goPath, hash)

return nil
}
@@ -307,7 +309,7 @@
return true
}

-func (b *Builder) buildSubrepos(goRoot, goHash string) {
+func (b *Builder) buildSubrepos(goRoot, goPath, goHash string) {
for _, pkg := range dashboardPackages("subrepo") {
// get the latest todo for this package
hash, err := b.todo("build-package", pkg, goHash)
@@ -323,7 +325,7 @@
if *verbose {
log.Printf("buildSubrepos %s: building %q", pkg, hash)
}
- buildLog, err := b.buildSubrepo(goRoot, pkg, hash)
+ buildLog, err := b.buildSubrepo(goRoot, goPath, pkg, hash)
if err != nil {
if buildLog == "" {
buildLog = err.Error()
@@ -341,43 +343,39 @@

// buildSubrepo fetches the given package, updates it to the specified
hash,
// and runs 'go test -short pkg/...'. It returns the build log and any
error.
-func (b *Builder) buildSubrepo(goRoot, pkg, hash string) (string, error) {
- goBin := filepath.Join(goRoot, "bin")
- goTool := filepath.Join(goBin, "go")
- env := append(b.envv(), "GOROOT="+goRoot)
+func (b *Builder) buildSubrepo(goRoot, goPath, pkg, hash string) (string,
error) {
+ goTool := filepath.Join(goRoot, "bin", "go")
+ env := append(b.envv(), "GOROOT="+goRoot, "GOPATH="+goPath)

- // add goBin to PATH
+ // add $GOROOT/bin and $GOPATH/bin to PATH
for i, e := range env {
const p = "PATH="
if !strings.HasPrefix(e, p) {
continue
}
- env[i] = p + goBin + string(os.PathListSeparator) + e[len(p):]
+ env[i] = p +
+ filepath.Join(goRoot, "bin") + string(os.PathListSeparator) +
+ filepath.Join(goPath, "bin") + string(os.PathListSeparator) +
+ e[len(p):]
}

// fetch package and dependencies
- log, status, err := runLog(*cmdTimeout, env, "", goRoot,
goTool, "get", "-d", pkg)
+ log, status, err := runLog(*cmdTimeout, env, "", goPath,
goTool, "get", "-d", pkg+"/...")
if err == nil && status != 0 {
err = fmt.Errorf("go exited with status %d", status)
}
if err != nil {
- // 'go get -d' will fail for a subrepo because its top-level
- // directory does not contain a go package. No matter, just
- // check whether an hg directory exists and proceed.
- hgDir := filepath.Join(goRoot, "src/pkg", pkg, ".hg")
- if fi, e := os.Stat(hgDir); e != nil || !fi.IsDir() {
- return log, err
- }
+ return log, err
}

// hg update to the specified hash
- pkgPath := filepath.Join(goRoot, "src/pkg", pkg)
+ pkgPath := filepath.Join(goPath, "src/pkg", pkg)
if err := run(*cmdTimeout, nil, pkgPath, hgCmd("update", hash)...);
err != nil {
return "", err
}

// test the package
- log, status, err = runLog(*buildTimeout, env, "", goRoot,
goTool, "test", "-short", pkg+"/...")
+ log, status, err = runLog(*buildTimeout, env, "", goPath,
goTool, "test", "-short", pkg+"/...")
if err == nil && status != 0 {
err = fmt.Errorf("go exited with status %d", status)
}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJan 3, '13 at 10:18p
activeJan 3, '13 at 10:18p
posts1
users1
websitegolang.org

1 user in discussion

Dave: 1 post

People

Translate

site design / logo © 2021 Grokbase