mirror of
https://github.com/golang/go
synced 2024-11-24 21:10:04 -07:00
misc/dashboard/builder: -cmd for user-specified build command
R=rsc CC=golang-dev https://golang.org/cl/2248043
This commit is contained in:
parent
a071853015
commit
96d6f9dea4
@ -4,11 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"exec"
|
"exec"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// run is a simple wrapper for exec.Run/Close
|
// run is a simple wrapper for exec.Run/Close
|
||||||
func run(envv []string, dir string, argv ...string) os.Error {
|
func run(envv []string, dir string, argv ...string) os.Error {
|
||||||
bin, err := exec.LookPath(argv[0])
|
bin, err := pathLookup(argv[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -22,7 +23,7 @@ func run(envv []string, dir string, argv ...string) os.Error {
|
|||||||
|
|
||||||
// runLog runs a process and returns the combined stdout/stderr
|
// runLog runs a process and returns the combined stdout/stderr
|
||||||
func runLog(envv []string, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
|
func runLog(envv []string, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
|
||||||
bin, err := exec.LookPath(argv[0])
|
bin, err := pathLookup(argv[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -43,3 +44,11 @@ func runLog(envv []string, dir string, argv ...string) (output string, exitStatu
|
|||||||
}
|
}
|
||||||
return b.String(), w.WaitStatus.ExitStatus(), nil
|
return b.String(), w.WaitStatus.ExitStatus(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find bin in PATH if a relative or absolute path hasn't been specified
|
||||||
|
func pathLookup(s string) (string, os.Error) {
|
||||||
|
if strings.HasPrefix(s, "/") || strings.HasPrefix(s, "./") || strings.HasPrefix(s, "../") {
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
return exec.LookPath(s)
|
||||||
|
}
|
||||||
|
@ -41,6 +41,7 @@ var (
|
|||||||
runBenchmarks = flag.Bool("bench", false, "Run benchmarks")
|
runBenchmarks = flag.Bool("bench", false, "Run benchmarks")
|
||||||
buildRelease = flag.Bool("release", false, "Build and upload binary release archives")
|
buildRelease = flag.Bool("release", false, "Build and upload binary release archives")
|
||||||
buildRevision = flag.String("rev", "", "Build specified revision and exit")
|
buildRevision = flag.String("rev", "", "Build specified revision and exit")
|
||||||
|
buildCmd = flag.String("cmd", "./all.bash", "Build command (specify absolute or relative to go/src/)")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -265,17 +266,8 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) {
|
|||||||
}
|
}
|
||||||
srcDir := path.Join(workpath, "go", "src")
|
srcDir := path.Join(workpath, "go", "src")
|
||||||
|
|
||||||
// check for all-${GOARCH,GOOS}.bash and use it if found
|
|
||||||
allbash := "all.bash"
|
|
||||||
if a := "all-"+b.goarch+".bash"; isFile(path.Join(srcDir, a)) {
|
|
||||||
allbash = a
|
|
||||||
}
|
|
||||||
if a := "all-"+b.goos+".bash"; isFile(path.Join(srcDir, a)) {
|
|
||||||
allbash = a
|
|
||||||
}
|
|
||||||
|
|
||||||
// build
|
// build
|
||||||
buildLog, status, err := runLog(env, srcDir, "bash", allbash)
|
buildLog, status, err := runLog(env, srcDir, *buildCmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errf("all.bash: %s", err)
|
return errf("all.bash: %s", err)
|
||||||
}
|
}
|
||||||
@ -307,7 +299,7 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) {
|
|||||||
// if this is a release, create tgz and upload to google code
|
// if this is a release, create tgz and upload to google code
|
||||||
if release := releaseRegexp.FindString(c.desc); release != "" {
|
if release := releaseRegexp.FindString(c.desc); release != "" {
|
||||||
// clean out build state
|
// clean out build state
|
||||||
err = run(env, srcDir, "sh", "clean.bash", "--nopkg")
|
err = run(env, srcDir, "./clean.bash", "--nopkg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errf("clean.bash: %s", err)
|
return errf("clean.bash: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user