Skip to content

Feat: Run the project directly on PC using xgo run . #1072

@joeykchen

Description

@joeykchen

一. (先不管)Godot运行时包含
gdspxrt2.1.36 + gdspxrt2.1.36.pck + runtime.gdextension

二. go动态库编译流程(可看重构后的版本https://github.com/goplus/spx/pull/1071)

func (pself *CmdTool) BuildDll() error {
	// 1. Restore original files (undoing a potential previous step)
	if err := pself.restoreFiles(); err != nil {
		return err
	}

	// 2. Determine the list of target architectures.
	targetArchs, err := pself.determineTargetArchs()
	if err != nil {
		return err
	}

	// 3. Generate Go code and get tags
	tagStr := pself.genGo()

	// 4. Execute the build for each target architecture inside GoDir.
	return pself.withGoDir(func() error {
		if err := pself.executeDllBuild(targetArchs, tagStr); err != nil {
			return err
		}
		// 5. Final check: ensure the resulting library path is set.
		if pself.LibPath == "" {
			return fmt.Errorf("build error: cannot find matched dylib for runtime arch %s", runtime.GOARCH)
		}
		return nil
	})
}
  1. 根据架构选择环境变量(加上CGO_ENABLED=1)
    示例:envs=[CGO_ENABLED=1 GOARCH=arm64]
  2. 编译动态库(重构后去掉了-tags=simulation ),-o指定路径
    示例:[go build -buildmode=c-shared -o /Users/mac/qiniu/spx/tutorial/00-Hello/project/lib/gdspx-darwin-arm64.dylib]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions