2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00

build.go: Allow specifying the temp dir to use

This commit is contained in:
Alexander Neumann 2018-02-27 21:56:42 +01:00
parent 21f67a0a13
commit 1e868933c5

View File

@ -270,7 +270,7 @@ func build(cwd, goos, goarch, goarm, gopath string, args ...string) error {
cmd.Dir = cwd cmd.Dir = cwd
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
verbosePrintf("go %s\n", args) verbosePrintf("go %s\n", a)
return cmd.Run() return cmd.Run()
} }
@ -437,6 +437,8 @@ func main() {
targetGOARCH := runtime.GOARCH targetGOARCH := runtime.GOARCH
targetGOARM := "" targetGOARM := ""
gopath := ""
var outputFilename string var outputFilename string
for i, arg := range params { for i, arg := range params {
@ -459,6 +461,9 @@ func main() {
case "-o", "--output": case "-o", "--output":
skipNext = true skipNext = true
outputFilename = params[i+1] outputFilename = params[i+1]
case "--tempdir":
skipNext = true
gopath = params[i+1]
case "-T", "--test": case "-T", "--test":
runTests = true runTests = true
case "--enable-cgo": case "--enable-cgo":
@ -498,9 +503,11 @@ func main() {
die("Getwd(): %v\n", err) die("Getwd(): %v\n", err)
} }
gopath, err := ioutil.TempDir("", fmt.Sprintf("%v-build-", config.Name)) if gopath == "" {
if err != nil { gopath, err = ioutil.TempDir("", fmt.Sprintf("%v-build-", config.Name))
die("TempDir(): %v\n", err) if err != nil {
die("TempDir(): %v\n", err)
}
} }
verbosePrintf("create GOPATH at %v\n", gopath) verbosePrintf("create GOPATH at %v\n", gopath)