diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 8cf4b7f..195cd15 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -85,7 +85,7 @@ jobs: GOWORK: "off" GOTOOLCHAIN: local run: | - GOOS=js GOARCH=wasm go build -trimpath -ldflags "-s -w" \ + GOOS=js GOARCH=wasm go build -tags rbgo_core -trimpath -ldflags "-s -w" \ -o ../../static/playground/rbgo.wasm github.com/go-embedded-ruby/ruby/cmd/wasm raw=$(stat -c %s ../../static/playground/rbgo.wasm); gz=$(gzip -9 -c ../../static/playground/rbgo.wasm | wc -c) echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index 47171b1..f2c3bf9 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -127,7 +127,7 @@ jobs: - name: build go-embedded-ruby (js/wasm) working-directory: playground/rubywasm run: | - GOOS=js GOARCH=wasm go build -trimpath -ldflags "-s -w" -o "$RUNNER_TEMP/rbgo.wasm" github.com/go-embedded-ruby/ruby/cmd/wasm + GOOS=js GOARCH=wasm go build -tags rbgo_core -trimpath -ldflags "-s -w" -o "$RUNNER_TEMP/rbgo.wasm" github.com/go-embedded-ruby/ruby/cmd/wasm raw=$(stat -c %s "$RUNNER_TEMP/rbgo.wasm"); gz=$(gzip -9 -c "$RUNNER_TEMP/rbgo.wasm" | wc -c) echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY" - name: run the proof @@ -137,7 +137,7 @@ jobs: PLAYGROUND_CAPTURE_DIR: ${{ runner.temp }}/captures PLAYGROUND_RUBY_WASM: ${{ runner.temp }}/rbgo.wasm # TestRubyAgreesWithGo runs every operation's Ruby program on the - # interpreter. The proof downloads its ~100 MB twice in Chrome: give the + # interpreter. The proof downloads its ~23 MB twice in Chrome: give the # run more than go test's 10 minutes. run: go test -count=1 -timeout 30m -v -run 'TestBrowserProof|TestRubyAgreesWithGo' . ./engine - name: keep the screenshots diff --git a/playground/README.md b/playground/README.md index 60c534e..ccfb361 100644 --- a/playground/README.md +++ b/playground/README.md @@ -87,15 +87,18 @@ calls only the methods of that API. The interpreter is a second Go program compiled to WebAssembly, `github.com/go-embedded-ruby/ruby/cmd/wasm`, at the version `rubywasm/go.mod` -pins: +pins, built with the `rbgo_core` tag: the Ruby language and its numeric stack +(NDArray, FFT, Complex, Rational, Set, BigDecimal, Matrix, …) and none of the +gem bindings, which the playground never calls: ```sh cd rubywasm -GOOS=js GOARCH=wasm go build -trimpath -ldflags="-s -w" \ +GOOS=js GOARCH=wasm go build -tags rbgo_core -trimpath -ldflags="-s -w" \ -o ../../static/playground/rbgo.wasm github.com/go-embedded-ruby/ruby/cmd/wasm ``` -It is far larger than the playground (about 100 MB, 21 MB gzipped), so the page +The full build was about 100 MB (22 MB gzipped); the core one is about 23 MB +(5.7 MB gzipped). It is still larger than the playground, so the page never loads it up front: the first time the visitor opens the Ruby tab, the ViewModel asks the host, the page's `ndarrayRubyLoad` fetches it with a progress line and bar counting the bytes, and starts it in its own Go runtime diff --git a/playground/browser_test.go b/playground/browser_test.go index 31f5175..5eba224 100644 --- a/playground/browser_test.go +++ b/playground/browser_test.go @@ -94,7 +94,7 @@ func TestBrowserProof(t *testing.T) { t.Fatal(err) } } else { - run("rubywasm", []string{"GOOS=js", "GOARCH=wasm"}, "go", "build", "-trimpath", "-ldflags=-s -w", "-o", + run("rubywasm", []string{"GOOS=js", "GOARCH=wasm"}, "go", "build", "-tags", "rbgo_core", "-trimpath", "-ldflags=-s -w", "-o", rbgo, "github.com/go-embedded-ruby/ruby/cmd/wasm") } execJS, err := os.ReadFile(filepath.Join(runtime.GOROOT(), "lib", "wasm", "wasm_exec.js")) diff --git a/playground/rubywasm/go.mod b/playground/rubywasm/go.mod index 6cd7daf..9fc7afd 100644 --- a/playground/rubywasm/go.mod +++ b/playground/rubywasm/go.mod @@ -80,7 +80,7 @@ require ( github.com/go-crdt/collab v0.74.0 // indirect github.com/go-crdt/crdt v0.55.0 // indirect github.com/go-datetime/dates v0.1.0 // indirect - github.com/go-embedded-ruby/ruby v0.5.0 // indirect + github.com/go-embedded-ruby/ruby v0.6.0 // indirect github.com/go-encryptions/unixcrypt v0.1.0 // indirect github.com/go-facter/facter v0.0.0-20260830120958-454b72e642ab // indirect github.com/go-fft/fft v0.23.0 // indirect diff --git a/playground/rubywasm/go.sum b/playground/rubywasm/go.sum index 9aa3311..c0a776c 100644 --- a/playground/rubywasm/go.sum +++ b/playground/rubywasm/go.sum @@ -202,8 +202,8 @@ github.com/go-crdt/crdt v0.55.0 h1:D/LHQ4OgSJRomMvEeYzRwwnP0hnXGngWevXglmpXIxI= github.com/go-crdt/crdt v0.55.0/go.mod h1:vbfvns9B9FUaMi2sPKzMYttKmbxfgO7EK3Yu82SrlYw= github.com/go-datetime/dates v0.1.0 h1:Uj8TaTZ09DXdq75EGQ/teFdrXpfVAC3ZDHAPQvPTnaA= github.com/go-datetime/dates v0.1.0/go.mod h1:KeZ1wUeMScJD6HOvj3hINwbsB+GCSFjJLWcJhrBlwIo= -github.com/go-embedded-ruby/ruby v0.5.0 h1:DcJxu4H6CJC9qr6utIa399Q41eq36Ti/zbqnR8fRaYA= -github.com/go-embedded-ruby/ruby v0.5.0/go.mod h1:QS5klA3N6Wg6nWe90pesNQvRQPw9AXMxBNOi9I6ukCs= +github.com/go-embedded-ruby/ruby v0.6.0 h1:uB+qHsTf+75YtXj2u76IHiNI/2/YYlZ8Gj/caM3ZEZg= +github.com/go-embedded-ruby/ruby v0.6.0/go.mod h1:QS5klA3N6Wg6nWe90pesNQvRQPw9AXMxBNOi9I6ukCs= github.com/go-encryptions/unixcrypt v0.1.0 h1:XWk4h9uCDd+T2hovOzgO0B2vOdJvAwi9nbOBVb3o62c= github.com/go-encryptions/unixcrypt v0.1.0/go.mod h1:B1dJSjz3kdxvP7cpi5xSzyxezgBijmtNCUeCKqqDd3o= github.com/go-facter/facter v0.0.0-20260830120958-454b72e642ab h1:bXPxQDhADpiF/S/8jlRFhVisFPRaxPtPgjibLnOzvsE=