refactor: centralize ABI metadata into meta/meta.go

- meta/meta.go: add ABIVersion, ABIVersionMin, 45 dispatch method IDs
- tools/plugindev/cmd_init.go: cabiVersion -> meta.ABIVersion
- tools/plugindev/templates.go: C header comments reference meta.go
This commit is contained in:
JianFeeeee
2026-07-25 14:42:32 +08:00
parent cb7999ca71
commit 1fa3c843ab
4 changed files with 74 additions and 4 deletions

View File

@ -6,9 +6,9 @@ import (
"path/filepath"
"strings"
"text/template"
)
const cabiVersion = 1
"gitcode.com/JianFeeeee/homeagent-sdk/meta"
)
type PlgConfig struct {
Name string `json:"name"`
@ -84,7 +84,7 @@ func cmdInit(args []string) {
Targets: targets,
},
IsLua: isLua,
CABIVersion: cabiVersion,
CABIVersion: meta.ABIVersion,
CABIHeader: tmplCABIHeader,
}

View File

@ -1,3 +1,7 @@
module github.com/JianFeeeee/homeagent-sdk/tools/plugindev
go 1.21
go 1.25.0
require gitcode.com/JianFeeeee/homeagent-sdk v0.0.0
replace gitcode.com/JianFeeeee/homeagent-sdk => ../../

View File

@ -279,9 +279,11 @@ func main() {}
`
// tmplCABIHeader — shared C ABI type definitions for both core and plugin
// 此模板中的常量应与 core/internal/meta/meta.go 保持一致ABI 版本、dispatch method IDs
const tmplCABIHeader = `
#ifndef HOMEAGENT_CABI_H
#define HOMEAGENT_CABI_H
// HOMEAGENT_ABI_VERSION 与 sdk/meta/meta.go ABIVersion 同步
#define HOMEAGENT_ABI_VERSION 1
#ifdef __cplusplus
extern "C" {