Skip to content

Commit

Permalink
refactor(tools/ispx): migrate to Go 1.23
Browse files Browse the repository at this point in the history
Signed-off-by: Aofei Sheng <[email protected]>
  • Loading branch information
aofei committed Feb 18, 2025
1 parent 8ca78b1 commit b51fe6e
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 80 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ RUN gop build -trimpath -o spx-backend ./cmd/spx-backend
FROM ${GO_BASE_IMAGE} AS go-builder

ARG GOPROXY
# Pre-install Go toolchain for 1.21.3, which will be used by tools/ispx
RUN GOTOOLCHAIN=go1.21.3 go version

WORKDIR /app
COPY tools ./tools
Expand Down
30 changes: 0 additions & 30 deletions spx-gui/build-wasm.bat

This file was deleted.

14 changes: 7 additions & 7 deletions spx-gui/build-wasm.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
set -e

echo Run this script from 'spx-gui' directory
echo "Run this script from 'spx-gui' directory"

cd ../tools/ispx
source ./build.sh
cp ./main.wasm ../../spx-gui/src/assets/ispx/main.wasm
# Build and copy ispx.wasm
( cd ../tools/ispx && ./build.sh )
cp ../tools/ispx/ispx.wasm src/assets/ispx.wasm

cd ../spxls
source ./build.sh
cp ./spxls.wasm ../../spx-gui/src/assets/spxls.wasm
# Build and copy spxls.wasm
( cd ../tools/spxls && ./build.sh )
cp ../tools/spxls/spxls.wasm src/assets/spxls.wasm
1 change: 0 additions & 1 deletion spx-gui/src/assets/ispx/runner.html

This file was deleted.

8 changes: 4 additions & 4 deletions spx-gui/src/components/project/runner/v1/IframeDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<script lang="ts">
import { ref, watch } from 'vue'
import rawRunnerHtml from '@/assets/ispx/runner.html?raw'
import wasmExecUrl from '@/assets/wasm_exec.js?url'
import wasmUrl from '@/assets/ispx/main.wasm?url'
import ispxWasmUrl from '@/assets/ispx.wasm?url'
import ispxRunnerHtml from './ispx/runner.html?raw'
import { addPrefetchLink } from '@/utils/dom'
// preload resources (for example, wasm files) to accelerate the loading
Expand All @@ -15,7 +15,7 @@ export function preload() {
// * `preload` indicates higher priority than `prefetch`. Preloaded content are expected to be used soon. For example, chrome will warn if the preloaded content is not used within 3 or 5 seconds. While project here will not be runned until the user clicks some "run" button.
// * `preload` results are not shared across different documents, while the iframe content is a different document. The "preloading" is meaningful only when the HTTP cache is shared, which is more like the case of `prefetch`.
addPrefetchLink(wasmExecUrl)
addPrefetchLink(wasmUrl)
addPrefetchLink(ispxWasmUrl)
}
</script>

