82 lines
2.2 KiB
Bash
Executable File
82 lines
2.2 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}
|
|
cxx=${CXX:-g++}
|
|
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_safe_probe.XXXXXX")
|
|
shim_sources=(
|
|
core/wasm_shims/dlfcn.cc
|
|
core/wasm_shims/emc_status_shim.cc
|
|
core/wasm_shims/gettext_shim.cc
|
|
core/wasm_shims/linuxcnc_runtime_shim.cc
|
|
core/wasm_shims/python_c_api_shim.cc
|
|
core/wasm_shims/rtapi_compat.cc
|
|
core/wasm_shims/tooldata/tooldata_mmap_backend.cc
|
|
core/wasm_shims/tooldata/tooldata_runtime_stubs.cc
|
|
core/wasm_shims/pythonplugin/python_plugin.cc
|
|
)
|
|
|
|
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
|
|
trap 'rm -rf "$build_dir"' EXIT
|
|
|
|
common_flags=(
|
|
-std=c++20
|
|
-DULAPI
|
|
-include wctype.h
|
|
-I "$(pwd)/core/include"
|
|
-I "$(pwd)/core/src"
|
|
-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"
|
|
)
|
|
|
|
sources=()
|
|
while IFS=: read -r group path note; do
|
|
case "$group" in
|
|
core)
|
|
if [[ ! -f "$linuxcnc_root/$path" ]]; then
|
|
echo "missing manifest source: $path" >&2
|
|
exit 1
|
|
fi
|
|
sources+=("$path")
|
|
;;
|
|
""|\#*|blocked)
|
|
;;
|
|
*)
|
|
echo "unknown manifest group: $group" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done < "$manifest"
|
|
|
|
shim_index=0
|
|
for source in "${shim_sources[@]}"; do
|
|
obj="$build_dir/shim_${shim_index}.o"
|
|
"$cxx" "${common_flags[@]}" -c "$source" -o "$obj"
|
|
shim_index=$((shim_index + 1))
|
|
done
|
|
|
|
source_index=0
|
|
for source in "${sources[@]}"; do
|
|
obj="$build_dir/linuxcnc_${source_index}.o"
|
|
"$cxx" "${common_flags[@]}" -c "$linuxcnc_root/$source" -o "$obj"
|
|
source_index=$((source_index + 1))
|
|
done
|
|
|
|
echo "linuxcnc wasm-safe source object probe passed (${#sources[@]} linuxcnc objects + ${#shim_sources[@]} shims)"
|