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:
@@ -9,6 +9,12 @@ if(WIN32)
|
||||
# Stand-ins for Windows SDK headers; on Windows the real ones are used.
|
||||
list(FILTER MT_PORT_HEADERS EXCLUDE REGEX "/common/shim/win32/")
|
||||
endif()
|
||||
# The script layer needs the embedded interpreter (mt3p::python), which has no Windows build yet
|
||||
# (PORT-PLAN 批次 2P step 4). Without it, ScriptLib and its <Python-2.7/*> shims are left out.
|
||||
if(NOT TARGET mtpython)
|
||||
list(FILTER MT_PORT_SOURCES EXCLUDE REGEX "/ScriptLib/")
|
||||
list(FILTER MT_PORT_HEADERS EXCLUDE REGEX "/ScriptLib/|/common/shim/sdk/Python-2\\.7/")
|
||||
endif()
|
||||
|
||||
add_library(port_logic STATIC ${MT_PORT_SOURCES})
|
||||
target_include_directories(port_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -20,8 +26,11 @@ if(NOT WIN32)
|
||||
endif()
|
||||
target_include_directories(port_logic PUBLIC ${MT_PORT_SHIMS})
|
||||
# Libraries 40250 links that are vendored as-is: <lzo/lzo1x.h> (EterBase/lzo.h), <cryptopp/*>
|
||||
# (EterBase/cipher.h).
|
||||
# (EterBase/cipher.h), <Python-2.7/*> (ScriptLib).
|
||||
target_link_libraries(port_logic PUBLIC mt3p::minilzo mt3p::cryptopp)
|
||||
if(TARGET mtpython)
|
||||
target_link_libraries(port_logic PUBLIC mt3p::python)
|
||||
endif()
|
||||
# 40250 sources carry MSVC `#pragma warning(...)` lines verbatim, and non-literal printf formats
|
||||
# (EterImageLib/StdAfx.h) that the Android toolchain turns into errors.
|
||||
set(MT_PORT_WARNING_FLAGS)
|
||||
@@ -123,6 +132,9 @@ endforeach()
|
||||
add_library(port_header_gate OBJECT ${MT_PORT_GATE_SOURCES})
|
||||
target_include_directories(port_header_gate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MT_PORT_SHIMS})
|
||||
target_link_libraries(port_header_gate PRIVATE mt3p::minilzo mt3p::cryptopp)
|
||||
if(TARGET mtpython)
|
||||
target_link_libraries(port_header_gate PRIVATE mt3p::python)
|
||||
endif()
|
||||
target_compile_features(port_header_gate PRIVATE cxx_std_20)
|
||||
target_compile_definitions(port_header_gate PRIVATE "NANOBEGIN=" "NANOEND=")
|
||||
if(MINGW)
|
||||
@@ -148,4 +160,12 @@ if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||
target_link_libraries(port_eterpack_test PRIVATE port_platform)
|
||||
add_test(NAME port.eterpack COMMAND $<TARGET_FILE:port_eterpack_test> ${MT_40250_CLIENT})
|
||||
set_tests_properties(port.eterpack PROPERTIES SKIP_RETURN_CODE 77)
|
||||
|
||||
if(TARGET mtpython)
|
||||
add_executable(port_python_launcher_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_python_launcher_test.cpp)
|
||||
target_link_libraries(port_python_launcher_test PRIVATE port_platform)
|
||||
add_test(NAME port.python_launcher
|
||||
COMMAND $<TARGET_FILE:port_python_launcher_test> ${MT_40250_CLIENT})
|
||||
set_tests_properties(port.python_launcher PROPERTIES SKIP_RETURN_CODE 77)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user