#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" # LinuxCNC source basis: this guard keeps the local source map aligned with the # LinuxCNC-root relative rs274 manifests that drive native and WASM source-link # probes. It validates documentation/manifest drift only; it does not interpret # CNC behavior. python3 - <<'PY' from pathlib import Path source_map = Path("docs/linuxcnc-rs274-source-map.md").read_text(encoding="utf-8") native_manifest = Path("linuxcnc-rs274-source-files.txt").read_text(encoding="utf-8").splitlines() wasm_manifest = Path("linuxcnc-rs274-wasm-source-files.txt").read_text(encoding="utf-8").splitlines() expected = { "### Interpreter core": [ Path(line.split(":", 2)[1]).name for line in native_manifest if line.startswith("core:") ], "### Python binding modules": [ Path(line.split(":", 2)[1]).name for line in native_manifest if line.startswith("binding:") ], "### WASM-safe source core": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("core:") ], "### WASM-blocked sources": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("blocked:") ], "### WASM-tracked headers": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("header:") ], "### WASM-blocked headers": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("blocked-header:") ], "### WASM metadata sources": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("metadata:") ], } actual = {section: [] for section in expected} active_section = None for line in source_map.splitlines(): if line in expected: active_section = line continue if active_section and line.startswith("### "): active_section = None if active_section and line.startswith("- `"): actual[active_section].append(line.split("`", 2)[1]) labels = { "### Interpreter core": "interpreter core", "### Python binding modules": "Python binding module", "### WASM-safe source core": "WASM-safe source core", "### WASM-blocked sources": "WASM-blocked source", "### WASM-tracked headers": "WASM-tracked header", "### WASM-blocked headers": "WASM-blocked header", "### WASM metadata sources": "WASM metadata source", } for section, expected_entries in expected.items(): if actual[section] != expected_entries: raise SystemExit( f"docs/linuxcnc-rs274-source-map.md {labels[section]} list no longer matches source manifest" ) PY