Skip to content

Commit

Permalink
Fix web build
Browse files Browse the repository at this point in the history
  • Loading branch information
JiepengTan committed Dec 6, 2024
1 parent 0a2c51b commit aaa1a57
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 63 deletions.
2 changes: 1 addition & 1 deletion cmd/ispx/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/goplus/igop v0.27.1
github.com/goplus/reflectx v1.2.2
github.com/goplus/spx v0.0.0
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c
)

require (
Expand Down
4 changes: 2 additions & 2 deletions cmd/ispx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qiniu/x v1.13.10 h1:J4Z3XugYzAq85SlyAfqlKVrbf05glMbAOh+QncsDQpE=
github.com/qiniu/x v1.13.10/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c h1:Qky9Z4gbY0gHnt2oSra7YevCS2payh8ieguymIknTeY=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c/go.mod h1:UCzetvoQdU+yfesI6xAL33acsuEbYICGQUcYpGiAW00=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c h1:PXY/AYmMKSuoE+j5ivYZbo7z1v+bByrzHxUQ9soQgK8=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c/go.mod h1:N1y5yuSjxaxzTgTI6NQrMbI/9YA3dZue74P5I346xO4=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16 h1:V/zAuyQF0v6ng+UVwJi+qF0s+P/nEHb/lha3Uf86TQM=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16/go.mod h1:zCbLmeT7a+pH1sknxgdFLiha6xA3gezTtwbTuuNRJWE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
36 changes: 19 additions & 17 deletions cmd/ispx/pkg/github.com/goplus/spx/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,20 @@ func init() {
Name: "spx",
Path: "github.com/goplus/spx",
Deps: map[string]string{
"encoding/json": "json",
"errors": "errors",
"flag": "flag",
"fmt": "fmt",
"github.com/goplus/spx/fs": "fs",
"github.com/goplus/spx/fs/asset": "asset",
"github.com/goplus/spx/fs/zip": "zip",
"github.com/goplus/spx/internal/anim": "anim",
"encoding/json": "json",
"flag": "flag",
"fmt": "fmt",
"github.com/goplus/spx/fs": "fs",
"github.com/goplus/spx/fs/asset": "asset",
"github.com/goplus/spx/fs/zip": "zip",
"github.com/goplus/spx/internal/audiorecord": "audiorecord",
"github.com/goplus/spx/internal/coroutine": "coroutine",
"github.com/goplus/spx/internal/engine": "engine",
"github.com/goplus/spx/internal/gdi": "gdi",
"github.com/goplus/spx/internal/math32": "math32",
"github.com/goplus/spx/internal/time": "time",
"github.com/goplus/spx/internal/tools": "tools",
"github.com/goplus/spx/internal/ui": "ui",
"github.com/realdream-ai/gdspx/pkg/engine": "engine",
"golang.org/x/image/colornames": "colornames",
"image/color": "color",
"github.com/realdream-ai/mathf": "mathf",
"image/jpeg": "jpeg",
"image/png": "png",
"io": "io",
Expand Down Expand Up @@ -61,6 +57,7 @@ func init() {
"Widget": reflect.TypeOf((*q.Widget)(nil)).Elem(),
},
NamedTypes: map[string]reflect.Type{
"BackdropName": reflect.TypeOf((*q.BackdropName)(nil)).Elem(),
"Camera": reflect.TypeOf((*q.Camera)(nil)).Elem(),
"Config": reflect.TypeOf((*q.Config)(nil)).Elem(),
"EffectKind": reflect.TypeOf((*q.EffectKind)(nil)).Elem(),
Expand All @@ -70,7 +67,6 @@ func init() {
"MovingInfo": reflect.TypeOf((*q.MovingInfo)(nil)).Elem(),
"PlayAction": reflect.TypeOf((*q.PlayAction)(nil)).Elem(),
"PlayOptions": reflect.TypeOf((*q.PlayOptions)(nil)).Elem(),
"ProxyUi": reflect.TypeOf((*q.ProxyUi)(nil)).Elem(),
"RotationStyle": reflect.TypeOf((*q.RotationStyle)(nil)).Elem(),
"Sound": reflect.TypeOf((*q.Sound)(nil)).Elem(),
"SpriteImpl": reflect.TypeOf((*q.SpriteImpl)(nil)).Elem(),
Expand All @@ -79,9 +75,14 @@ func init() {
"Value": reflect.TypeOf((*q.Value)(nil)).Elem(),
},
AliasTypes: map[string]reflect.Type{
"Color": reflect.TypeOf((*q.Color)(nil)).Elem(),
"Key": reflect.TypeOf((*int64)(nil)).Elem(),
"Pos": reflect.TypeOf((*int)(nil)).Elem(),
"Color": reflect.TypeOf((*q.Color)(nil)).Elem(),
"Key": reflect.TypeOf((*int64)(nil)).Elem(),
"Pos": reflect.TypeOf((*int)(nil)).Elem(),
"SoundName": reflect.TypeOf((*string)(nil)).Elem(),
"SpriteAnimationName": reflect.TypeOf((*string)(nil)).Elem(),
"SpriteCostumeName": reflect.TypeOf((*string)(nil)).Elem(),
"SpriteName": reflect.TypeOf((*string)(nil)).Elem(),
"WidgetName": reflect.TypeOf((*string)(nil)).Elem(),
},
Vars: map[string]reflect.Value{
"Key0": reflect.ValueOf(&q.Key0),
Expand Down Expand Up @@ -196,9 +197,10 @@ func init() {
"Gopt_SpriteImpl_Clone__0": reflect.ValueOf(q.Gopt_SpriteImpl_Clone__0),
"Gopt_SpriteImpl_Clone__1": reflect.ValueOf(q.Gopt_SpriteImpl_Clone__1),
"Iround": reflect.ValueOf(q.Iround),
"NewUiNode": reflect.ValueOf(q.NewUiNode),
"RGB": reflect.ValueOf(q.RGB),
"RGBA": reflect.ValueOf(q.RGBA),
"RGBAf": reflect.ValueOf(q.RGBAf),
"RGBf": reflect.ValueOf(q.RGBf),
"Rand__0": reflect.ValueOf(q.Rand__0),
"Rand__1": reflect.ValueOf(q.Rand__1),
"Sched": reflect.ValueOf(q.Sched),
Expand Down
28 changes: 9 additions & 19 deletions cmd/ispx/pkg/github.com/realdream-ai/gdspx/pkg/engine/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ func init() {
Name: "engine",
Path: "github.com/realdream-ai/gdspx/pkg/engine",
Deps: map[string]string{
"fmt": "fmt",
"math": "math",
"reflect": "reflect",
"runtime/debug": "debug",
"sort": "sort",
"sync": "sync",
"fmt": "fmt",
"github.com/realdream-ai/mathf": "mathf",
"math": "math",
"reflect": "reflect",
"runtime/debug": "debug",
"sort": "sort",
"sync": "sync",
},
Interfaces: map[string]reflect.Type{
"IAudioMgr": reflect.TypeOf((*q.IAudioMgr)(nil)).Elem(),
Expand All @@ -40,18 +41,13 @@ func init() {
NamedTypes: map[string]reflect.Type{
"Action0": reflect.TypeOf((*q.Action0)(nil)).Elem(),
"CallbackInfo": reflect.TypeOf((*q.CallbackInfo)(nil)).Elem(),
"Color": reflect.TypeOf((*q.Color)(nil)).Elem(),
"EngineCallbackInfo": reflect.TypeOf((*q.EngineCallbackInfo)(nil)).Elem(),
"Event0": reflect.TypeOf((*q.Event0)(nil)).Elem(),
"KeyCodeEnum": reflect.TypeOf((*q.KeyCodeEnum)(nil)).Elem(),
"Node": reflect.TypeOf((*q.Node)(nil)).Elem(),
"Object": reflect.TypeOf((*q.Object)(nil)).Elem(),
"Rect2": reflect.TypeOf((*q.Rect2)(nil)).Elem(),
"Sprite": reflect.TypeOf((*q.Sprite)(nil)).Elem(),
"UiNode": reflect.TypeOf((*q.UiNode)(nil)).Elem(),
"Vec2": reflect.TypeOf((*q.Vec2)(nil)).Elem(),
"Vec3": reflect.TypeOf((*q.Vec3)(nil)).Elem(),
"Vec4": reflect.TypeOf((*q.Vec4)(nil)).Elem(),
},
AliasTypes: map[string]reflect.Type{},
Vars: map[string]reflect.Value{
Expand All @@ -72,26 +68,20 @@ func init() {
},
Funcs: map[string]reflect.Value{
"Abs": reflect.ValueOf(q.Abs),
"Angle": reflect.ValueOf(q.Angle),
"AngleToPoint": reflect.ValueOf(q.AngleToPoint),
"BindSceneInstantiatedSprite": reflect.ValueOf(q.BindSceneInstantiatedSprite),
"Clamp01Vec2": reflect.ValueOf(q.Clamp01Vec2),
"Clamp01f": reflect.ValueOf(q.Clamp01f),
"ClampVec2": reflect.ValueOf(q.ClampVec2),
"Clampf": reflect.ValueOf(q.Clampf),
"ClearAllSprites": reflect.ValueOf(q.ClearAllSprites),
"DealySpriteCall": reflect.ValueOf(q.DealySpriteCall),
"DegToRad": reflect.ValueOf(q.DegToRad),
"DelayCall": reflect.ValueOf(q.DelayCall),
"GetSprite": reflect.ValueOf(q.GetSprite),
"InternalInitEngine": reflect.ValueOf(q.InternalInitEngine),
"InternalUpdateEngine": reflect.ValueOf(q.InternalUpdateEngine),
"LerpVec2": reflect.ValueOf(q.LerpVec2),
"Lerpf": reflect.ValueOf(q.Lerpf),
"MoveToward": reflect.ValueOf(q.MoveToward),
"NewEvent0": reflect.ValueOf(q.NewEvent0),
"PrintStack": reflect.ValueOf(q.PrintStack),
"RadToDeg": reflect.ValueOf(q.RadToDeg),
"Sign": reflect.ValueOf(q.Sign),
"Signf": reflect.ValueOf(q.Signf),
"TweenPos": reflect.ValueOf(q.TweenPos),
"TweenPos2": reflect.ValueOf(q.TweenPos2),
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/spx/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.21.3

require (
github.com/goplus/spx v0.0.0-00010101000000-000000000000
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206074307-ff60dc288a6c
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206104940-c8b4a8f07f1c
)

require github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16 // indirect

require (
github.com/pkg/errors v0.9.1 // indirect
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c // indirect
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd // indirect
)
Expand Down
8 changes: 4 additions & 4 deletions cmd/spx/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c h1:Qky9Z4gbY0gHnt2oSra7YevCS2payh8ieguymIknTeY=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c/go.mod h1:UCzetvoQdU+yfesI6xAL33acsuEbYICGQUcYpGiAW00=
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206074307-ff60dc288a6c h1:8RdPQBcZ6DKBi8ZjAU/TUWHpcyRN24qS2LPO3XfGw34=
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206074307-ff60dc288a6c/go.mod h1:13E+n0eYg6BgtOYJ7asaMnyfXW+MsM75ZImE7jb/bQ8=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c h1:PXY/AYmMKSuoE+j5ivYZbo7z1v+bByrzHxUQ9soQgK8=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c/go.mod h1:N1y5yuSjxaxzTgTI6NQrMbI/9YA3dZue74P5I346xO4=
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206104940-c8b4a8f07f1c h1:74hhiLEuxNeOMNU7EEvVRuK9E1qo9UOY6Twf5pjKW2E=
github.com/realdream-ai/gdspx/cmd/gdspx v0.0.0-20241206104940-c8b4a8f07f1c/go.mod h1:13E+n0eYg6BgtOYJ7asaMnyfXW+MsM75ZImE7jb/bQ8=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16 h1:V/zAuyQF0v6ng+UVwJi+qF0s+P/nEHb/lha3Uf86TQM=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16/go.mod h1:zCbLmeT7a+pH1sknxgdFLiha6xA3gezTtwbTuuNRJWE=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
Expand Down
23 changes: 14 additions & 9 deletions cmd/spx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,25 @@ type CmdTool struct {

func main() {
cmd := &CmdTool{}
if os.Args[1] == "installispx" {
installIspx()
return
}
cmdtool.RunCmd(cmd, "gdspx", version, proejct_fs, "template/project", "project", "installispx")
}

func installIspx() {
filePath := getISpxPath()
rawdir, _ := os.Getwd()
os.Chdir("../ispx")
envVars := []string{"GOOS=js", "GOARCH=wasm"}
util.RunGolang(envVars, "build", "-o", filePath)
os.Chdir(rawdir)
}

func (pself *CmdTool) CheckEnv() error {
dir, _ := filepath.Abs(cmdtool.TargetDir)

exist := CheckFileExist(dir, "spx", false)
if !exist {
return fmt.Errorf("can not find spx file, not a valid project dir")
Expand Down Expand Up @@ -87,15 +101,6 @@ func CheckFileExist(dir, ext string, recursive bool) bool {
return false
}
func (pself *CmdTool) OnBeforeCheck(cmd string) error {
switch cmd {
case "installispx":
filePath := getISpxPath()
rawdir, _ := os.Getwd()
os.Chdir("../ispx")
envVars := []string{"GOOS=js", "GOARCH=wasm"}
util.RunGolang(envVars, "build", "-o", filePath)
os.Chdir(rawdir)
}
webDir, _ = filepath.Abs(filepath.Join(cmdtool.ProjectDir, ".builds", "web"))
return nil
}
Expand Down
1 change: 0 additions & 1 deletion cmd/spx/template/project/.builds/web/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class GameApp {
await this.waitFsSyncDone(this.editorCanvas)
this.onProgress(0.9);
await this.mergeProjectWithEngineRes()
window.goLoadData(new Uint8Array(this.projectData));
this.onProgress(1.0);
await this.updateProjectHash(this.curProjectHash)
this.logVerbose("==> editor start done")
Expand Down
2 changes: 1 addition & 1 deletion cmd/spx/template/project/go.mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require github.com/goplus/spx v0.0.0-00010101000000-000000000000

require (
github.com/pkg/errors v0.9.1 // indirect
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c
golang.org/x/image v0.18.0 // indirect
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd // indirect
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.3

require (
github.com/pkg/errors v0.9.1
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c h1:Qky9Z4gbY0gHnt2oSra7YevCS2payh8ieguymIknTeY=
github.com/realdream-ai/gdspx v0.0.0-20241206074307-ff60dc288a6c/go.mod h1:UCzetvoQdU+yfesI6xAL33acsuEbYICGQUcYpGiAW00=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c h1:PXY/AYmMKSuoE+j5ivYZbo7z1v+bByrzHxUQ9soQgK8=
github.com/realdream-ai/gdspx v0.0.0-20241206104940-c8b4a8f07f1c/go.mod h1:N1y5yuSjxaxzTgTI6NQrMbI/9YA3dZue74P5I346xO4=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16 h1:V/zAuyQF0v6ng+UVwJi+qF0s+P/nEHb/lha3Uf86TQM=
github.com/realdream-ai/mathf v0.0.0-20241205091834-a85cb2402a16/go.mod h1:zCbLmeT7a+pH1sknxgdFLiha6xA3gezTtwbTuuNRJWE=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
Expand Down
6 changes: 2 additions & 4 deletions internal/engine/sync.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ func SyncPlatformSetTimeScale(time_scale float64) {
}

// IResMgr
func SyncResCreateAnimation(sprite_type_name string, anim_name string, context string, fps int64, is_altas bool) int64 {
var _ret1 int64
func SyncResCreateAnimation(sprite_type_name string, anim_name string, context string, fps int64, is_altas bool) {
WaitMainThread(func() {
_ret1 = ResMgr.CreateAnimation(sprite_type_name, anim_name, context, fps, is_altas)
ResMgr.CreateAnimation(sprite_type_name, anim_name, context, fps, is_altas)
})
return _ret1
}
func SyncResSetLoadMode(is_direct_mode bool) {
WaitMainThread(func() {
Expand Down

0 comments on commit aaa1a57

Please sign in to comment.