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

Merge pull request #122 from goreleaser/120

support for custom build flags
This commit is contained in:
Carlos Alexandro Becker 2017-02-23 09:32:52 -03:00 committed by GitHub
commit 52627501b0
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.Fields(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
}