From 3a58f1e4951f7b5a3f237dc3f2af860c3b6bb756 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Mon, 8 Jun 2026 15:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E8=A7=84=E5=88=92=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:已接通 vendored LinuxCNC interp_remap.cc 的 NGC REMAP 描述符解析路径,新增 native harness 验证 xyzac/xyzbc 的 M428/M429/M430 映射,未实现自写 M 码语义。 --- wasm-port/docs/compatibility-validation.md | 8 + wasm-port/docs/porting-steps-standalone.md | 7 +- wasm-port/docs/scope-and-baseline.md | 5 +- wasm-port/docs/source-reuse-map.md | 15 +- .../linuxcnc_interp_python_edge_stubs.cpp | 41 +++++ .../linuxcnc_remap_parse_harness.cpp | 146 ++++++++++++++++++ .../tests/native/verify_native_probes.sh | 23 +++ wasm-port/tools/build_native_probes.sh | 59 +++++++ .../verify_no_standalone_cnc_semantics.sh | 7 +- 9 files changed, 300 insertions(+), 11 deletions(-) create mode 100644 wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_python_edge_stubs.cpp create mode 100644 wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_remap_parse_harness.cpp diff --git a/wasm-port/docs/compatibility-validation.md b/wasm-port/docs/compatibility-validation.md index 4f136f6..1c02a0c 100644 --- a/wasm-port/docs/compatibility-validation.md +++ b/wasm-port/docs/compatibility-validation.md @@ -595,3 +595,11 @@ switchkins links, tool tables, and demo programs. It verifies that these commands remain LinuxCNC `REMAP` entries backed by LinuxCNC NGC subroutines using `M68`, `M66`, and `_hal[motion.switchkins-type]`; it does not implement the remap execution path. + +`linuxcnc_remap_parse_harness` links vendored `interp_remap.cc` for the +standalone remap descriptor path. It reads the vendored `xyzac-trt` and +`xyzbc-trt` INI `REMAP` entries, resolves their `remap_subs/*.ngc` files +through LinuxCNC `find_ngc_file()`, and validates the resulting +`_setup.m_remapped` descriptors for `M428`, `M429`, and `M430`. Python +callbacks, O-word remap execution, and HAL synchronization remain runtime +boundaries. diff --git a/wasm-port/docs/porting-steps-standalone.md b/wasm-port/docs/porting-steps-standalone.md index 85d2aff..d7ad704 100644 --- a/wasm-port/docs/porting-steps-standalone.md +++ b/wasm-port/docs/porting-steps-standalone.md @@ -796,11 +796,14 @@ Current five-axis switchkins status: 3. `M428`, `M429`, and `M430` remain LinuxCNC `REMAP` entries backed by vendored LinuxCNC NGC subroutines; do not replace them with standalone M-code handlers. +4. `linuxcnc_remap_parse_harness` now links vendored `interp_remap.cc` and + validates the LinuxCNC `Interp::parse_remap()` path for `xyzac-trt` and + `xyzbc-trt` `M428`/`M429`/`M430` NGC remap descriptors. Next work: -1. Route vendored LinuxCNC remap lookup/execution through the standalone - interpreter harness for NGC remaps. +1. Route vendored LinuxCNC O-word remap execution through the standalone + interpreter harness for parsed NGC remaps. 2. Connect the standalone HAL adapter so LinuxCNC `M68`/`M66` remap synchronization updates and reads `_hal[motion.switchkins-type]`. 3. Add a native machine-session harness for `xyzac-trt` and `xyzbc-trt` diff --git a/wasm-port/docs/scope-and-baseline.md b/wasm-port/docs/scope-and-baseline.md index 6992eeb..3dbac18 100644 --- a/wasm-port/docs/scope-and-baseline.md +++ b/wasm-port/docs/scope-and-baseline.md @@ -72,5 +72,6 @@ Machine baseline is still limited to standalone interpreter, trajectory planner, LinuxCNC identity/trivial kinematics, LinuxCNC `5axiskins` XYZBCW bridge-mill probing, LinuxCNC TRT `xyzac`/`xyzbc` probing, and vendored LinuxCNC five-axis sample machine assets for `M428`, `M429`, and `M430` -switchkins remaps. Full standalone execution of those remaps still needs the -LinuxCNC remap runtime and HAL synchronization boundary connected. +switchkins remaps, including LinuxCNC `interp_remap.cc` descriptor parsing for +TRT NGC remaps. Full standalone execution of those remaps still needs LinuxCNC +O-word remap dispatch and HAL synchronization boundaries connected. diff --git a/wasm-port/docs/source-reuse-map.md b/wasm-port/docs/source-reuse-map.md index 75489f9..b1bbd3d 100644 --- a/wasm-port/docs/source-reuse-map.md +++ b/wasm-port/docs/source-reuse-map.md @@ -40,7 +40,7 @@ Current validation is intentionally mechanical: | Identity/trivial kinematics | `src/emc/kinematics/kinematics.h`, `cubic.h`, `kins_util.c`, `trivkins.c` | Copy unchanged | HAL component lifecycle and RTAPI module metadata are replaced by standalone shims; forward/inverse mapping behavior remains LinuxCNC source | Vendor byte sync, per-file source probes, `linuxcnc_kinematics_probe` | | Switchable 5-axis bridge kinematics | `src/emc/kinematics/5axiskins.c`, `switchkins.c`, `switchkins.h`, `userkfuncs.c`, plus `src/rtapi/rtapi_ctype.h` | Copy unchanged | HAL pin allocation, HAL component lifecycle, and RTAPI module metadata are standalone runtime edges; switchable 5-axis forward/inverse behavior remains LinuxCNC source | Vendor byte sync, per-file source probes, `linuxcnc_5axis_kinematics_probe` | | TRT table-rotary kinematics | `src/emc/kinematics/trtfuncs.c`, `xyzac-trt-kins.c`, `xyzbc-trt-kins.c` | Copy unchanged | HAL pin allocation and switchkins lifecycle stay runtime boundaries; XYZAC/XYZBC TRT forward/inverse behavior remains LinuxCNC source | Vendor byte sync, per-file source probes, `linuxcnc_xyzac_trt_kinematics_probe`, `linuxcnc_xyzbc_trt_kinematics_probe` | -| Five-axis switchkins machine configs and M428/M429/M430 remaps | `configs/sim/axis/vismach/5axis/bridgemill/*`, `table-dual-rotary/*`, and `table-rotary-tilting/*` selected INI, HAL, tool-table, XML, demo, and `remap_subs/*.ngc` files | Copy unchanged | `M428`, `M429`, and `M430` remain LinuxCNC `REMAP` entries that call LinuxCNC NGC subroutines using `M68`, `M66`, `_hal[motion.switchkins-type]`, and the INI/HAL `motion.analog-out-03 => motion.switchkins-type` link; standalone execution of these remaps still requires the interpreter remap runtime and HAL synchronization edge to be connected | Vendor byte sync, `linuxcnc_5axis_remap_asset_probe`, browser INI panel sample loaded from vendored `xyzab-tdr.ini` | +| Five-axis switchkins machine configs and M428/M429/M430 remaps | `configs/sim/axis/vismach/5axis/bridgemill/*`, `table-dual-rotary/*`, and `table-rotary-tilting/*` selected INI, HAL, tool-table, XML, demo, and `remap_subs/*.ngc` files plus `src/emc/rs274ngc/interp_remap.cc` | Copy unchanged | `M428`, `M429`, and `M430` remain LinuxCNC `REMAP` entries that call LinuxCNC NGC subroutines using `M68`, `M66`, `_hal[motion.switchkins-type]`, and the INI/HAL `motion.analog-out-03 => motion.switchkins-type` link; standalone remap descriptor parsing now routes through vendored `Interp::parse_remap()` and `find_ngc_file()`, while full O-word remap execution and HAL synchronization remain runtime edges | Vendor byte sync, `linuxcnc_5axis_remap_asset_probe`, `linuxcnc_remap_parse_harness`, browser INI panel sample loaded from vendored `xyzab-tdr.ini` | | Additional non-switchable kinematics | `src/emc/kinematics/corexykins.c`, `rotatekins.c`, `rosekins.c`, `maxkins.c`, `lineardeltakins.c`, `lineardeltakins-common.h`, `rotarydeltakins.c`, `rotarydeltakins-common.h`, `scorbot-kins.c`, `tripodkins.c`, `scarakins.c`, `pumakins.c`, `pumakins.h`, `genhexkins.c`, `genhexkins.h`, `genserfuncs.c`, `genserkins.c`, `genserkins.h`, `ugenserkins.c`, `pentakins.c`, `pentakins.h`, `cubic.c` | Copy unchanged | HAL pin allocation, HAL parameter allocation, HAL component lifecycle, RTAPI module metadata, Go math C/C++ linkage, switchkins iterative-forward warmup, and userspace test-program process entry remain standalone runtime edges; forward/inverse behavior remains LinuxCNC source where the module exposes it | Vendor byte sync, per-file source probes, `linuxcnc_corexy_kinematics_probe`, `linuxcnc_rotate_kinematics_probe`, `linuxcnc_rose_kinematics_probe`, `linuxcnc_max_kinematics_probe`, `linuxcnc_lineardelta_kinematics_probe`, `linuxcnc_rotarydelta_kinematics_probe`, `linuxcnc_scorbot_kinematics_probe`, `linuxcnc_tripod_kinematics_probe`, `linuxcnc_scara_kinematics_probe`, `linuxcnc_puma_kinematics_probe`, `linuxcnc_genser_kinematics_probe`, `linuxcnc_genhex_kinematics_probe`, `linuxcnc_pentakins_kinematics_probe` | | Trajectory planner | `src/emc/tp/tp.c`, `tc.c`, `tcq.c`, `spherical_arc.c`, `blendmath.c`, `sp_scurve.c`, `ruckig_wrapper.c`, plus matching `*.h` files | Copy unchanged | Native realtime scheduling and motion process state are replaced by standalone probe setup; the WASM TP probe uses the same deterministic status/config boundary and calls vendored TP APIs through a narrow C ABI | Vendor byte sync, per-file source probes, `linuxcnc_tp_api_probe`, `tests/wasm/node/verify_tp_wasm.sh` | | Ruckig C planner support | Selected `src/emc/tp/cruckig/*.c` and `*.h` files in the manifest | Copy unchanged | Used as LinuxCNC planner support code through vendored TP sources | Vendor byte sync, per-file source probes, `tests/wasm/node/verify_tp_wasm.sh` | @@ -59,7 +59,7 @@ Current validation is intentionally mechanical: | RTAPI | `rtapi_*.h`, TP, posemath, motion headers | Minimal standalone shim in `runtime/core/shims/rtapi.h` | | NML transport | `emc.hh`, motion/NML type headers | Transport is not ported; only the status/type edges needed by vendored compute code are exposed through standalone shims and probes | | HAL runtime | named parameter lookup, kinematics component lifecycle, and runtime status edges | Standalone HAL adapter under `runtime/core/linuxcnc_wrap/` | -| Python/remap | `rs274ngc_pre.cc`, `interp_o_word.cc`, remap hooks, selected LinuxCNC `configs/sim/axis/vismach/5axis/*/remap_subs/*.ngc` files | Stubbed at runtime boundary today; five-axis M428/M429/M430 source assets are vendored unchanged, and the next runtime step is to route LinuxCNC NGC remap execution plus HAL pin synchronization through standalone adapters without reimplementing the remap semantics | +| Python/remap | `rs274ngc_pre.cc`, `interp_o_word.cc`, `interp_remap.cc`, remap hooks, selected LinuxCNC `configs/sim/axis/vismach/5axis/*/remap_subs/*.ngc` files | Python calls remain stubbed at the runtime boundary today; five-axis M428/M429/M430 source assets are vendored unchanged, and the NGC remap descriptor path now parses through vendored LinuxCNC code. The next runtime step is to route LinuxCNC O-word remap execution plus HAL pin synchronization through standalone adapters without reimplementing the remap semantics | | Canonical machine actions | `interp_convert.cc`, `interp_execute.cc`, `interp_queue.cc` | Captured by standalone canonical event sink functions for regression fixtures | | Realtime scheduling | TP and motion headers | Not ported; native TP probes seed deterministic status/config state | | GUI | None used as implementation | Native LinuxCNC GUI remains reference-only | @@ -71,10 +71,13 @@ Current validation is intentionally mechanical: `pentakins` have native runtime baselines; full runtime machine baselines for userspace genser flows are not yet established. - Five-axis M428/M429/M430 source assets are now vendored for bridge-mill, - dual-rotary, and table-rotary-tilting LinuxCNC sample machines. Full - standalone execution still needs LinuxCNC remap dispatch, the `M68`/`M66` - synchronization path, and `_hal[motion.switchkins-type]` readback connected - through the standalone HAL boundary. + dual-rotary, and table-rotary-tilting LinuxCNC sample machines. NGC remap + descriptors for the TRT sample machines are parsed through vendored + `Interp::parse_remap()` and `find_ngc_file()` by + `linuxcnc_remap_parse_harness`. Full standalone execution still needs + LinuxCNC O-word remap dispatch, the `M68`/`M66` synchronization path, and + `_hal[motion.switchkins-type]` readback connected through the standalone HAL + boundary. - Cutter compensation positive motion and negative interpreter paths are fixture-covered through vendored `interp_convert.cc` and `interp_queue.cc`. - Browser/WASM C ABI and JS SDK layers are now present for the INI parser, the diff --git a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_python_edge_stubs.cpp b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_python_edge_stubs.cpp new file mode 100644 index 0000000..1babf0c --- /dev/null +++ b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_python_edge_stubs.cpp @@ -0,0 +1,41 @@ +#include + +#define private public +#include "emc/rs274ngc/rs274ngc_interp.hh" +#undef private + +#include "emc/rs274ngc/rs274ngc_return.hh" +#include "interp_python.hh" +#include "pythonplugin/python_plugin.hh" + +PythonPlugin *python_plugin = nullptr; +int _task = 0; + +struct _inittab { + const char *name; + void *initfunc; +}; + +_inittab builtin_modules[] = {{nullptr, nullptr}}; + +InterpBase::~InterpBase() {} + +PythonPlugin *PythonPlugin::instantiate(struct _inittab *) +{ + static PythonPlugin standalone_plugin; + python_plugin = &standalone_plugin; + return python_plugin; +} + +std::string handle_pyerror() +{ + return {}; +} + +bool Interp::is_pycallable(setup_pointer, const char *, const char *) { return false; } +int Interp::pycall(setup_pointer, context_pointer, const char *, const char *, int) +{ + return INTERP_ERROR; +} +int Interp::py_execute(const char *, bool) { return INTERP_ERROR; } +int Interp::py_reload() { return INTERP_OK; } diff --git a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_remap_parse_harness.cpp b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_remap_parse_harness.cpp new file mode 100644 index 0000000..7ca5f92 --- /dev/null +++ b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_remap_parse_harness.cpp @@ -0,0 +1,146 @@ +#define private public +#include "emc/rs274ngc/rs274ngc_interp.hh" +#undef private + +#include +#include +#include +#include +#include +#include + +#include "emc/ini/inifile.hh" +#include "emc/rs274ngc/interp_internal.hh" +#include "emc/rs274ngc/rs274ngc_return.hh" + +#ifndef LINUXCNC_VENDOR_DIR +#error "LINUXCNC_VENDOR_DIR must point at wasm-port/vendor/linuxcnc" +#endif + +namespace { + +struct ExpectedRemap { + int mcode; + const char *name; + const char *ngc; +}; + +struct MachineCase { + const char *label; + const char *ini_rel; + std::vector expected; +}; + +std::filesystem::path vendor_path(const std::string &rel) +{ + return std::filesystem::path(LINUXCNC_VENDOR_DIR) / rel; +} + +void print_bool(const std::string &name, bool value) +{ + std::cout << name << "=" << (value ? 1 : 0) << "\n"; +} + +bool check_remap(Interp &interp, const std::string &label, const ExpectedRemap &expected) +{ + const auto by_name = interp.remapping(expected.name); + const auto by_mcode = interp._setup.m_remapped[expected.mcode]; + + const bool name_ok = by_name != nullptr; + const bool mcode_ok = by_mcode != nullptr && by_mcode == by_name; + const bool ngc_ok = by_mcode != nullptr && by_mcode->remap_ngc != nullptr && + std::strcmp(by_mcode->remap_ngc, expected.ngc) == 0; + const bool modal_group_ok = by_mcode != nullptr && by_mcode->modal_group == 10; + const bool no_python_ok = by_mcode != nullptr && by_mcode->remap_py == nullptr && + by_mcode->prolog_func == nullptr && + by_mcode->epilog_func == nullptr; + const bool mcode_remappable = interp.is_m_code_remappable(expected.mcode); + + const std::string prefix = label + "_" + expected.name; + print_bool(prefix + "_name_lookup", name_ok); + print_bool(prefix + "_mcode_lookup", mcode_ok); + print_bool(prefix + "_ngc", ngc_ok); + print_bool(prefix + "_modalgroup10", modal_group_ok); + print_bool(prefix + "_no_python", no_python_ok); + print_bool(prefix + "_linuxcnc_mcode_remappable", mcode_remappable); + + return name_ok && mcode_ok && ngc_ok && modal_group_ok && no_python_ok && + mcode_remappable; +} + +bool check_machine(const MachineCase &machine) +{ + const auto ini_path = vendor_path(machine.ini_rel); + const auto machine_dir = ini_path.parent_path(); + const auto remap_dir = machine_dir / "remap_subs"; + + linuxcnc::IniFile ini(ini_path.string()); + const bool opened = static_cast(ini); + print_bool(std::string(machine.label) + "_ini_open", opened); + if (!opened) { + return false; + } + + Interp interp; + std::snprintf(interp._setup.program_prefix, sizeof(interp._setup.program_prefix), "%s", + machine_dir.c_str()); + interp._setup.subroutines[0] = strstore(remap_dir.c_str()); + + bool ok = true; + int remap_count = 0; + int line_number = 0; + while (auto remap = ini.findString(++remap_count, "REMAP", "RS274NGC")) { + line_number = ini.lineOf(remap_count, "REMAP", "RS274NGC").second; + const int rc = interp.parse_remap(remap->c_str(), line_number); + std::cout << machine.label << "_parse_remap_" << remap_count << "=" << rc << "\n"; + ok &= rc == INTERP_OK; + } + remap_count -= 1; + std::cout << machine.label << "_parsed_remap_count=" << remap_count << "\n"; + ok &= remap_count == static_cast(machine.expected.size()); + + std::cout << machine.label << "_m_remapped_count=" << interp._setup.m_remapped.size() + << "\n"; + ok &= interp._setup.m_remapped.size() == machine.expected.size(); + + for (const auto &expected : machine.expected) { + ok &= check_remap(interp, machine.label, expected); + } + + print_bool(std::string(machine.label) + "_linuxcnc_ngc_remaps_parsed", ok); + return ok; +} + +} // namespace + +int main() +{ + const MachineCase cases[] = { + { + "xyzac_trt", + "configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini", + { + {428, "M428", "428remap"}, + {429, "M429", "429remap"}, + {430, "M430", "430remap"}, + }, + }, + { + "xyzbc_trt", + "configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzbc-trt.ini", + { + {428, "M428", "428remap"}, + {429, "M429", "429remap"}, + {430, "M430", "430remap"}, + }, + }, + }; + + bool ok = true; + for (const auto &machine : cases) { + ok &= check_machine(machine); + } + + print_bool("fiveaxis_linuxcnc_remap_parse_path", ok); + return ok ? 0 : 1; +} diff --git a/wasm-port/tests/native/verify_native_probes.sh b/wasm-port/tests/native/verify_native_probes.sh index 68aad5f..11647c2 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -159,6 +159,8 @@ check_exitcode linuxcnc_parameter_file_harness check_exitcode linuxcnc_parameter_file_harness.run check_exitcode linuxcnc_interp_init_harness check_exitcode linuxcnc_interp_init_harness.run +check_exitcode linuxcnc_remap_parse_harness +check_exitcode linuxcnc_remap_parse_harness.run check_exitcode linuxcnc_indexer_harness check_exitcode linuxcnc_indexer_harness.run check_exitcode linuxcnc_rs274_compile_probe @@ -241,6 +243,27 @@ grep -Fq "xyzac_trt_switch_mcodes_from_linuxcnc=1" "$FIVEAXIS_REMAP_ASSET_STDOUT grep -Fq "xyzbc_trt_switch_mcodes_from_linuxcnc=1" "$FIVEAXIS_REMAP_ASSET_STDOUT" grep -Fq "fiveaxis_remap_assets_from_linuxcnc=1" "$FIVEAXIS_REMAP_ASSET_STDOUT" +REMAP_PARSE_STDOUT="$BUILD_DIR/linuxcnc_remap_parse_harness.run.stdout.log" +grep -Fq "xyzac_trt_ini_open=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_parse_remap_1=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_parse_remap_2=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_parse_remap_3=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_parsed_remap_count=3" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_M428_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_M429_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_M430_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzac_trt_linuxcnc_ngc_remaps_parsed=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_ini_open=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_parse_remap_1=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_parse_remap_2=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_parse_remap_3=0" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_parsed_remap_count=3" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_M428_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_M429_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_M430_ngc=1" "$REMAP_PARSE_STDOUT" +grep -Fq "xyzbc_trt_linuxcnc_ngc_remaps_parsed=1" "$REMAP_PARSE_STDOUT" +grep -Fq "fiveaxis_linuxcnc_remap_parse_path=1" "$REMAP_PARSE_STDOUT" + NAMEDPARAM_STDOUT="$BUILD_DIR/linuxcnc_namedparam_harness.run.stdout.log" grep -Fq "init_named_parameters=0" "$NAMEDPARAM_STDOUT" grep -Fq "global_named_count=57" "$NAMEDPARAM_STDOUT" diff --git a/wasm-port/tools/build_native_probes.sh b/wasm-port/tools/build_native_probes.sh index f5836bc..50a1da4 100755 --- a/wasm-port/tools/build_native_probes.sh +++ b/wasm-port/tools/build_native_probes.sh @@ -58,6 +58,12 @@ MINIMAL_FLAGS=( -DLINUXCNC_STANDALONE_USE_RS274_PRE_STATE ) +REMAP_RUNTIME_FLAGS=( + "${MINIMAL_FLAGS[@]}" + -DLINUXCNC_VENDOR_DIR=\"$VENDOR_DIR\" + -include "$SHIM_DIR/linuxcnc_remap_compile_compat.hh" +) + INTERP_BASE_FLAGS=( "${MINIMAL_FLAGS[@]}" -DEMC2_HOME=\"/standalone\" @@ -661,6 +667,36 @@ INDEXER_HARNESS_SOURCES=( "$WRAP_DIR/linuxcnc_indexer_harness.cpp" ) +REMAP_PARSE_SOURCES=( + "$VENDOR_DIR/src/emc/rs274ngc/modal_state.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_array.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_internal.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_read.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_check.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_arc.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_inverse.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_execute.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_convert.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_cycles.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_g7x.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_queue.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_find.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_namedparams.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_write.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_o_word.cc" + "$VENDOR_DIR/src/emc/rs274ngc/interp_remap.cc" + "$VENDOR_DIR/src/emc/rs274ngc/rs274ngc_pre.cc" + "$VENDOR_DIR/src/emc/tooldata/tooldata_common.cc" + "$WRAP_DIR/linuxcnc_hal_adapter.cpp" + "$WRAP_DIR/linuxcnc_emc_status_runtime.cpp" + "$WRAP_DIR/linuxcnc_interp_python_edge_stubs.cpp" + "$WRAP_DIR/linuxcnc_runtime_state_stubs.cpp" + "$WRAP_DIR/linuxcnc_tool_adapter.cpp" + "$WRAP_DIR/linuxcnc_interp_minimal_runtime.cpp" + "$VENDOR_DIR/src/emc/ini/inifile.cc" + "$WRAP_DIR/linuxcnc_remap_parse_harness.cpp" +) + build_binary_target \ linuxcnc_ini_probe \ "$BUILD_DIR/linuxcnc_ini_probe" \ @@ -1223,6 +1259,29 @@ else "$BUILD_DIR/linuxcnc_interp_init_harness.run.stderr.log" fi +build_binary_target \ + linuxcnc_remap_parse_harness \ + "$BUILD_DIR/linuxcnc_remap_parse_harness" \ + REMAP_RUNTIME_FLAGS \ + REMAP_PARSE_SOURCES \ + MINIMAL_LINK_FLAGS \ + -lfmt + +if [[ "$(tr -d '[:space:]' < "$BUILD_DIR/linuxcnc_remap_parse_harness.exitcode")" == "0" ]]; then + set +e + "$BUILD_DIR/linuxcnc_remap_parse_harness" \ + >"$BUILD_DIR/linuxcnc_remap_parse_harness.run.stdout.log" \ + 2>"$BUILD_DIR/linuxcnc_remap_parse_harness.run.stderr.log" + REMAP_PARSE_RUN_RC=$? + set -e + echo "$REMAP_PARSE_RUN_RC" > "$BUILD_DIR/linuxcnc_remap_parse_harness.run.exitcode" +else + rm -f \ + "$BUILD_DIR/linuxcnc_remap_parse_harness.run.exitcode" \ + "$BUILD_DIR/linuxcnc_remap_parse_harness.run.stdout.log" \ + "$BUILD_DIR/linuxcnc_remap_parse_harness.run.stderr.log" +fi + build_binary_target \ linuxcnc_indexer_harness \ "$BUILD_DIR/linuxcnc_indexer_harness" \ diff --git a/wasm-port/tools/verify_no_standalone_cnc_semantics.sh b/wasm-port/tools/verify_no_standalone_cnc_semantics.sh index cb9042e..a47db83 100755 --- a/wasm-port/tools/verify_no_standalone_cnc_semantics.sh +++ b/wasm-port/tools/verify_no_standalone_cnc_semantics.sh @@ -19,6 +19,7 @@ find \ xargs -0 grep -nE '^[[:space:]]*([A-Za-z_][A-Za-z0-9_:<>~*&[:space:]]+[[:space:]]+)?Interp::[A-Za-z_~][A-Za-z0-9_]*[[:space:]]*\(' > "$TMP_FILE" || true ALLOWED_STUB_FILE="$ROOT_DIR/runtime/core/linuxcnc_wrap/linuxcnc_interp_edge_stubs.cpp" +ALLOWED_PYTHON_STUB_FILE="$ROOT_DIR/runtime/core/linuxcnc_wrap/linuxcnc_interp_python_edge_stubs.cpp" is_allowed_interp_stub() { local line="$1" @@ -37,7 +38,11 @@ is_allowed_interp_stub() { "$ALLOWED_STUB_FILE":*Interp::add_parameters\(* | \ "$ALLOWED_STUB_FILE":*Interp::pycall\(* | \ "$ALLOWED_STUB_FILE":*Interp::py_execute\(* | \ - "$ALLOWED_STUB_FILE":*Interp::py_reload\(*) + "$ALLOWED_STUB_FILE":*Interp::py_reload\(* | \ + "$ALLOWED_PYTHON_STUB_FILE":*Interp::is_pycallable\(* | \ + "$ALLOWED_PYTHON_STUB_FILE":*Interp::pycall\(* | \ + "$ALLOWED_PYTHON_STUB_FILE":*Interp::py_execute\(* | \ + "$ALLOWED_PYTHON_STUB_FILE":*Interp::py_reload\(*) return 0 ;; esac