说明:集中 LinuxCNC 源码清单与 wasm/native probe 的路径解析,补强 manifest、shim、source-link 检查,并保持 LinuxCNC 源码后端对齐验证流程可复用。 验证:./test-native.sh;./test-linuxcnc-source-link.sh;./test-all-native.sh;wasm source/probe 相关脚本。
153 lines
4.3 KiB
Bash
Executable File
153 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
|
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
|
|
|
|
if [[ ! -f "$manifest" ]]; then
|
|
echo "missing manifest: $manifest" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d "$linuxcnc_root" ]]; then
|
|
echo "missing LinuxCNC root: $linuxcnc_root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
python_blockers=()
|
|
core_python_sources=()
|
|
dlopen_blockers=()
|
|
core_dlopen_sources=()
|
|
tooldata_blockers=()
|
|
core_tooldata_sources=()
|
|
shimmed_tooldata_users=()
|
|
core_tooldata_users=()
|
|
native_backend_blockers=()
|
|
native_fs_blockers=()
|
|
core_native_fs_sources=()
|
|
core_count=0
|
|
blocked_count=0
|
|
blocked_replacements=()
|
|
core_source_list=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_wasm_blocker_core_sources.XXXXXX.txt")
|
|
blocked_source_list=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_wasm_blocker_blocked_sources.XXXXXX.txt")
|
|
trap 'rm -f "$core_source_list" "$blocked_source_list"' EXIT
|
|
|
|
blocked_replacement_for() {
|
|
case "$1" in
|
|
src/emc/tooldata/tooldata_mmap.cc)
|
|
./list-linuxcnc-wasm-safe-shims.sh tooldata_mmap_backend.cc
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
./list-linuxcnc-wasm-manifest-sources.sh "$manifest" core > "$core_source_list"
|
|
./list-linuxcnc-wasm-manifest-sources.sh "$manifest" blocked > "$blocked_source_list"
|
|
core_count=$(wc -l < "$core_source_list")
|
|
blocked_count=$(wc -l < "$blocked_source_list")
|
|
|
|
scan_source() {
|
|
local group=$1
|
|
local path=$2
|
|
full_path="$linuxcnc_root/$path"
|
|
if [[ "$group" == "blocked" ]]; then
|
|
if ! replacement=$(blocked_replacement_for "$path"); then
|
|
echo "missing blocked replacement mapping: $path" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$replacement" ]]; then
|
|
echo "missing blocked replacement source: $replacement" >&2
|
|
exit 1
|
|
fi
|
|
blocked_replacements+=("$path -> $replacement")
|
|
fi
|
|
|
|
if [[ "$path" == src/emc/tooldata/* ]]; then
|
|
if [[ "$group" == "blocked" ]]; then
|
|
tooldata_blockers+=("$path")
|
|
else
|
|
core_tooldata_sources+=("$path")
|
|
fi
|
|
fi
|
|
|
|
if [[ "$path" == "src/emc/tooldata/tooldata_mmap.cc" ]]; then
|
|
native_backend_blockers+=("$path")
|
|
fi
|
|
|
|
if grep -Eq 'Python\.h|boost/python|pythonplugin|PyObject|PyInit_' "$full_path"; then
|
|
if [[ "$group" == "blocked" ]]; then
|
|
python_blockers+=("$path")
|
|
else
|
|
core_python_sources+=("$path")
|
|
fi
|
|
fi
|
|
|
|
if grep -Eq 'dlopen|dlsym|RTLD_' "$full_path"; then
|
|
if [[ "$group" == "blocked" ]]; then
|
|
dlopen_blockers+=("$path")
|
|
else
|
|
core_dlopen_sources+=("$path")
|
|
fi
|
|
fi
|
|
|
|
if grep -Eq 'mkstemp|mkstemps|dirent\.h|opendir|readdir|unistd\.h' "$full_path"; then
|
|
if [[ "$group" == "blocked" ]]; then
|
|
native_fs_blockers+=("$path")
|
|
else
|
|
core_native_fs_sources+=("$path")
|
|
fi
|
|
fi
|
|
|
|
if [[ "$path" != src/emc/tooldata/* ]] && grep -Eq 'tooldata/tooldata.hh|tooldata_' "$full_path"; then
|
|
if [[ "$group" == "blocked" ]]; then
|
|
shimmed_tooldata_users+=("$path")
|
|
else
|
|
core_tooldata_users+=("$path")
|
|
fi
|
|
fi
|
|
}
|
|
|
|
while IFS= read -r path; do
|
|
[[ -z "$path" ]] && continue
|
|
scan_source core "$path"
|
|
done < "$core_source_list"
|
|
|
|
while IFS= read -r path; do
|
|
[[ -z "$path" ]] && continue
|
|
scan_source blocked "$path"
|
|
done < "$blocked_source_list"
|
|
|
|
print_group() {
|
|
local title=$1
|
|
shift
|
|
echo "[$title]"
|
|
if [[ $# -eq 0 ]]; then
|
|
echo "(none)"
|
|
else
|
|
printf '%s\n' "$@" | LC_ALL=C sort -u
|
|
fi
|
|
echo
|
|
}
|
|
|
|
echo "[manifest]"
|
|
echo "core=$core_count"
|
|
echo "blocked=$blocked_count"
|
|
echo
|
|
|
|
print_group "python" "${python_blockers[@]}"
|
|
print_group "dlopen" "${dlopen_blockers[@]}"
|
|
print_group "tooldata" "${tooldata_blockers[@]}"
|
|
print_group "tooldata-users" "${shimmed_tooldata_users[@]}"
|
|
print_group "native-backend" "${native_backend_blockers[@]}"
|
|
print_group "native-fs" "${native_fs_blockers[@]}"
|
|
print_group "blocked-replacements" "${blocked_replacements[@]}"
|
|
print_group "core-python-shimmed" "${core_python_sources[@]}"
|
|
print_group "core-dlopen-shimmed" "${core_dlopen_sources[@]}"
|
|
print_group "core-tooldata-shimmed" "${core_tooldata_sources[@]}"
|
|
print_group "core-tooldata-users-shimmed" "${core_tooldata_users[@]}"
|
|
print_group "core-native-fs-shimmed" "${core_native_fs_sources[@]}"
|