Skip to content

Commit

Permalink
feat: wasm support (#1159)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Oct 1, 2019
1 parent e0ef203 commit 9d5f36f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/builders/golang/build_test.go
Expand Up @@ -91,6 +91,7 @@ func TestBuild(t *testing.T) {
"darwin_amd64",
"windows_amd64",
"linux_arm_6",
"js_wasm",
},
Asmflags: []string{".=", "all="},
Gcflags: []string{"all="},
Expand All @@ -107,6 +108,9 @@ func TestBuild(t *testing.T) {
if strings.HasPrefix(target, "windows") {
ext = ".exe"
}
if target == "js_wasm" {
ext = ".wasm"
}
var err = Default.Build(ctx, build, api.Options{
Target: target,
Name: build.Binary,
Expand Down Expand Up @@ -165,6 +169,18 @@ func TestBuild(t *testing.T) {
"ID": "foo",
},
},
{
Name: "foo",
Path: filepath.Join(folder, "dist", "js_wasm", "foo"),
Goos: "js",
Goarch: "wasm",
Type: artifact.Binary,
Extra: map[string]interface{}{
"Ext": ".wasm",
"Binary": "foo",
"ID": "foo",
},
},
})
}

Expand Down
1 change: 1 addition & 0 deletions internal/builders/golang/targets.go
Expand Up @@ -102,6 +102,7 @@ var validTargets = []string{
"freebsd386",
"freebsdamd64",
"freebsdarm",
"jswasm",
"linux386",
"linuxamd64",
"linuxarm",
Expand Down
4 changes: 4 additions & 0 deletions internal/builders/golang/targets_test.go
Expand Up @@ -15,12 +15,14 @@ func TestAllBuildTargets(t *testing.T) {
"darwin",
"freebsd",
"openbsd",
"js",
},
Goarch: []string{
"386",
"amd64",
"arm",
"arm64",
"wasm",
},
Goarm: []string{
"6",
Expand Down Expand Up @@ -52,6 +54,7 @@ func TestAllBuildTargets(t *testing.T) {
"freebsd_arm_7",
"openbsd_386",
"openbsd_amd64",
"js_wasm",
}, matrix(build))
}

Expand Down Expand Up @@ -91,6 +94,7 @@ func TestGoosGoarchCombos(t *testing.T) {
{"solaris", "amd64", true},
{"windows", "386", true},
{"windows", "amd64", true},
{"js", "wasm", true},
// invalid targets
{"darwin", "arm", false},
{"darwin", "arm64", false},
Expand Down
3 changes: 3 additions & 0 deletions internal/pipe/build/build.go
Expand Up @@ -131,6 +131,9 @@ func extFor(target string) string {
if strings.Contains(target, "windows") {
return ".exe"
}
if target == "js_wasm" {
return ".wasm"
}
return ""
}

Expand Down
4 changes: 4 additions & 0 deletions internal/pipe/build/build_test.go
Expand Up @@ -340,6 +340,10 @@ func TestExtWindows(t *testing.T) {
assert.Equal(t, ".exe", extFor("windows_386"))
}

func TestExtWasm(t *testing.T) {
assert.Equal(t, ".wasm", extFor("js_wasm"))
}

func TestExtOthers(t *testing.T) {
assert.Empty(t, "", extFor("linux_amd64"))
assert.Empty(t, "", extFor("linuxwin_386"))
Expand Down

0 comments on commit 9d5f36f

Please sign in to comment.