From c3157ee3f8dbc3e106a5a7baae7fd174490a69ed Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 7 Jun 2026 18:32:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E6=8E=A8=E8=8D=90=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=EF=BC=8C=E7=BB=A7=E7=BB=AD=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:新增 standalone CNC 语义守卫,禁止在 wrapper/tools/tests 中重新定义 Interp::convert_g(),确保 G-code 转换继续走 vendored LinuxCNC interp_convert.cc。 --- wasm-port/docs/porting-steps-standalone.md | 9 +++++-- .../tests/native/verify_native_probes.sh | 1 + .../verify_no_standalone_cnc_semantics.sh | 26 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 wasm-port/tools/verify_no_standalone_cnc_semantics.sh diff --git a/wasm-port/docs/porting-steps-standalone.md b/wasm-port/docs/porting-steps-standalone.md index a981175..1d15488 100644 --- a/wasm-port/docs/porting-steps-standalone.md +++ b/wasm-port/docs/porting-steps-standalone.md @@ -488,6 +488,11 @@ Current verified progress: script compares that map against every `.c` and `.cc` entry in `tools/source-manifest.txt`, so future LinuxCNC source additions fail validation unless they also get an explicit standalone source compile probe. +- `tools/verify_no_standalone_cnc_semantics.sh` now guards against + reintroducing a standalone `Interp::convert_g()` definition outside + `vendor/linuxcnc/`. This keeps G-code group conversion on the vendored + LinuxCNC `interp_convert.cc` path instead of allowing the wrapper layer to + grow another project-authored conversion implementation. ## Phase 4: Port INI Parsing Without Editing Upstream @@ -786,8 +791,8 @@ Keep these documents under `wasm-port/docs/`: Continue expanding the standalone interpreter core from the verified minimal traverse path: -1. replace the temporary minimal `convert_g()` implementation with calls into - vendored LinuxCNC interpreter conversion code. +1. keep `convert_g()` execution on vendored LinuxCNC interpreter conversion + code and reject any new standalone `Interp::convert_g()` implementation. 2. identify and shim the native runtime symbols blocking direct compilation of `interp_convert.cc`, `interp_execute.cc`, and related interpreter files. 3. keep fixture coverage as regression protection while deleting temporary diff --git a/wasm-port/tests/native/verify_native_probes.sh b/wasm-port/tests/native/verify_native_probes.sh index 5976218..74cfbfb 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -10,6 +10,7 @@ CANON_ERROR_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/canon_errors" NAMEDPARAM_INI_FIXTURE="$ROOT_DIR/tests/fixtures/ini/namedparams.ini" "$ROOT_DIR/tools/verify_vendor_sync.sh" +"$ROOT_DIR/tools/verify_no_standalone_cnc_semantics.sh" "$ROOT_DIR/tools/build_native_probes.sh" check_source_probe_coverage() { diff --git a/wasm-port/tools/verify_no_standalone_cnc_semantics.sh b/wasm-port/tools/verify_no_standalone_cnc_semantics.sh new file mode 100755 index 0000000..41a63a9 --- /dev/null +++ b/wasm-port/tools/verify_no_standalone_cnc_semantics.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" + +TMP_FILE="$(mktemp)" +trap 'rm -f "$TMP_FILE"' EXIT + +find \ + "$ROOT_DIR/runtime" \ + "$ROOT_DIR/tests" \ + "$ROOT_DIR/tools" \ + -type f \ + \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' -o -name '*.js' -o -name '*.ts' \) \ + ! -path "$ROOT_DIR/vendor/*" \ + ! -path "$ROOT_DIR/runtime/ui/ini-panel/linuxcnc_ini.js" \ + -print0 | + xargs -0 grep -nE '^[[:space:]]*int[[:space:]]+Interp::convert_g[[:space:]]*\(' > "$TMP_FILE" || true + +if [[ -s "$TMP_FILE" ]]; then + echo "standalone Interp::convert_g definitions are not allowed:" >&2 + cat "$TMP_FILE" >&2 + exit 1 +fi + +echo "standalone CNC semantics guard complete"