From dfd98d090c73530140621dff3ef49fd1139aa89a Mon Sep 17 00:00:00 2001 From: "Devon H. O'Dell" Date: Mon, 6 Dec 2010 10:34:39 +1100 Subject: [PATCH] builder: Allow buildroot to be passed as command-line argument R=adg CC=golang-dev https://golang.org/cl/3473041 --- misc/dashboard/builder/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/misc/dashboard/builder/main.go b/misc/dashboard/builder/main.go index 2b8b855dd7a..89be52792ea 100644 --- a/misc/dashboard/builder/main.go +++ b/misc/dashboard/builder/main.go @@ -37,6 +37,7 @@ type BenchRequest struct { } var ( + buildroot = flag.String("buildroot", path.Join(os.TempDir(), "gobuilder"), "Directory under which to build") dashboard = flag.String("dashboard", "godashboard.appspot.com", "Go Dashboard Host") runBenchmarks = flag.Bool("bench", false, "Run benchmarks") buildRelease = flag.Bool("release", false, "Build and upload binary release archives") @@ -45,8 +46,7 @@ var ( ) var ( - buildroot = path.Join(os.TempDir(), "gobuilder") - goroot = path.Join(buildroot, "goroot") + goroot string releaseRegexp = regexp.MustCompile(`^release\.[0-9\-]+`) benchRequests vector.Vector ) @@ -61,6 +61,7 @@ func main() { if len(flag.Args()) == 0 { flag.Usage() } + goroot = path.Join(*buildroot, "goroot") builders := make([]*Builder, len(flag.Args())) for i, builder := range flag.Args() { b, err := NewBuilder(builder) @@ -69,13 +70,13 @@ func main() { } builders[i] = b } - if err := os.RemoveAll(buildroot); err != nil { - log.Exitf("Error removing build root (%s): %s", buildroot, err) + if err := os.RemoveAll(*buildroot); err != nil { + log.Exitf("Error removing build root (%s): %s", *buildroot, err) } - if err := os.Mkdir(buildroot, mkdirPerm); err != nil { - log.Exitf("Error making build root (%s): %s", buildroot, err) + if err := os.Mkdir(*buildroot, mkdirPerm); err != nil { + log.Exitf("Error making build root (%s): %s", *buildroot, err) } - if err := run(nil, buildroot, "hg", "clone", hgUrl, goroot); err != nil { + if err := run(nil, *buildroot, "hg", "clone", hgUrl, goroot); err != nil { log.Exit("Error cloning repository:", err) } // if specified, build revision and return @@ -236,7 +237,7 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) { log.Println(b.name, "building", c.num) // create place in which to do work - workpath := path.Join(buildroot, b.name+"-"+strconv.Itoa(c.num)) + workpath := path.Join(*buildroot, b.name+"-"+strconv.Itoa(c.num)) err = os.Mkdir(workpath, mkdirPerm) if err != nil { return