Skip to content

Commit

Permalink
Fixes for TinyGo 0.26.0 (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
  • Loading branch information
mathetake authored Nov 20, 2022
1 parent 708a56d commit 83330ad
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 7 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ on:
env:
GO_VERSION: "1.18"
PROTOC_VERSION: "21.5"
TINYGO_VERSION: "0.24.0"

jobs:
test:
name: Test
name: Test (TinyGo ${{ matrix.tinygo-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tinygo-version:
- "0.24.0"
- "0.25.0"
- "0.26.0"

steps:
- uses: actions/checkout@v3

Expand All @@ -41,8 +49,8 @@ jobs:

- name: Install TinyGo
run: |
wget https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo_${TINYGO_VERSION}_amd64.deb
sudo dpkg -i tinygo_${TINYGO_VERSION}_amd64.deb
wget https://github.com/tinygo-org/tinygo/releases/download/v${{ matrix.tinygo-version }}/tinygo_${{ matrix.tinygo-version }}_amd64.deb
sudo dpkg -i tinygo_${{ matrix.tinygo-version }}_amd64.deb
- name: Run unit tests
run: make test
run: make test
3 changes: 3 additions & 0 deletions examples/helloworld/greeting/greet_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/host-functions/greeting/greet_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/known-types/known/known_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/wasi/cat/cat_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion gen/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ func genPluginMethod(g *protogen.GeneratedFile, f *fileInfo, method *protogen.Me
g.P("data, err := request.MarshalVT()")
g.P(errorHandling)
g.P("dataSize := uint64(len(data))")

g.P(`if dataSize == 0 {
return response, nil
}`)
g.P("results, err := p.malloc.Call(ctx, dataSize)")
g.P(errorHandling)

Expand Down
3 changes: 3 additions & 0 deletions tests/fields/proto/fields_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/host-functions/proto/host_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/import/proto/bar/bar_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/import/proto/foo/foo_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/well-known/proto/known_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion wasm/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ func WriteMemory(ctx context.Context, m api.Module, data []byte) (uint64, error)
if malloc == nil {
return 0, errors.New("malloc is not exported")
}
results, err := malloc.Call(ctx, uint64(len(data)))

l := uint64(len(data))
if l == 0 {
return 0, nil
}

results, err := malloc.Call(ctx, l)
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 83330ad

Please sign in to comment.