forked from TrueCloudLab/restic
build.go: Allow setting the output file name
This commit is contained in:
parent
a3181dbead
commit
62b1056860
1 changed files with 11 additions and 3 deletions
10
build.go
10
build.go
|
@ -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,10 +383,12 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
outputFilename := config.Name
|
if outputFilename == "" {
|
||||||
|
outputFilename = config.Name
|
||||||
if targetGOOS == "windows" {
|
if targetGOOS == "windows" {
|
||||||
outputFilename += ".exe"
|
outputFilename += ".exe"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue