chore(build): 搭建并验证 C# / C++(GDExtension) 原生构建环境(4.7.1 Mono)
为「GDScript→C#→C++」性能逃生梯备好可随时启用的工具链,运行时仍 100% GDScript。
C#:新增根 Rogue.csproj(Godot.NET.Sdk/4.7.1,net8.0,程序集名 Rogue);
csharp/ 下既有 3 个骨架 .cs 现可编译,dotnet build 与编辑器 --build-solutions 均 0 错通过。
C++:gdextension/ 下加 godot-cpp 子模块(master,因无 4.6/4.7 分支,配合本工程 dump 的
4.7.1 extension_api.json + gdextension_interface.h 经 custom_api_file 精确匹配 ABI);
SConstruct + 示例扩展 SpellforgeNative(含 PackedFloat32Array 零拷贝热路径写法);
SCons 自动探测 MSVC 构建出 debug .dll,headless 冒烟验证类注册/调用通过
(CLASS_EXISTS=true / multiply=42 / scale_inplace 正确)。
配套:.gitignore 忽略编译中间产物、保留 debug .dll 开箱即用;gdextension/README.md 记录构建/激活/升级流程;
CLAUDE.md 修正引擎版本 4.6→4.7.1 并更新「环境已就绪但休眠」现状。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
# SConstruct — Spellforge C++ GDExtension 构建脚本
|
||||
# 用法(在本目录 gdextension/ 下):
|
||||
# scons # 默认 template_debug,本机平台/架构
|
||||
# scons target=template_release
|
||||
# scons -j8 # 并行编译
|
||||
# 依赖:godot-cpp 子模块(gdextension/godot-cpp)、SCons、C++ 工具链(Windows 用 MSVC,SCons 自动探测 VS)。
|
||||
# API:通过 custom_api_file 指向本工程从 4.7.1 编辑器 dump 的 extension_api.json,保证绑定与引擎精确匹配。
|
||||
import os
|
||||
|
||||
# 将本工程 4.7.1 的 API 注入 godot-cpp(除非命令行显式覆盖 custom_api_file)。
|
||||
ARGUMENTS.setdefault("custom_api_file", os.path.abspath("api/extension_api.json"))
|
||||
|
||||
# 复用 godot-cpp 的构建环境(平台/架构/编译器探测、绑定生成、静态库)。
|
||||
env = SConscript("godot-cpp/SConstruct")
|
||||
|
||||
env.Append(CPPPATH=["src/"])
|
||||
sources = Glob("src/*.cpp")
|
||||
|
||||
libname = "spellforge_native"
|
||||
bindir = "bin"
|
||||
|
||||
if env["platform"] == "macos":
|
||||
target = "{}/lib{}.{}.{}.framework/lib{}.{}.{}".format(
|
||||
bindir, libname, env["platform"], env["target"],
|
||||
libname, env["platform"], env["target"],
|
||||
)
|
||||
else:
|
||||
target = "{}/lib{}{}{}".format(bindir, libname, env["suffix"], env["SHLIBSUFFIX"])
|
||||
|
||||
library = env.SharedLibrary(target, source=sources)
|
||||
|
||||
Default(library)
|
||||
Reference in New Issue
Block a user