From e776020b08ab2125f9abdea7deda9bac4f383fcf Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 7 Jun 2026 18:28:35 +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 结论:新增 source-probes.tsv 映射并在 native 验证中比对 source-manifest,确保每个 vendored LinuxCNC .c/.cc 源文件都有显式 standalone 源码编译探针。 --- wasm-port/docs/porting-steps-standalone.md | 5 +++ .../tests/native/verify_native_probes.sh | 41 +++++++++++++++++++ wasm-port/tools/build_native_probes.sh | 13 ++++++ 3 files changed, 59 insertions(+) diff --git a/wasm-port/docs/porting-steps-standalone.md b/wasm-port/docs/porting-steps-standalone.md index 6a49e5e..a981175 100644 --- a/wasm-port/docs/porting-steps-standalone.md +++ b/wasm-port/docs/porting-steps-standalone.md @@ -483,6 +483,11 @@ Current verified progress: existing INI parser harness. With this probe, every `.c` and `.cc` file listed in `tools/source-manifest.txt` has a native source-level compile check under the standalone build boundary. +- `tools/build_native_probes.sh` now emits `build/native/source-probes.tsv` + while compiling vendored `*_source_probe` targets. The native verification + 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. ## 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 fe690d6..5976218 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -12,6 +12,46 @@ 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_source_probe_coverage() { + local manifest_sources="$BUILD_DIR/source-manifest-sources.sorted" + local probe_sources="$BUILD_DIR/source-probe-sources.sorted" + local duplicate_probe_sources="$BUILD_DIR/source-probe-sources.duplicates" + + awk ' + /^[[:space:]]*($|#)/ { next } + /\.(c|cc)$/ { print } + ' "$ROOT_DIR/tools/source-manifest.txt" | sort > "$manifest_sources" + + if [[ ! -f "$BUILD_DIR/source-probes.tsv" ]]; then + echo "missing source probe map: $BUILD_DIR/source-probes.tsv" >&2 + exit 1 + fi + + cut -f1 "$BUILD_DIR/source-probes.tsv" | sort > "$probe_sources" + uniq -d "$probe_sources" > "$duplicate_probe_sources" + if [[ -s "$duplicate_probe_sources" ]]; then + echo "duplicate source probe entries:" >&2 + cat "$duplicate_probe_sources" >&2 + exit 1 + fi + + local missing_sources + missing_sources="$(comm -23 "$manifest_sources" "$probe_sources")" + if [[ -n "$missing_sources" ]]; then + echo "manifest source files without source probes:" >&2 + printf '%s\n' "$missing_sources" >&2 + exit 1 + fi + + local extra_sources + extra_sources="$(comm -13 "$manifest_sources" "$probe_sources")" + if [[ -n "$extra_sources" ]]; then + echo "source probes not listed in manifest:" >&2 + printf '%s\n' "$extra_sources" >&2 + exit 1 + fi +} + check_exitcode() { local name="$1" local file="$BUILD_DIR/$name.exitcode" @@ -32,6 +72,7 @@ check_exitcode() { fi } +check_source_probe_coverage check_exitcode linuxcnc_interp_state_probe check_exitcode linuxcnc_inifile_source_probe check_exitcode linuxcnc_tp_api_probe diff --git a/wasm-port/tools/build_native_probes.sh b/wasm-port/tools/build_native_probes.sh index fb84ede..f4b2cf5 100755 --- a/wasm-port/tools/build_native_probes.sh +++ b/wasm-port/tools/build_native_probes.sh @@ -7,12 +7,14 @@ BUILD_DIR="$ROOT_DIR/build/native" WRAP_DIR="$ROOT_DIR/runtime/core/linuxcnc_wrap" SHIM_DIR="$ROOT_DIR/runtime/core/shims" INCLUDE_DIR="$ROOT_DIR/runtime/core/include" +SOURCE_PROBE_MAP="$BUILD_DIR/source-probes.tsv" MINIMAL_GCODE_FIXTURE="$ROOT_DIR/tests/fixtures/gcode/minimal_linear.ngc" NAMEDPARAM_INI_FIXTURE="$ROOT_DIR/tests/fixtures/ini/namedparams.ini" CXX="${CXX:-g++}" CC="${CC:-gcc}" mkdir -p "$BUILD_DIR" +: > "$SOURCE_PROBE_MAP" COMMON_FLAGS=( -std=c++20 @@ -179,6 +181,15 @@ compile_c_object() { return 1 } +record_source_probe() { + local target="$1" + local source="$2" + + [[ "$target" == *_source_probe ]] || return 0 + [[ "$source" == "$VENDOR_DIR/"* ]] || return 0 + printf '%s\t%s\n' "${source#"$VENDOR_DIR"/}" "$target" >> "$SOURCE_PROBE_MAP" +} + link_needs_rebuild() { local output="$1" local cmdfile="$2" @@ -293,6 +304,7 @@ build_object_target() { status=1 fi + record_source_probe "$target" "$source" echo "$status" > "$BUILD_DIR/$target.exitcode" return "$status" } @@ -314,6 +326,7 @@ build_c_object_target() { status=1 fi + record_source_probe "$target" "$source" echo "$status" > "$BUILD_DIR/$target.exitcode" return "$status" }