1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

support for custom build flags

This commit is contained in:
Carlos Alexandro Becker 2017-02-22 09:25:43 -03:00
parent eaaf816e59
commit b2fcbaeb49
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 12 additions and 2 deletions

View File

@ -169,9 +169,14 @@ build:
# Default is `main.go`
main: ./cmd/main.go
# Name of the binary. Default is the name of the project directory.
# Name of the binary.
# Default is the name of the project directory.
binary_name: program
# Custom build tags.
# Default is empty
flags: -tags dev
# Custom ldflags.
# Default is `-s -w`
ldflags: -s -w

View File

@ -28,6 +28,7 @@ type Build struct {
Goarch []string
Main string
Ldflags string
Flags string
BinaryName string `yaml:"binary_name"`
Hooks Hooks
}

View File

@ -49,7 +49,11 @@ func build(name, goos, goarch string, ctx *context.Context) error {
return err
}
}
cmd := []string{"go", "build", "-ldflags=" + ldflags, "-o", output, ctx.Config.Build.Main}
cmd := []string{"go", "build"}
if ctx.Config.Build.Flags != "" {
cmd = append(cmd, strings.Split(ctx.Config.Build.Flags, " ")...)
}
cmd = append(cmd, "-ldflags="+ldflags, "-o", output, ctx.Config.Build.Main)
if err := run(goos, goarch, cmd); err != nil {
return err
}