1
0
mirror of https://github.com/golang/go synced 2024-11-25 03:07:56 -07:00

builder: Allow buildroot to be passed as command-line argument

R=adg
CC=golang-dev
https://golang.org/cl/3473041
This commit is contained in:
Devon H. O'Dell 2010-12-06 10:34:39 +11:00 committed by Andrew Gerrand
parent dbcf79b4b9
commit dfd98d090c

View File

@ -37,6 +37,7 @@ type BenchRequest struct {
} }
var ( 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") dashboard = flag.String("dashboard", "godashboard.appspot.com", "Go Dashboard Host")
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")
@ -45,8 +46,7 @@ var (
) )
var ( var (
buildroot = path.Join(os.TempDir(), "gobuilder") goroot string
goroot = path.Join(buildroot, "goroot")
releaseRegexp = regexp.MustCompile(`^release\.[0-9\-]+`) releaseRegexp = regexp.MustCompile(`^release\.[0-9\-]+`)
benchRequests vector.Vector benchRequests vector.Vector
) )
@ -61,6 +61,7 @@ func main() {
if len(flag.Args()) == 0 { if len(flag.Args()) == 0 {
flag.Usage() flag.Usage()
} }
goroot = path.Join(*buildroot, "goroot")
builders := make([]*Builder, len(flag.Args())) builders := make([]*Builder, len(flag.Args()))
for i, builder := range flag.Args() { for i, builder := range flag.Args() {
b, err := NewBuilder(builder) b, err := NewBuilder(builder)
@ -69,13 +70,13 @@ func main() {
} }
builders[i] = b builders[i] = b
} }
if err := os.RemoveAll(buildroot); err != nil { if err := os.RemoveAll(*buildroot); err != nil {
log.Exitf("Error removing build root (%s): %s", buildroot, err) log.Exitf("Error removing build root (%s): %s", *buildroot, err)
} }
if err := os.Mkdir(buildroot, mkdirPerm); err != nil { if err := os.Mkdir(*buildroot, mkdirPerm); err != nil {
log.Exitf("Error making build root (%s): %s", buildroot, err) 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) log.Exit("Error cloning repository:", err)
} }
// if specified, build revision and return // 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) log.Println(b.name, "building", c.num)
// create place in which to do work // 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) err = os.Mkdir(workpath, mkdirPerm)
if err != nil { if err != nil {
return return