2
2
mirror of https://github.com/octoleo/restic.git synced 2024-10-31 19:02:32 +00:00

build.go: Allow setting the output file name

This commit is contained in:
Alexander Neumann 2017-01-12 19:51:08 +01:00
parent a3181dbead
commit 62b1056860

View File

@ -174,6 +174,7 @@ func showUsage(output io.Writer) {
fmt.Fprintf(output, " -t --tags specify additional build tags\n") fmt.Fprintf(output, " -t --tags specify additional build tags\n")
fmt.Fprintf(output, " -k --keep-gopath do not remove the GOPATH after build\n") fmt.Fprintf(output, " -k --keep-gopath do not remove the GOPATH after build\n")
fmt.Fprintf(output, " -T --test run tests\n") fmt.Fprintf(output, " -T --test run tests\n")
fmt.Fprintf(output, " -o --output set output file name\n")
fmt.Fprintf(output, " --goos value set GOOS for cross-compilation\n") fmt.Fprintf(output, " --goos value set GOOS for cross-compilation\n")
fmt.Fprintf(output, " --goarch value set GOARCH for cross-compilation\n") fmt.Fprintf(output, " --goarch value set GOARCH for cross-compilation\n")
} }
@ -298,6 +299,8 @@ func main() {
targetGOOS := runtime.GOOS targetGOOS := runtime.GOOS
targetGOARCH := runtime.GOARCH targetGOARCH := runtime.GOARCH
var outputFilename string
for i, arg := range params { for i, arg := range params {
if skipNext { if skipNext {
skipNext = false skipNext = false
@ -315,6 +318,9 @@ func main() {
} }
skipNext = true skipNext = true
buildTags = strings.Split(params[i+1], " ") buildTags = strings.Split(params[i+1], " ")
case "-o", "--output":
skipNext = true
outputFilename = params[i+1]
case "-T", "--test": case "-T", "--test":
runTests = true runTests = true
case "--goos": case "--goos":
@ -377,9 +383,11 @@ func main() {
} }
}() }()
outputFilename := config.Name if outputFilename == "" {
if targetGOOS == "windows" { outputFilename = config.Name
outputFilename += ".exe" if targetGOOS == "windows" {
outputFilename += ".exe"
}
} }
cwd, err := os.Getwd() cwd, err := os.Getwd()