-
Notifications
You must be signed in to change notification settings - Fork 1
Tinygo wasm #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tinygo wasm #4
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7205aa7
chore: add tiny_wasm_exec.js
ZauberNerd 1388f81
fix: use forked yaml package
ZauberNerd 264cf17
chore: add setup-tinygo action
ZauberNerd c009470
feat: use tinygo instead of go to create smaller wasm binary
ZauberNerd 3f83542
fix: upgrade actionlint to v1.6.12
ZauberNerd 84c9a7e
chore: update tinygo and go
ZauberNerd dc072c2
refactor: destructure wasm exports to improve readability
ZauberNerd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: 'Setup TinyGo environment' | ||
| description: 'Setup a TinyGo environment and add it to the PATH' | ||
| inputs: | ||
| version: | ||
| description: 'The Go version to download and use. Must be a valid commitish, e.g. "dev" or "v1.0.0"' | ||
| required: true | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install LLVM 13 | ||
| run: | | ||
| source /etc/os-release | ||
| echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-13 main" | sudo tee /etc/apt/sources.list.d/llvm.list | ||
| wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
| sudo apt-get -qq update | ||
| sudo apt-get -yqq install clang-13 llvm-13-dev lld-13 libclang-13-dev | ||
| shell: bash | ||
|
|
||
| - uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: 1.17 | ||
|
|
||
| - name: Install Binaryen | ||
| run: | | ||
| pushd /dev/shm | ||
| VERSION="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/WebAssembly/binaryen/releases/latest)" | ||
| VERSION="${VERSION#https://github.com/WebAssembly/binaryen/releases/tag/}" | ||
| curl -sfOL "https://github.com/WebAssembly/binaryen/releases/download/${VERSION}/binaryen-${VERSION}-$(uname -m)-linux.tar.gz" | ||
| tar -xvf "binaryen-${VERSION}-$(uname -m)-linux.tar.gz" | ||
| mkdir -p "${RUNNER_TOOL_CACHE}/binaryen" | ||
| mv "binaryen-${VERSION}" "${RUNNER_TOOL_CACHE}/binaryen/${VERSION}" | ||
| echo "${RUNNER_TOOL_CACHE}/binaryen/${VERSION}/bin" >> $GITHUB_PATH | ||
| popd | ||
| shell: bash | ||
|
|
||
| - name: Install TinyGo | ||
| run: | | ||
| pushd /dev/shm | ||
| mkdir tinygo | ||
| cd tinygo | ||
| git init | ||
| git remote add origin https://github.com/tinygo-org/tinygo.git | ||
| git fetch --prune --progress --no-tags --depth=1 origin "${{ inputs.version }}" | ||
| git checkout --progress --force -B "${{ inputs.version }}" FETCH_HEAD | ||
| git submodule update --init --recursive --depth 1 | ||
| make wasi-libc | ||
| mkdir -p "${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" | ||
| GOBIN="${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" go install | ||
| echo "${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" >> $GITHUB_PATH | ||
| popd | ||
| shell: bash | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| main.wasm | ||
| wasm_exec.js | ||
| tmp.wasm | ||
| node_modules/ | ||
| types/ | ||
| types/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| .github/ | ||
| .vscode/ | ||
| node_modules/ | ||
| go.mod | ||
| go.sum | ||
| globals.d.ts | ||
| main.go | ||
| Makefile | ||
| renovate.json | ||
| test.mjs | ||
| tmp.wasm | ||
| tsconfig.json | ||
| yarn.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,4 @@ | |
| "GOARCH": "wasm" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,17 @@ | ||
| build: wasm_exec.js main.wasm types/node.d.mts | ||
| build: main.wasm types/node.d.mts | ||
|
|
||
| wasm_exec.js: | ||
| cp $$(go env GOROOT)/misc/wasm/wasm_exec.js wasm_exec.tmp.js | ||
| echo "// @ts-nocheck" > wasm_exec.js | ||
| cat wasm_exec.tmp.js >> wasm_exec.js | ||
| rm wasm_exec.tmp.js | ||
| main.wasm: tmp.wasm | ||
| wasm-opt -c -O4 -o main.wasm tmp.wasm | ||
|
|
||
| main.wasm: main.go go.mod | ||
| GOOS=js GOARCH=wasm go build -o main.wasm | ||
| tmp.wasm: main.go go.mod | ||
| tinygo build -o tmp.wasm -target wasm -panic trap -opt z main.go | ||
|
|
||
| types/node.d.mts: *.cjs *.mjs *.d.ts *.json yarn.lock | ||
| $$(yarn bin)/tsc -p . | ||
|
|
||
| clean: | ||
| rm main.wasm | ||
| rm wasm_exec.js | ||
| rm tmp.wasm | ||
| rm -rf types | ||
|
|
||
| .PHONY: build clean | ||
| .PHONY: build clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,36 @@ | ||
| github.com/ZauberNerd/yaml v0.0.0-20220305122605-f022dd71f1c2 h1:XKY7uPNa/yq6NV/j6HHrAck1Aco1Xlj5Y+bDHnN9HHA= | ||
| github.com/ZauberNerd/yaml v0.0.0-20220305122605-f022dd71f1c2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
| github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= | ||
| github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= | ||
| github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= | ||
| github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
| github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= | ||
| github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
| github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
| github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||
| github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= | ||
| github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= | ||
| github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= | ||
| github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= | ||
| github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | ||
| github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= | ||
| github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= | ||
| github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= | ||
| github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= | ||
| github.com/rhysd/actionlint v1.6.9 h1:8rQQ76o88zctUCzukt0A5O/FO003wTGbkLQuwQkMf9c= | ||
| github.com/rhysd/actionlint v1.6.9/go.mod h1:0AA4pvZ2nrZHT6D86eUhieH2NFmLqhxrNex0NEa2A2g= | ||
| github.com/rhysd/actionlint v1.6.12 h1:Qoa69UsvF/7tNc0008v7s1hHDANHuqaq0qHhu4syf7w= | ||
| github.com/rhysd/actionlint v1.6.12/go.mod h1:M+vAgTIFE2yOdr91fpDF4CUsyZVsPmS+D/x2K7qhhP0= | ||
| github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= | ||
| github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= | ||
| github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= | ||
| github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= | ||
| github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= | ||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= | ||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
| golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo= | ||
| golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY= | ||
| golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.