结论:已完成浏览器侧真实加载验证,M428/M429/M430 的配置入口进一步从 LinuxCNC INI/HALFILE/REMAP 来源生成,native 与 source-link 验证通过。
129 lines
4.5 KiB
Bash
Executable File
129 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
|
cxx=${CXX:-g++}
|
|
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_python_c_api_symbols.XXXXXX")
|
|
|
|
trap 'rm -rf "$build_dir"' EXIT
|
|
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh --root-only
|
|
|
|
python_c_api_shim=$(./list-linuxcnc-wasm-safe-shims.sh python_c_api_shim.cc)
|
|
runtime_shim=$(./list-linuxcnc-wasm-safe-shims.sh linuxcnc_runtime_shim.cc)
|
|
linuxcnc_source_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-files.sh \
|
|
src/emc/rs274ngc/interp_namedparams.cc \
|
|
src/emc/rs274ngc/interp_o_word.cc \
|
|
src/emc/rs274ngc/interp_python.cc \
|
|
src/emc/rs274ngc/interp_remap.cc \
|
|
src/emc/rs274ngc/interp_setup.cc \
|
|
src/emc/rs274ngc/rs274ngc_pre.cc \
|
|
src/emc/rs274ngc/pyarrays.cc \
|
|
src/emc/rs274ngc/pyblock.cc \
|
|
src/emc/rs274ngc/pyemctypes.cc \
|
|
src/emc/rs274ngc/pyinterp1.cc \
|
|
src/emc/rs274ngc/pyparamclass.cc \
|
|
src/emc/rs274ngc/canonmodule.cc \
|
|
src/emc/rs274ngc/interpmodule.cc \
|
|
src/emc/rs274ngc/gcodemodule.cc)
|
|
mapfile -t linuxcnc_sources <<<"$linuxcnc_source_output"
|
|
python_binding_sources=("${linuxcnc_sources[@]:6}")
|
|
|
|
common_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-common-cxxflags.sh)
|
|
mapfile -t common_flags <<<"$common_flag_output"
|
|
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$python_c_api_shim" \
|
|
-o "$build_dir/python_c_api_shim.o"
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$runtime_shim" \
|
|
-o "$build_dir/runtime_shim.o"
|
|
|
|
nm --defined-only "$build_dir/python_c_api_shim.o" \
|
|
| awk '$2 ~ /^[A-Z]$/ {print $3}' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/shim.exports"
|
|
|
|
rg -o 'Py[A-Za-z0-9_]+' "${linuxcnc_sources[@]}" \
|
|
| sed 's/^.*://' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/linuxcnc.py-tokens"
|
|
|
|
awk '
|
|
$0 == "PyObject" { next }
|
|
$0 == "PyTypeObject" { next }
|
|
$0 == "Py_None" { next }
|
|
$0 == "Py_TYPE" { next }
|
|
$0 == "Py_XDECREF" { next }
|
|
$0 == "Py_DECREF" { next }
|
|
$0 == "PyList_SET_ITEM" { next }
|
|
$0 == "PyTuple_SET_ITEM" { next }
|
|
$0 == "PyObject_HEAD" { next }
|
|
$0 == "PyVarObject_HEAD_INIT" { next }
|
|
$0 == "PyModuleDef_HEAD_INIT" { next }
|
|
$0 == "Py_TPFLAGS_DEFAULT" { next }
|
|
$0 == "PyCFunction" { next }
|
|
$0 == "PyGetSetDef" { next }
|
|
$0 == "PyMemberDef" { next }
|
|
$0 == "PyMethodDef" { next }
|
|
$0 == "PyModuleDef" { next }
|
|
$0 == "PyMODINIT_FUNC" { next }
|
|
$0 == "PyObject_New" { next }
|
|
$0 == "PyInit_emccanon" { next }
|
|
$0 == "PyInit_gcode" { next }
|
|
$0 == "PyInit_interpreter" { next }
|
|
$0 == "PyErr_Ocurred" { next }
|
|
$0 == "PyFloat_CheckAndError" { next }
|
|
$0 == "PyLong_CheckAndError" { next }
|
|
$0 == "Python" { next }
|
|
$0 == "PythonPlugin" { next }
|
|
{ print }
|
|
' "$build_dir/linuxcnc.py-tokens" > "$build_dir/required.exports"
|
|
|
|
comm -23 "$build_dir/required.exports" "$build_dir/shim.exports" > "$build_dir/missing.exports"
|
|
if [[ -s "$build_dir/missing.exports" ]]; then
|
|
echo "missing wasm Python C API shim exports used by LinuxCNC rs274 sources:" >&2
|
|
cat "$build_dir/missing.exports" >&2
|
|
exit 1
|
|
fi
|
|
|
|
for macro in Py_None Py_TYPE Py_XDECREF Py_DECREF PyTuple_SET_ITEM PyList_SET_ITEM PyObject_New; do
|
|
if ! grep -F "#define $macro" core/wasm_shims/boost/python/object.hpp >/dev/null; then
|
|
echo "missing wasm Python C API shim macro used by LinuxCNC rs274 sources: $macro" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
grep -F "Py_DecRef" core/wasm_shims/boost/python/object.hpp >/dev/null
|
|
grep -F "_Py_NoneStructPtr" core/wasm_shims/boost/python/object.hpp >/dev/null
|
|
grep -F 'extern "C" PyObject *PyInit_gcode(void)' core/wasm_shims/linuxcnc_runtime_shim.cc >/dev/null
|
|
|
|
for source in "${python_binding_sources[@]}"; do
|
|
object_name=$(basename "$source" .cc)
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$source" \
|
|
-o "$build_dir/$object_name.o"
|
|
done
|
|
|
|
nm -u "$build_dir"/*.o \
|
|
| awk '{print $2}' \
|
|
| sed '/^$/d' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/object.undefined"
|
|
nm --defined-only "$build_dir"/*.o \
|
|
| awk '{print $3}' \
|
|
| sed '/^$/d' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/object.defined"
|
|
comm -23 "$build_dir/object.undefined" "$build_dir/object.defined" \
|
|
| awk '/^_?Py/ { print }' \
|
|
> "$build_dir/object.missing-python"
|
|
if [[ -s "$build_dir/object.missing-python" ]]; then
|
|
echo "missing wasm Python C API object definitions used by LinuxCNC rs274 bindings:" >&2
|
|
cat "$build_dir/object.missing-python" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "linuxcnc wasm Python C API symbol probe passed"
|