mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: Add support for c-shared and c-archive build modes in windows (#1243)
* add hardcoded .dll and .lib extensions * chore: remove unnecessary else case
This commit is contained in:
parent
16cb4d8277
commit
1cf86b86f6
@ -104,7 +104,7 @@ func runHook(ctx *context.Context, env []string, hook string) error {
|
||||
}
|
||||
|
||||
func doBuild(ctx *context.Context, build config.Build, target string) error {
|
||||
var ext = extFor(target)
|
||||
var ext = extFor(target, build.Flags)
|
||||
|
||||
binary, err := tmpl.New(ctx).Apply(build.Binary)
|
||||
if err != nil {
|
||||
@ -127,8 +127,16 @@ func doBuild(ctx *context.Context, build config.Build, target string) error {
|
||||
})
|
||||
}
|
||||
|
||||
func extFor(target string) string {
|
||||
func extFor(target string, flags config.FlagArray) string {
|
||||
if strings.Contains(target, "windows") {
|
||||
for _, s := range flags {
|
||||
if s == "-buildmode=c-shared" {
|
||||
return ".dll"
|
||||
}
|
||||
if s == "-buildmode=c-archive" {
|
||||
return ".lib"
|
||||
}
|
||||
}
|
||||
return ".exe"
|
||||
}
|
||||
if target == "js_wasm" {
|
||||
|
@ -336,18 +336,23 @@ func TestDefaultFillSingleBuild(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExtWindows(t *testing.T) {
|
||||
assert.Equal(t, ".exe", extFor("windows_amd64"))
|
||||
assert.Equal(t, ".exe", extFor("windows_386"))
|
||||
assert.Equal(t, ".exe", extFor("windows_amd64", config.FlagArray{}))
|
||||
assert.Equal(t, ".exe", extFor("windows_386", config.FlagArray{}))
|
||||
assert.Equal(t, ".exe", extFor("windows_amd64", config.FlagArray{"-tags=dev", "-v"}))
|
||||
assert.Equal(t, ".dll", extFor("windows_amd64", config.FlagArray{"-tags=dev", "-v", "-buildmode=c-shared"}))
|
||||
assert.Equal(t, ".dll", extFor("windows_386", config.FlagArray{"-buildmode=c-shared"}))
|
||||
assert.Equal(t, ".lib", extFor("windows_amd64", config.FlagArray{"-buildmode=c-archive"}))
|
||||
assert.Equal(t, ".lib", extFor("windows_386", config.FlagArray{"-tags=dev", "-v", "-buildmode=c-archive"}))
|
||||
}
|
||||
|
||||
func TestExtWasm(t *testing.T) {
|
||||
assert.Equal(t, ".wasm", extFor("js_wasm"))
|
||||
assert.Equal(t, ".wasm", extFor("js_wasm", config.FlagArray{}))
|
||||
}
|
||||
|
||||
func TestExtOthers(t *testing.T) {
|
||||
assert.Empty(t, "", extFor("linux_amd64"))
|
||||
assert.Empty(t, "", extFor("linuxwin_386"))
|
||||
assert.Empty(t, "", extFor("winasdasd_sad"))
|
||||
assert.Empty(t, "", extFor("linux_amd64", config.FlagArray{}))
|
||||
assert.Empty(t, "", extFor("linuxwin_386", config.FlagArray{}))
|
||||
assert.Empty(t, "", extFor("winasdasd_sad", config.FlagArray{}))
|
||||
}
|
||||
|
||||
func TestTemplate(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user