Skip to content

Commit

Permalink
fix all wasm guests build and refresh with TinyGo 0.28.1 (#3377)
Browse files Browse the repository at this point in the history
  • Loading branch information
evacchi committed Mar 9, 2024
1 parent 49afc55 commit 6290422
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 13 deletions.
8 changes: 4 additions & 4 deletions bindings/wasm/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ func (out *outputBinding) Invoke(ctx context.Context, req *bindings.InvokeReques

// Instantiating executes the guest's main function (exported as _start).
mod, err := out.runtime.InstantiateModule(ctx, out.module, moduleConfig)
if err != nil {
return nil, err
}

// WASI typically calls proc_exit which exits the module, but just in case
// it doesn't, close the module manually.
_ = mod.Close(ctx)

// Return STDOUT if there was no error.
if err == nil {
return &bindings.InvokeResponse{Data: stdout.Bytes()}, nil
}
return nil, err
return &bindings.InvokeResponse{Data: stdout.Bytes()}, nil
}

func (out *outputBinding) Operations() []bindings.OperationKind {
Expand Down
7 changes: 6 additions & 1 deletion bindings/wasm/testdata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ tinygo_sources := ./args/main.go ./example/main.go ./loop/main.go
.PHONY: build
build: $(tinygo_sources)
@for f in $^; do \
tinygo build -o $$(echo $$f | sed -e 's/\.go/\.wasm/') -scheduler=none --no-debug --target=wasi $$f; \
cd $$(dirname $$f); \
fname=$$(basename $$f); \
tinygo build -o $$(echo $$fname | sed -e 's/\.go/\.wasm/') -scheduler=none --no-debug --target=wasi $$fname; \
cd ..; \
done
@# http/main.go is compiled seprately because it requires a scheduler.
@(cd ./http && tinygo build -o main.wasm --no-debug --target=wasi ./main.go)
3 changes: 3 additions & 0 deletions bindings/wasm/testdata/args/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/dapr/components-contrib/bindings/wasm/testdata/args

go 1.20
Binary file modified bindings/wasm/testdata/args/main.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions bindings/wasm/testdata/example/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/dapr/components-contrib/bindings/wasm/testdata/example

go 1.20
Binary file modified bindings/wasm/testdata/example/main.wasm
Binary file not shown.
4 changes: 0 additions & 4 deletions bindings/wasm/testdata/http/Makefile

This file was deleted.

8 changes: 8 additions & 0 deletions bindings/wasm/testdata/http/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/dapr/components-contrib/bindings/wasm/testdata/http

go 1.20

// This is the last version building with
// stealthrocket/wasi-go host ABI.
// The guest is revlocked to TinyGo 0.28.1
require github.com/dev-wasm/dev-wasm-go/http v0.0.0-20230803142009-0dee5e3d3722
2 changes: 2 additions & 0 deletions bindings/wasm/testdata/http/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/dev-wasm/dev-wasm-go/http v0.0.0-20230803142009-0dee5e3d3722 h1:H8rt2at/lzf9hSuZX/+/E0Rqp5o7hYOZ1XZiOGVkwSw=
github.com/dev-wasm/dev-wasm-go/http v0.0.0-20230803142009-0dee5e3d3722/go.mod h1:K7HKbanDfLH3UL/hvExI1hVPetqnn9OZ4IOFcD5Pzw0=
4 changes: 0 additions & 4 deletions bindings/wasm/testdata/http/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package main

// Building main.wasm:
// go get github.com/dev-wasm/dev-wasm-go/http/client
// tinygo build -target wasi -o main.wasm main.go

import (
"fmt"
"io/ioutil"
Expand Down
Binary file modified bindings/wasm/testdata/http/main.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions bindings/wasm/testdata/loop/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/dapr/components-contrib/bindings/wasm/testdata/loop

go 1.20
Binary file modified bindings/wasm/testdata/loop/main.wasm
Binary file not shown.
Binary file modified middleware/http/wasm/example/router.wasm
Binary file not shown.
Binary file modified middleware/http/wasm/internal/e2e-guests/config/main.wasm
Binary file not shown.
Binary file modified middleware/http/wasm/internal/e2e-guests/output/main.wasm
Binary file not shown.
Binary file modified middleware/http/wasm/internal/e2e-guests/rewrite/main.wasm
Binary file not shown.
Binary file modified middleware/http/wasm/internal/testdata/rewrite.wasm
Binary file not shown.

0 comments on commit 6290422

Please sign in to comment.