Skip to content

Commit 91a52d8

Browse files
committed
refactor: extract web host runtime and pack it explicitly
Move the host-side web runtime assets into `internal/webruntime/host` so their ownership is separated from `cmd/ispx` and from platform templates under `cmd/gox/template/platform`. Update the web export flow to assemble runtime assets explicitly from the engine template, embedded host assets, `ispx.wasm`, and `wasm_exec.js` instead of staging host files through `$GOPATH/bin/ispx`. Add `packwebruntime` to build release bundles directly and replace the temporary empty-project export hack in `make_util.sh`. Also remove XBuilder-specific branding from shared runtime-facing titles so the base web runtime stays product-neutral. Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
1 parent e6b5c4c commit 91a52d8

21 files changed

Lines changed: 1012 additions & 789 deletions

File tree

cmd/gox/install.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ if [ "$1" = "--web" ]; then
5555
go env -w GOFLAGS="-buildvcs=false"
5656
( cd ../ispx && ./build.sh )
5757
cp ../ispx/ispx.wasm "$GOPATH/bin/"
58-
59-
# Install ispx web runtime
60-
echo "Installing ispx web runtime..."
61-
rm -rf "$GOPATH/bin/ispx"
62-
mkdir -p "$GOPATH/bin/ispx"
63-
cp ../ispx/web/* "$GOPATH/bin/ispx/"
64-
echo "ispx web runtime installed to $GOPATH/bin/ispx/"
6558
fi
6659

6760
( cd ../ispxnative && ./build.sh )

cmd/gox/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"embed"
5+
"fmt"
56
"strings"
67

78
"github.com/goplus/spx/v2/cmd/gox/pkg/command"
@@ -50,7 +51,7 @@ func main() {
5051
// Initialize the Args field if not already initialized
5152
err := cmd.RunCmd(appName, appName, cmd.Version, projectFS, "template/project", "project")
5253
if err != nil {
53-
println("failed to run cmd:", err)
54+
fmt.Println("failed to run cmd:", err)
5455
return
5556
}
5657
}

cmd/gox/pkg/command/args.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (pself *CmdTool) CheckCmd(ext ...string) bool {
7272
"build", "buildtinygo", "rune", "export",
7373
"runweb", "buildweb", "exportweb", "stopweb", "runwebworker",
7474
"runm", "exportbot", "exportapk", "exportios",
75-
"run", "runi", "exporttemplateweb", "exportminigame", "exportminiprogram", "exportwebworker",
75+
"run", "runi", "exporttemplateweb", "exportminigame", "exportminiprogram", "exportwebworker", "packwebruntime",
7676
}
7777
cmds = append(cmds, ext...)
7878

@@ -194,6 +194,7 @@ Available commands:
194194
- exportweb # Export the web package
195195
- exportwebworker # Export web worker package
196196
- exporttemplateweb # Export template web package
197+
- packwebruntime # Pack the reusable web runtime bundle
197198
- stopweb # Stop the web server
198199
199200
Export & Distribution:

cmd/gox/pkg/command/cmd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ func (cmd *CmdTool) RunCmd(projectName, fileSuffix, version string, fs embed.FS,
100100
if cmd.Args.CmdName == "init" {
101101
return cmd.Init()
102102
}
103+
if cmd.Args.CmdName == "packwebruntime" {
104+
return cmd.PackWebRuntime()
105+
}
103106

104107
// Setup paths
105108
err = cmd.setupPaths(dstRelDir)

cmd/gox/pkg/command/env.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,6 @@ func (pself *CmdTool) getWasmPath() string {
247247
return filePath
248248
}
249249

250-
// getIspxWebDir returns the path to the ispx web runtime directory.
251-
func (pself *CmdTool) getIspxWebDir() (string, error) {
252-
ispxWebDir := path.Join(pself.GoBinPath, "ispx")
253-
if _, err := os.Stat(ispxWebDir); os.IsNotExist(err) {
254-
return "", fmt.Errorf("ispx web runtime not found at %s; "+
255-
"run 'cd cmd/gox && ./install.sh --web' to install", ispxWebDir)
256-
}
257-
return ispxWebDir, nil
258-
}
259-
260250
// SetupPC sets up the PC environment by running the initialization script
261251
func (pself *CmdTool) SetupPC() error {
262252
// Get current working directory

0 commit comments

Comments
 (0)