From 1e868933c5aeb33027802dc65d4ff8cdc543ea77 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 27 Feb 2018 21:56:42 +0100 Subject: [PATCH] build.go: Allow specifying the temp dir to use --- build.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build.go b/build.go index 05c572f98..0072c6232 100644 --- a/build.go +++ b/build.go @@ -270,7 +270,7 @@ func build(cwd, goos, goarch, goarm, gopath string, args ...string) error { cmd.Dir = cwd cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - verbosePrintf("go %s\n", args) + verbosePrintf("go %s\n", a) return cmd.Run() } @@ -437,6 +437,8 @@ func main() { targetGOARCH := runtime.GOARCH targetGOARM := "" + gopath := "" + var outputFilename string for i, arg := range params { @@ -459,6 +461,9 @@ func main() { case "-o", "--output": skipNext = true outputFilename = params[i+1] + case "--tempdir": + skipNext = true + gopath = params[i+1] case "-T", "--test": runTests = true case "--enable-cgo": @@ -498,9 +503,11 @@ func main() { die("Getwd(): %v\n", err) } - gopath, err := ioutil.TempDir("", fmt.Sprintf("%v-build-", config.Name)) - if err != nil { - die("TempDir(): %v\n", err) + if gopath == "" { + gopath, err = ioutil.TempDir("", fmt.Sprintf("%v-build-", config.Name)) + if err != nil { + die("TempDir(): %v\n", err) + } } verbosePrintf("create GOPATH at %v\n", gopath)