196 lines
5.7 KiB
Bash
Executable File
196 lines
5.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# LinuxCNC source basis: this blocker scan is constrained to the RS274/WASM
|
|
# manifest. Python and Boost.Python blockers come from
|
|
# src/emc/rs274ngc/gcodemodule.cc, interp_namedparams.cc, interp_o_word.cc,
|
|
# and the py*.cc module bindings; tooldata/native-backend blockers come from
|
|
# src/emc/tooldata/tooldata_mmap.cc and tooldata_db.cc; native filesystem
|
|
# blockers come from LinuxCNC RS274 sources such as interp_o_word.cc and
|
|
# interp_write.cc.
|
|
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
|
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
|
|
|
|
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh "$manifest"
|
|
linuxcnc_root=$(cd "$linuxcnc_root" && pwd)
|
|
|
|
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=()
|
|
shim_source_output=$(./list-linuxcnc-wasm-safe-shims.sh)
|
|
mapfile -t wasm_safe_shims <<<"$shim_source_output"
|
|
|
|
blocked_replacement_for() {
|
|
case "$1" in
|
|
src/emc/tooldata/tooldata_mmap.cc)
|
|
./list-linuxcnc-wasm-safe-shims.sh tooldata_mmap_backend.cc
|
|
;;
|
|
src/emc/rs274ngc/canonmodule.cc|src/emc/rs274ngc/gcodemodule.cc|src/emc/rs274ngc/interpmodule.cc)
|
|
./list-linuxcnc-wasm-safe-shims.sh linuxcnc_runtime_shim.cc
|
|
;;
|
|
src/emc/rs274ngc/pyarrays.cc|src/emc/rs274ngc/pyblock.cc|src/emc/rs274ngc/pyemctypes.cc|src/emc/rs274ngc/pyinterp1.cc|src/emc/rs274ngc/pyparamclass.cc)
|
|
./list-linuxcnc-wasm-safe-shims.sh python_c_api_shim.cc
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
wasm_safe_shim_in_build() {
|
|
local shim=$1
|
|
local candidate
|
|
for candidate in "${wasm_safe_shims[@]}"; do
|
|
if [[ "$candidate" == "$shim" ]]; then
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
core_sources=()
|
|
blocked_sources=()
|
|
while IFS=: read -r group path note extra; do
|
|
case "$group" in
|
|
""|\#*)
|
|
continue
|
|
;;
|
|
core)
|
|
core_sources+=("$path")
|
|
;;
|
|
blocked)
|
|
blocked_sources+=("$path")
|
|
;;
|
|
header|metadata|blocked-header)
|
|
;;
|
|
*)
|
|
echo "unknown manifest group: $group" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done < "$manifest"
|
|
core_count=${#core_sources[@]}
|
|
blocked_count=${#blocked_sources[@]}
|
|
|
|
scan_source() {
|
|
local group=$1
|
|
local path=$2
|
|
full_path="$linuxcnc_root/$path"
|
|
if [[ ! -f "$full_path" ]]; then
|
|
echo "missing manifest source: $path" >&2
|
|
exit 1
|
|
fi
|
|
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
|
|
if ! wasm_safe_shim_in_build "$replacement"; then
|
|
echo "blocked replacement is not in wasm shim build set: $path -> $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
|
|
}
|
|
|
|
for path in "${core_sources[@]}"; do
|
|
[[ -z "$path" ]] && continue
|
|
scan_source core "$path"
|
|
done
|
|
|
|
for path in "${blocked_sources[@]}"; do
|
|
[[ -z "$path" ]] && continue
|
|
scan_source blocked "$path"
|
|
done
|
|
|
|
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[@]}"
|