65 lines
1.6 KiB
Bash
Executable File
65 lines
1.6 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_rs274_objects.XXXXXX")
|
|
python_includes=$(python3.13-config --includes 2>/dev/null || python3-config --includes)
|
|
manifest=${1:-linuxcnc-rs274-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
|
|
|
|
trap 'rm -rf "$build_dir"' EXIT
|
|
|
|
common_flags=(
|
|
-std=c++17
|
|
-DULAPI
|
|
-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/src/emc/pythonplugin"
|
|
-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 file: $path" >&2
|
|
exit 1
|
|
fi
|
|
sources+=("$path")
|
|
;;
|
|
""|\#*|binding|tooldata)
|
|
;;
|
|
*)
|
|
echo "unknown manifest group: $group" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done < "$manifest"
|
|
|
|
source_index=0
|
|
for source in "${sources[@]}"; do
|
|
obj="$build_dir/linuxcnc_${source_index}.o"
|
|
# shellcheck disable=SC2086
|
|
"$cxx" "${common_flags[@]}" $python_includes -c "$linuxcnc_root/$source" -o "$obj"
|
|
source_index=$((source_index + 1))
|
|
done
|
|
|
|
echo "linuxcnc rs274 source object build passed (${#sources[@]} objects)"
|
|
echo "built objects in $build_dir"
|