port(2P step 2): ScriptLib/PythonLauncher on the embedded interpreter
Link mtpython into port_logic and copy 40250's ScriptLib launcher across: PythonLauncher, PythonUtils and PythonMarshal, plus the 12 forwarding headers that make its `#include <Python-2.7/*>` lines compile unchanged. symtable.h forward-declares mod_ty rather than including Python-ast.h, whose one-word macros (Delete, Module, Set, Print) collide with EterLib/Pool.h — the same clash 40250 sidestepped by commenting out PySymtable_Build. Two `// PORT:` edits: `unsigned char(val)` is an MSVC extension (PythonUtils.cpp, twice), and PyObject_AsCharBuffer wants a Py_ssize_t* (TraceFunc). port_python_launcher_test drives the launcher in the order UserInterface.cpp does (:241-434): Create(), __DEBUG__/__COMMAND_LINE__, TRUE/FALSE, a CRLF script through RunMemoryTextFile, a .pyc through RunCompiledFile, then RunFile reading system.py out of the real pack. It stops at `ImportError: No module named app`, i.e. the first C++ module RunMainScript registers — that is the 2V0 slice, and the stdlib behind it is step 3. The host flags (Py_NoSiteFlag and friends) sit in the test for now; step 3 moves them into the platform layer. port-map statuses are set only for what the test actually executes: 10 of 12 launcher functions and 4 of 11 marshal ones (the small-.pyc path delegates to CPython's own reader, so the ported r_object stays unreached). PythonUtils compiles but nothing calls it until the binding modules arrive, so it stays TODO. Windows has no mtpython yet, so port_logic drops ScriptLib and the shims there. Tests: macOS ctest 27/27 incl. port.python_launcher; port_logic (with ScriptLib) also compiles for android arm64 (NDK API 24) and ios arm64. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+12
-4
@@ -82,7 +82,7 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
||||
| — | 定下目录结构,评估内嵌 Python;Android 独立程序验证 | 完成(9d0e50de、b02c49bb) |
|
||||
| **2A** | 基础:Win32 类型层、参考公共头的最小闭包、`port_logic` CMake 目标、platform 接口骨架、头文件可编译门禁、port-map 重新基线 | **进行中**(剩 Python 库闭包头,等 2P) |
|
||||
| 2R | 资源包能力盘点:EPK 类型/密钥/覆盖顺序/路径大小写/移动端交付 | 完成:只有 NONE/COMPRESS/SECURITY,不需要服务器密钥;设备上直接读 EPK |
|
||||
| **2P** | CPython 2.7.18 编进 libmtgodot,五个平台分别配置和验证 | **进行中**:step 1(静态库 + macOS/Android/iOS 配置)完成 |
|
||||
| **2P** | CPython 2.7.18 编进 libmtgodot,五个平台分别配置和验证 | **进行中**:step 1(静态库 + macOS/Android/iOS 配置)、step 2(ScriptLib 进 `port_logic`)完成 |
|
||||
| 2D | 数据源切到 40250(msm 路径、proto、资源根、严格资源测试) | 完成(5a26e93f、232d0461、240d2827、a9b31dec);资源根只切了 proto/pack 后端,其余按第 5 节由 2V 切片逐个切换 |
|
||||
| **2V0** | UI 壳:真实 `PythonLauncher/wndMgr/grp/app` + platform UI,其他玩法模块用桩,显示并操作 Logo/Popup | 需要 2A、2P 和 root/uiscript 子集 |
|
||||
| **2V1** | 登录/选角:真实 `net` phase、登录/选角脚本及所需模块,走到 Loading | 2V0 之后 |
|
||||
@@ -286,6 +286,14 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
||||
`extension/tests/py_embed_test.cpp`(ctest `python.embed`)。三处 vendor 补丁见 `docs/THIRD-PARTY.md`。
|
||||
Linux/Windows 见下表。
|
||||
2. 静态链接进 `libmtgodot`,照抄 `ScriptLib/PythonLauncher.cpp`。
|
||||
**已完成**:`ScriptLib/{PythonLauncher,PythonUtils,PythonMarshal}.{h,cpp}` 进入 `port_logic`(`mt3p::python`),
|
||||
`common/shim/sdk/Python-2.7/` 12 个转发头让 40250 的 `#include <Python-2.7/*>` 原样编译
|
||||
(`symtable.h` 自带 `mod_ty` 前向声明,绕开 `Python-ast.h` 的 `Delete`/`Module` 等单词宏与 `EterLib/Pool.h` 冲突)。
|
||||
`extension/tests/port_python_launcher_test.cpp`(ctest `port.python_launcher`)按 `UserInterface.cpp:241-434` 的顺序跑:
|
||||
`Create()` → `__DEBUG__`/`__COMMAND_LINE__` → `TRUE/FALSE` → `RunMemoryTextFile`(CRLF)→ `RunCompiledFile`(.pyc)
|
||||
→ `RunFile("system.py")` 从真 pack 里取脚本,停在 `ImportError: No module named app`,即 2V0 的 C++ 模块。
|
||||
`Py_NoSiteFlag` 等宿主标志目前在测试里设置,step 3 移进 platform 层。Windows 没有 `mtpython`,
|
||||
`port_logic` 会自动排除 ScriptLib 和这些转发头。
|
||||
3. `pack` 模块通过 `asset_io` 读取 40250 的 root/uiscript。标准库沿用已验证的 `python27.zip + sys.path`:
|
||||
- 桌面端把 zip 放在 CPython 可读的真实文件系统路径;
|
||||
- Android/iOS 首次启动从应用资源复制到应用沙盒,校验提交在资源清单中的 sha256,再加入 `sys.path`;
|
||||
@@ -295,9 +303,9 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
||||
|
||||
| 平台 | 状态 |
|
||||
| --- | --- |
|
||||
| macOS arm64 | step 1 完成:`mtpython` 静态库 + `python.embed` 测试(39 个内建模块全部 import,标准库 codec/pickle 通过);`system.py` 在 app 进程内未做 |
|
||||
| Android arm64 | step 1 完成:NDK API 24 交叉编译出 `libmtpython.a`;独立可执行文件在真机跑通(b02c49bb);APK 进程内未做 |
|
||||
| iOS arm64 | step 1 完成:iphoneos arm64 编出 133 个目标文件,无 `_system`/`_fork`/`_popen` 未定义符号;真机未跑 |
|
||||
| macOS arm64 | step 1、2 完成:`mtpython` 静态库 + `python.embed`(39 个内建模块全部 import,标准库 codec/pickle 通过)+ `port.python_launcher`(`CPythonLauncher` 跑到 `system.py` 的第一个 import);`system.py` 在 app 进程内未做 |
|
||||
| Android arm64 | step 1 完成:NDK API 24 交叉编译出 `libmtpython.a`;独立可执行文件在真机跑通(b02c49bb);APK 进程内未做。step 2 的 ScriptLib 只在 macOS 编译过 |
|
||||
| iOS arm64 | step 1 完成:iphoneos arm64 编出 133 个目标文件,无 `_system`/`_fork`/`_popen` 未定义符号;真机未跑。step 2 的 ScriptLib 只在 macOS 编译过 |
|
||||
| Linux x86_64 | 未做(`gen_pyconfig.sh linux` 需要 Linux 主机,当前无) |
|
||||
| Windows x64 | 未做:上游 2.7 只支持 MSVC + `PC/pyconfig.h`,而本项目 Windows 门禁是 MinGW 交叉编译,`PC/pyconfig.h` 的 gnu-win32 分支不设 `HAVE_UNISTD_H`,`posixmodule.c`/`dynload_win.c` 与 MinGW 头文件冲突,需要一套补丁——在本步骤(step 4)决定走 MSVC 还是打补丁 |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user