mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix(build): c-shared build and release when target is wasm (#5128)
This commit fixes the automatic extension when building the wasip1_wasm target. Additionally, in future Go versions, support will be added for generating c-shared WASM binaries. https://github.com/golang/go/issues/65199 Therefore, this PR corrects the extension in the build process and removes the .h file from the release when c-shared is enabled and the target is WASM.
This commit is contained in:
parent
04dfb72d57
commit
40668d4382
@ -182,7 +182,7 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
a.Type = artifact.CArchive
|
||||
ctx.Artifacts.Add(getHeaderArtifactForLibrary(build, options))
|
||||
}
|
||||
if build.Buildmode == "c-shared" {
|
||||
if build.Buildmode == "c-shared" && !strings.Contains(options.Target, "wasm") {
|
||||
a.Type = artifact.CShared
|
||||
ctx.Artifacts.Add(getHeaderArtifactForLibrary(build, options))
|
||||
}
|
||||
|
@ -228,6 +228,9 @@ func extFor(target string, build config.BuildDetails) string {
|
||||
if strings.Contains(target, "windows") {
|
||||
return ".dll"
|
||||
}
|
||||
if strings.Contains(target, "wasm") {
|
||||
return ".wasm"
|
||||
}
|
||||
return ".so"
|
||||
case "c-archive":
|
||||
if strings.Contains(target, "windows") {
|
||||
@ -236,7 +239,7 @@ func extFor(target string, build config.BuildDetails) string {
|
||||
return ".a"
|
||||
}
|
||||
|
||||
if target == "js_wasm" {
|
||||
if strings.Contains(target, "wasm") {
|
||||
return ".wasm"
|
||||
}
|
||||
|
||||
|
@ -462,6 +462,8 @@ func TestExtWindows(t *testing.T) {
|
||||
|
||||
func TestExtWasm(t *testing.T) {
|
||||
require.Equal(t, ".wasm", extFor("js_wasm", config.BuildDetails{}))
|
||||
require.Equal(t, ".wasm", extFor("wasip1_wasm", config.BuildDetails{}))
|
||||
require.Equal(t, ".wasm", extFor("wasip1_wasm", config.BuildDetails{Buildmode: "c-shared"}))
|
||||
}
|
||||
|
||||
func TestExtOthers(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user