提示词:补齐 PythonPlugin C API WASM shim 符号
结论:按 LinuxCNC src/emc/pythonplugin/python_plugin.cc 的初始化、导入、配置和 callable 调用路径,把 PyConfig/PyStatus、PyImport_*、PyDict_SetItemString、Py_InitializeFromConfig、PyRun_SimpleString、Py_GetVersion、PyObject_Call 等符号纳入 inert WASM Python C API shim;真实 Python 执行仍保持禁用。 检查:./test-linuxcnc-wasm-python-c-api-symbols.sh 通过;./test-native.sh 通过;./test-linuxcnc-source-link.sh 通过。
This commit is contained in:
@@ -4,9 +4,9 @@ set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# LinuxCNC source basis: this probe derives required Python C API exports from
|
||||
# RS274 Python/remap sources in src/emc/rs274ngc, including
|
||||
# interp_namedparams.cc, interp_o_word.cc, interp_python.cc, interp_remap.cc,
|
||||
# rs274ngc_pre.cc, and the py*/module binding sources.
|
||||
# RS274 Python/remap sources in src/emc/rs274ngc and from
|
||||
# src/emc/pythonplugin/python_plugin.cc initialization/configuration paths,
|
||||
# while compiling only the RS274 binding objects that need wasm-safe symbols.
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
|
||||
@@ -58,6 +58,10 @@ linuxcnc_source_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-f
|
||||
src/emc/rs274ngc/gcodemodule.cc)
|
||||
mapfile -t linuxcnc_sources <<<"$linuxcnc_source_output"
|
||||
python_binding_sources=("${linuxcnc_sources[@]:6}")
|
||||
python_plugin_source_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-files.sh \
|
||||
src/emc/pythonplugin/python_plugin.cc)
|
||||
mapfile -t python_plugin_sources <<<"$python_plugin_source_output"
|
||||
python_token_sources=("${linuxcnc_sources[@]}" "${python_plugin_sources[@]}")
|
||||
|
||||
common_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-common-cxxflags.sh)
|
||||
mapfile -t common_flags <<<"$common_flag_output"
|
||||
@@ -143,14 +147,14 @@ source_symbols_signature="$build_dir/python-c-api.source-symbols.signature"
|
||||
source_symbols_next_signature="$build_dir/python-c-api.source-symbols.signature.next"
|
||||
{
|
||||
printf 'SOURCE_SYMBOL_RULE_VERSION=1\n'
|
||||
printf 'LINUXCNC_SOURCES:\n'
|
||||
printf '%s\n' "${linuxcnc_sources[@]}"
|
||||
printf 'LINUXCNC_TOKEN_SOURCES:\n'
|
||||
printf '%s\n' "${python_token_sources[@]}"
|
||||
printf 'SOURCE_STATS:\n'
|
||||
stat -c 'SOURCE=%n:%s:%y' "${linuxcnc_sources[@]}"
|
||||
stat -c 'SOURCE=%n:%s:%y' "${python_token_sources[@]}"
|
||||
} > "$source_symbols_next_signature"
|
||||
if [[ ! -f "$source_symbols_signature" || ! -f "$build_dir/linuxcnc.py-tokens" ]] ||
|
||||
! cmp -s "$source_symbols_signature" "$source_symbols_next_signature"; then
|
||||
rg -o 'Py[A-Za-z0-9_]+' "${linuxcnc_sources[@]}" \
|
||||
rg -o 'Py[A-Za-z0-9_]+' "${python_token_sources[@]}" \
|
||||
| sed 's/^.*://' \
|
||||
| LC_ALL=C sort -u \
|
||||
> "$build_dir/linuxcnc.py-tokens"
|
||||
@@ -204,12 +208,14 @@ awk '
|
||||
$0 == "PyModuleDef_HEAD_INIT" { next }
|
||||
$0 == "Py_TPFLAGS_DEFAULT" { next }
|
||||
$0 == "PyCFunction" { next }
|
||||
$0 == "PyConfig" { next }
|
||||
$0 == "PyGetSetDef" { next }
|
||||
$0 == "PyMemberDef" { next }
|
||||
$0 == "PyMethodDef" { next }
|
||||
$0 == "PyModuleDef" { next }
|
||||
$0 == "PyMODINIT_FUNC" { next }
|
||||
$0 == "PyObject_New" { next }
|
||||
$0 == "PyStatus" { next }
|
||||
$0 == "PyInit_emccanon" { next }
|
||||
$0 == "PyInit_gcode" { next }
|
||||
$0 == "PyInit_interpreter" { next }
|
||||
|
||||
Reference in New Issue
Block a user