说明:集中 LinuxCNC 源码清单与 wasm/native probe 的路径解析,补强 manifest、shim、source-link 检查,并保持 LinuxCNC 源码后端对齐验证流程可复用。 验证:./test-native.sh;./test-linuxcnc-source-link.sh;./test-all-native.sh;wasm source/probe 相关脚本。
85 lines
2.7 KiB
Bash
Executable File
85 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
|
cxx=${CXX:-g++}
|
|
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_tooldata_runtime_symbols.XXXXXX")
|
|
|
|
if [[ ! -d "$linuxcnc_root" ]]; then
|
|
echo "missing LinuxCNC root: $linuxcnc_root" >&2
|
|
exit 1
|
|
fi
|
|
trap 'rm -rf "$build_dir"' EXIT
|
|
|
|
tooldata_mmap_backend_shim=$(./list-linuxcnc-wasm-safe-shims.sh tooldata_mmap_backend.cc)
|
|
tooldata_runtime_stubs_shim=$(./list-linuxcnc-wasm-safe-shims.sh tooldata_runtime_stubs.cc)
|
|
readarray -t linuxcnc_sources < <(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-files.sh \
|
|
src/emc/tooldata/tooldata_db.cc \
|
|
src/emc/tooldata/tooldata_nml.cc)
|
|
tooldata_db_source=${linuxcnc_sources[0]}
|
|
tooldata_nml_source=${linuxcnc_sources[1]}
|
|
|
|
common_flags=(
|
|
-std=c++17
|
|
-DULAPI
|
|
-I "$(pwd)/core/wasm_shims"
|
|
-I "$linuxcnc_root/src"
|
|
-I "$linuxcnc_root/src/emc"
|
|
-I "$linuxcnc_root/src/emc/nml_intf"
|
|
-I "$linuxcnc_root/src/emc/rs274ngc"
|
|
-I "$linuxcnc_root/src/emc/motion"
|
|
-I "$linuxcnc_root/include"
|
|
)
|
|
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$tooldata_runtime_stubs_shim" \
|
|
-o "$build_dir/tooldata_runtime_stubs.o"
|
|
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$tooldata_mmap_backend_shim" \
|
|
-o "$build_dir/tooldata_mmap_backend.o"
|
|
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$tooldata_db_source" \
|
|
-o "$build_dir/linuxcnc_tooldata_db.o"
|
|
|
|
"$cxx" "${common_flags[@]}" \
|
|
-c "$tooldata_nml_source" \
|
|
-o "$build_dir/linuxcnc_tooldata_nml.o"
|
|
|
|
nm --defined-only "$build_dir/tooldata_runtime_stubs.o" \
|
|
| awk '$2 ~ /^[A-Z]$/ {print $3}' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/runtime.exports"
|
|
|
|
nm --defined-only "$build_dir/tooldata_mmap_backend.o" \
|
|
| awk '$2 ~ /^[A-Z]$/ {print $3}' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/backend.exports"
|
|
|
|
nm --defined-only "$build_dir"/linuxcnc_tooldata_*.o \
|
|
| awk '$2 ~ /^[A-Z]$/ {print $3}' \
|
|
| LC_ALL=C sort -u \
|
|
> "$build_dir/linuxcnc-runtime.exports"
|
|
|
|
comm -23 "$build_dir/linuxcnc-runtime.exports" "$build_dir/backend.exports" \
|
|
> "$build_dir/expected.exports"
|
|
|
|
comm -23 "$build_dir/expected.exports" "$build_dir/runtime.exports" > "$build_dir/missing.exports"
|
|
if [[ -s "$build_dir/missing.exports" ]]; then
|
|
echo "missing wasm tooldata runtime stub exports from LinuxCNC runtime sources:" >&2
|
|
cat "$build_dir/missing.exports" >&2
|
|
exit 1
|
|
fi
|
|
|
|
comm -13 "$build_dir/expected.exports" "$build_dir/runtime.exports" > "$build_dir/unexpected.exports"
|
|
if [[ -s "$build_dir/unexpected.exports" ]]; then
|
|
echo "unexpected wasm tooldata runtime stub exports beyond LinuxCNC runtime sources:" >&2
|
|
cat "$build_dir/unexpected.exports" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "linuxcnc wasm tooldata runtime symbol probe passed"
|