Expand All @@ -42,7 +42,7 @@ watch(iframe, () => {
if (!iframeWindow) {
return
}
const runnerHtml = rawRunnerHtml.replace('/wasm_exec.js', wasmExecUrl).replace('main.wasm', wasmUrl)
const runnerHtml = ispxRunnerHtml.replace('/wasm_exec.js', wasmExecUrl).replace('ispx.wasm', ispxWasmUrl)
iframeWindow.document.write(runnerHtml) // This resets the iframe's content, including its window object
Expand Down
1 change: 1 addition & 0 deletions spx-gui/src/components/project/runner/v1/ispx/runner.html
4 changes: 3 additions & 1 deletion spx-gui/vercel-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -e

export PATH=$PATH:/usr/local/go/bin && ./build-wasm.sh
export PATH=/usr/local/go/bin:$PATH

./build-wasm.sh
npm run build
2 changes: 1 addition & 1 deletion spx-gui/vercel-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ tar -C /usr/local -xzf ./go1.23.4.linux-amd64.tar.gz
/usr/local/go/bin/go version

npm install
source ./install-spx.sh
./install-spx.sh
3 changes: 0 additions & 3 deletions tools/ispx/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions tools/ispx/.vscode/settings.json

This file was deleted.

9 changes: 0 additions & 9 deletions tools/ispx/build.bat

This file was deleted.

5 changes: 3 additions & 2 deletions tools/ispx/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

GOTOOLCHAIN=go1.21.3 GOOS=js GOARCH=wasm go build -tags canvas -trimpath -o main.wasm
GOOS=js GOARCH=wasm go build -tags canvas -trimpath -ldflags -checklinkname=0 -o ispx.wasm
6 changes: 5 additions & 1 deletion tools/ispx/embedded_pkgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import (
_ "github.com/goplus/igop/pkg/io"
_ "github.com/goplus/igop/pkg/io/fs"
_ "github.com/goplus/igop/pkg/io/ioutil"
_ "github.com/goplus/igop/pkg/iter"
_ "github.com/goplus/igop/pkg/log"
_ "github.com/goplus/igop/pkg/log/slog"
_ "github.com/goplus/igop/pkg/maps"
Expand All @@ -79,6 +80,7 @@ import (
_ "github.com/goplus/igop/pkg/math/bits"
_ "github.com/goplus/igop/pkg/math/cmplx"
_ "github.com/goplus/igop/pkg/math/rand"
_ "github.com/goplus/igop/pkg/math/rand/v2"
_ "github.com/goplus/igop/pkg/mime"
_ "github.com/goplus/igop/pkg/net/http"
_ "github.com/goplus/igop/pkg/net/netip"
Expand Down Expand Up @@ -106,6 +108,7 @@ import (
_ "github.com/goplus/igop/pkg/unicode"
_ "github.com/goplus/igop/pkg/unicode/utf16"
_ "github.com/goplus/igop/pkg/unicode/utf8"
_ "github.com/goplus/igop/pkg/unique"

// Excluded stdlib packages.
// _ "github.com/goplus/igop/pkg/container/heap"
Expand Down Expand Up @@ -140,6 +143,7 @@ import (
// _ "github.com/goplus/igop/pkg/go/scanner"
// _ "github.com/goplus/igop/pkg/go/token"
// _ "github.com/goplus/igop/pkg/go/types"
// _ "github.com/goplus/igop/pkg/go/version"
// _ "github.com/goplus/igop/pkg/index/suffixarray"
// _ "github.com/goplus/igop/pkg/log/syslog"
// _ "github.com/goplus/igop/pkg/mime/multipart"
Expand All @@ -160,12 +164,12 @@ import (
// _ "github.com/goplus/igop/pkg/os/exec"
// _ "github.com/goplus/igop/pkg/os/signal"
// _ "github.com/goplus/igop/pkg/os/user"
// _ "github.com/goplus/igop/pkg/plugin"
// _ "github.com/goplus/igop/pkg/runtime/coverage"
// _ "github.com/goplus/igop/pkg/runtime/debug"
// _ "github.com/goplus/igop/pkg/runtime/metrics"
// _ "github.com/goplus/igop/pkg/runtime/pprof"
// _ "github.com/goplus/igop/pkg/runtime/trace"
// _ "github.com/goplus/igop/pkg/structs"
// _ "github.com/goplus/igop/pkg/syscall"
// _ "github.com/goplus/igop/pkg/testing"
// _ "github.com/goplus/igop/pkg/testing/fstest"
Expand Down
4 changes: 2 additions & 2 deletions tools/ispx/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/goplus/builder/ispx

go 1.21.0
go 1.23.0

require (
github.com/goplus/igop v0.32.0
github.com/goplus/igop v0.32.1
github.com/goplus/reflectx v1.3.2
github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499
github.com/hajimehoshi/ebiten/v2 v2.8.0-alpha.3
Expand Down
4 changes: 2 additions & 2 deletions tools/ispx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ github.com/goplus/gogen v1.16.6 h1:Zwv18HoTbPDk8s2ajxgVeqZE5i4/GMV722KHl6GS8Yk=
github.com/goplus/gogen v1.16.6/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972 h1:wA4+I+DDfoNwR+zCnaeckt5pxZgLAuaKvVkC+T9GdiQ=
github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972/go.mod h1:lcW75c0a5v361jId1Vxs4lRrsasWsQDH0k3dG3Z7wH0=
github.com/goplus/igop v0.32.0 h1:2m/RjkkFLPzRJ0ERyNCh8Abk0XuLSlxFkEFaygnpHgM=
github.com/goplus/igop v0.32.0/go.mod h1:GCJA4qASZ1IU8MNNgDiW+Yf+eKf2G8fJWrx3arSBm8A=
github.com/goplus/igop v0.32.1 h1:GbI9ThqEUDX9f18jO1xx9NWRb3XnTIgg+byr3JnCpAA=
github.com/goplus/igop v0.32.1/go.mod h1:GCJA4qASZ1IU8MNNgDiW+Yf+eKf2G8fJWrx3arSBm8A=
github.com/goplus/llgo v0.9.9/go.mod h1:udcq+s6tGOdhJq7I8fXPTv4qT2j17/KrlvtcJrMZAoM=
github.com/goplus/llvm v0.8.0/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4=
github.com/goplus/mod v0.13.13/go.mod h1:invR72Rz2+qpOOsXqxz830MX8/aR2GDR2EAow/WgfHI=
Expand Down
2 changes: 1 addition & 1 deletion tools/ispx/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

(async () => {
const go = new Go();
const { instance } = await WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject)
const { instance } = await WebAssembly.instantiateStreaming(fetch("ispx.wasm"), go.importObject)
go.run(instance);

window.startWithZipBuffer = (buffer) => {
Expand Down
4 changes: 2 additions & 2 deletions tools/spxls/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.23.4

require (
github.com/goplus/gogen v1.16.6
github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972
github.com/goplus/mod v0.13.15
github.com/goplus/gop v1.3.0
github.com/goplus/mod v0.13.17
github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499
github.com/stretchr/testify v1.9.0
golang.org/x/tools v0.23.0
Expand Down
8 changes: 4 additions & 4 deletions tools/spxls/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ github.com/goplus/canvas v0.1.0 h1:Vx3f2+U8UANvWf5/01YsQYKNbZDm1GZCjhlEBFrQkeU=
github.com/goplus/canvas v0.1.0/go.mod h1:Rhcvo5qkpD9WuXFnvnXtrBSY97l6h7sXQuofrmiLNdM=
github.com/goplus/gogen v1.16.6 h1:Zwv18HoTbPDk8s2ajxgVeqZE5i4/GMV722KHl6GS8Yk=
github.com/goplus/gogen v1.16.6/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972 h1:wA4+I+DDfoNwR+zCnaeckt5pxZgLAuaKvVkC+T9GdiQ=
github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972/go.mod h1:lcW75c0a5v361jId1Vxs4lRrsasWsQDH0k3dG3Z7wH0=
github.com/goplus/mod v0.13.15 h1:IyneSjwm1VpwvHGz6hSHnFxZCuO6ULHcu74IAZcW9nw=
github.com/goplus/mod v0.13.15/go.mod h1:invR72Rz2+qpOOsXqxz830MX8/aR2GDR2EAow/WgfHI=
github.com/goplus/gop v1.3.0 h1:RDOTn+VZc9jB1qF3mkgB0f1LuAbzRKz4pNVGzkH7Ii8=
github.com/goplus/gop v1.3.0/go.mod h1:BnMzJG+PYoOWjKT4Q7CwxLUTBRnTFuuxW8W4O3vq/TU=
github.com/goplus/mod v0.13.17 h1:aWp14xosENrh7t0/0qcIejDmQEiTgI3ou2+KoLDlSlE=
github.com/goplus/mod v0.13.17/go.mod h1:XlHf8mnQ4QkRDX14Of2tpywuHDd+JVpPStvh3egog+0=
github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499 h1:wt9bXZWSZ6MKgLw0c87GSbKrXjj69aCt7JVM1RwLp3c=
github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499/go.mod h1:ng8mGU/k+1pXjG5zpeczzLOyDD0RhvOv35bxmpiTPGQ=
github.com/hajimehoshi/ebiten/v2 v2.7.9 h1:DYH/usAa9dMHcGkBIIEApJsVqDekrJBxYHmsBuly8Iw=
Expand Down

0 comments on commit b51fe6e

Please sign in to comment.