From 4158a7876017a82d285afc887302437809bb452a Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 7 Jun 2026 17:06:02 +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 结论:新增 vendored LinuxCNC 源码同步验证脚本,去重 source-manifest,并在 native 验证前检查 vendor 与上游源文件字节一致,强化功能来源于 LinuxCNC 源程序的纪律。 --- wasm-port/docs/porting-steps-standalone.md | 6 ++ .../tests/native/verify_native_probes.sh | 1 + wasm-port/tools/source-manifest.txt | 2 - wasm-port/tools/verify_vendor_sync.sh | 85 +++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100755 wasm-port/tools/verify_vendor_sync.sh diff --git a/wasm-port/docs/porting-steps-standalone.md b/wasm-port/docs/porting-steps-standalone.md index 5fff336..cd0ba33 100644 --- a/wasm-port/docs/porting-steps-standalone.md +++ b/wasm-port/docs/porting-steps-standalone.md @@ -467,6 +467,12 @@ Current verified progress: `sincos.c`. These probes use the same `TP_FLAGS` as the standalone TP harness, including the existing `-fpermissive` boundary required by upstream enum conversions in `tp.c`. +- `tools/verify_vendor_sync.sh` now validates the LinuxCNC source extraction + boundary before native probes run. It rejects duplicate manifest entries, + missing or extra vendored files, and byte-level drift between each manifest + file under `vendor/linuxcnc/` and the matching file under `../linuxcnc/`. + `tools/source-manifest.txt` was also de-duplicated so the manifest is a + single authoritative extraction list. ## Phase 4: Port INI Parsing Without Editing Upstream diff --git a/wasm-port/tests/native/verify_native_probes.sh b/wasm-port/tests/native/verify_native_probes.sh index d2babaf..a1ca5bd 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -9,6 +9,7 @@ GCODE_ERROR_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/gcode_errors" 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/build_native_probes.sh" check_exitcode() { diff --git a/wasm-port/tools/source-manifest.txt b/wasm-port/tools/source-manifest.txt index 8444b6c..c1e496c 100644 --- a/wasm-port/tools/source-manifest.txt +++ b/wasm-port/tools/source-manifest.txt @@ -115,5 +115,3 @@ src/emc/rs274ngc/interp_o_word.cc src/emc/rs274ngc/interp_convert.cc src/emc/rs274ngc/interp_cycles.cc src/emc/rs274ngc/interp_g7x.cc -src/emc/rs274ngc/interp_check.cc -src/emc/rs274ngc/interp_execute.cc diff --git a/wasm-port/tools/verify_vendor_sync.sh b/wasm-port/tools/verify_vendor_sync.sh new file mode 100755 index 0000000..da3a80c --- /dev/null +++ b/wasm-port/tools/verify_vendor_sync.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +UPSTREAM_DIR="$ROOT_DIR/../linuxcnc" +VENDOR_DIR="$ROOT_DIR/vendor/linuxcnc" +MANIFEST_FILE="$ROOT_DIR/tools/source-manifest.txt" + +if [[ ! -d "$UPSTREAM_DIR" ]]; then + echo "missing upstream directory: $UPSTREAM_DIR" >&2 + exit 1 +fi + +if [[ ! -d "$VENDOR_DIR" ]]; then + echo "missing vendor directory: $VENDOR_DIR" >&2 + exit 1 +fi + +if [[ ! -f "$MANIFEST_FILE" ]]; then + echo "missing manifest: $MANIFEST_FILE" >&2 + exit 1 +fi + +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT + +MANIFEST_CLEAN="$TMP_DIR/manifest.clean" +MANIFEST_SORTED="$TMP_DIR/manifest.sorted" +VENDOR_SORTED="$TMP_DIR/vendor.sorted" + +while IFS= read -r src_rel; do + [[ -z "$src_rel" ]] && continue + [[ "${src_rel:0:1}" == "#" ]] && continue + + if [[ "$src_rel" = /* || "$src_rel" == *".."* ]]; then + echo "invalid manifest path: $src_rel" >&2 + exit 1 + fi + + printf '%s\n' "$src_rel" >> "$MANIFEST_CLEAN" +done < "$MANIFEST_FILE" + +if [[ ! -s "$MANIFEST_CLEAN" ]]; then + echo "empty manifest: $MANIFEST_FILE" >&2 + exit 1 +fi + +sort "$MANIFEST_CLEAN" > "$MANIFEST_SORTED" + +if duplicate_entries="$(uniq -d "$MANIFEST_SORTED")" && [[ -n "$duplicate_entries" ]]; then + echo "duplicate manifest entries:" >&2 + printf '%s\n' "$duplicate_entries" >&2 + exit 1 +fi + +find "$VENDOR_DIR" -type f | sed "s#^$VENDOR_DIR/##" | sort > "$VENDOR_SORTED" + +if extra_vendor="$(comm -23 "$VENDOR_SORTED" "$MANIFEST_SORTED")" && [[ -n "$extra_vendor" ]]; then + echo "vendor files not listed in manifest:" >&2 + printf '%s\n' "$extra_vendor" >&2 + exit 1 +fi + +if missing_vendor="$(comm -13 "$VENDOR_SORTED" "$MANIFEST_SORTED")" && [[ -n "$missing_vendor" ]]; then + echo "manifest files missing from vendor:" >&2 + printf '%s\n' "$missing_vendor" >&2 + exit 1 +fi + +while IFS= read -r src_rel; do + upstream_file="$UPSTREAM_DIR/$src_rel" + vendor_file="$VENDOR_DIR/$src_rel" + + if [[ ! -f "$upstream_file" ]]; then + echo "missing upstream file: $src_rel" >&2 + exit 1 + fi + + if ! cmp -s "$upstream_file" "$vendor_file"; then + echo "vendor drift from upstream: $src_rel" >&2 + exit 1 + fi +done < "$MANIFEST_SORTED" + +echo "vendor sync validation complete"