151 lines
4.2 KiB
Bash
Executable File
151 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
LINUXCNC_ROOT="${LINUXCNC_ROOT:-$ROOT_DIR/../linuxcnc}"
|
|
VENDOR_ROOT="$ROOT_DIR/vendor/linuxcnc"
|
|
MANIFEST="$ROOT_DIR/tools/task-hal-source-manifest.txt"
|
|
BUILD_DIR="$ROOT_DIR/build/task-hal"
|
|
REPORT="$BUILD_DIR/task-hal-source-manifest.tsv"
|
|
|
|
mkdir -p "$BUILD_DIR"
|
|
|
|
print_kv() {
|
|
printf '%s=%s\n' "$1" "$2"
|
|
}
|
|
|
|
if [[ ! -f "$MANIFEST" ]]; then
|
|
print_kv task_hal_source_manifest_status missing_manifest
|
|
print_kv task_hal_source_manifest_path "$MANIFEST"
|
|
exit 1
|
|
fi
|
|
|
|
tmp="$(mktemp "$BUILD_DIR/task-hal-source-manifest.XXXXXX.tsv")"
|
|
trap 'rm -f "$tmp"' EXIT
|
|
|
|
printf '%s\t%s\t%s\t%s\t%s\n' \
|
|
source_rel \
|
|
reference_exists \
|
|
vendor_exists \
|
|
vendor_hash_matches \
|
|
boundary > "$tmp"
|
|
|
|
source_count=0
|
|
task_source_count=0
|
|
hal_source_count=0
|
|
motion_source_count=0
|
|
nml_source_count=0
|
|
libnml_source_count=0
|
|
reference_ready=1
|
|
vendor_ready=1
|
|
vendor_match_ready=1
|
|
missing_reference=()
|
|
missing_vendor=()
|
|
mismatched_vendor=()
|
|
|
|
while IFS= read -r source_rel; do
|
|
[[ -z "$source_rel" || "$source_rel" =~ ^[[:space:]]*# ]] && continue
|
|
source_count=$((source_count + 1))
|
|
case "$source_rel" in
|
|
src/emc/task/*)
|
|
task_source_count=$((task_source_count + 1))
|
|
;;
|
|
src/hal/*)
|
|
hal_source_count=$((hal_source_count + 1))
|
|
;;
|
|
src/emc/motion/*)
|
|
motion_source_count=$((motion_source_count + 1))
|
|
;;
|
|
src/emc/nml_intf/*)
|
|
nml_source_count=$((nml_source_count + 1))
|
|
;;
|
|
src/libnml/*)
|
|
libnml_source_count=$((libnml_source_count + 1))
|
|
;;
|
|
esac
|
|
|
|
reference_file="$LINUXCNC_ROOT/$source_rel"
|
|
vendor_file="$VENDOR_ROOT/$source_rel"
|
|
reference_exists=0
|
|
vendor_exists=0
|
|
vendor_hash_matches=0
|
|
|
|
if [[ -f "$reference_file" ]]; then
|
|
reference_exists=1
|
|
else
|
|
reference_ready=0
|
|
missing_reference+=("$source_rel")
|
|
fi
|
|
|
|
if [[ -f "$vendor_file" ]]; then
|
|
vendor_exists=1
|
|
else
|
|
vendor_ready=0
|
|
missing_vendor+=("$source_rel")
|
|
fi
|
|
|
|
if [[ "$reference_exists" == "1" && "$vendor_exists" == "1" ]]; then
|
|
if cmp -s "$reference_file" "$vendor_file"; then
|
|
vendor_hash_matches=1
|
|
else
|
|
vendor_match_ready=0
|
|
mismatched_vendor+=("$source_rel")
|
|
fi
|
|
elif [[ "$vendor_exists" != "1" ]]; then
|
|
vendor_hash_matches=0
|
|
fi
|
|
|
|
printf '%s\t%s\t%s\t%s\t%s\n' \
|
|
"$source_rel" \
|
|
"$reference_exists" \
|
|
"$vendor_exists" \
|
|
"$vendor_hash_matches" \
|
|
"phase0_reference_only_not_runtime_promoted" >> "$tmp"
|
|
done < "$MANIFEST"
|
|
|
|
mv -f "$tmp" "$REPORT"
|
|
trap - EXIT
|
|
|
|
join_csv() {
|
|
local IFS=,
|
|
printf '%s' "$*"
|
|
}
|
|
|
|
print_kv task_hal_source_manifest_status ok
|
|
print_kv task_hal_source_manifest_ready "$(( source_count > 0 && reference_ready == 1 ? 1 : 0 ))"
|
|
print_kv task_hal_source_manifest_path "$MANIFEST"
|
|
print_kv task_hal_source_manifest_report "$REPORT"
|
|
print_kv task_hal_source_count "$source_count"
|
|
print_kv task_source_count "$task_source_count"
|
|
print_kv hal_source_count "$hal_source_count"
|
|
print_kv motion_source_count "$motion_source_count"
|
|
print_kv nml_source_count "$nml_source_count"
|
|
print_kv libnml_source_count "$libnml_source_count"
|
|
print_kv task_hal_reference_source_ready "$reference_ready"
|
|
print_kv task_hal_vendor_source_ready "$vendor_ready"
|
|
print_kv task_hal_vendor_hash_match_ready "$vendor_match_ready"
|
|
print_kv task_hal_missing_reference_source_count "${#missing_reference[@]}"
|
|
print_kv task_hal_missing_reference_sources_ready "$(( ${#missing_reference[@]} == 0 ? 1 : 0 ))"
|
|
if [[ "${#missing_reference[@]}" -gt 0 ]]; then
|
|
print_kv task_hal_missing_reference_source_list "$(join_csv "${missing_reference[@]}")"
|
|
else
|
|
print_kv task_hal_missing_reference_source_list "-"
|
|
fi
|
|
if [[ "${#missing_vendor[@]}" -gt 0 ]]; then
|
|
print_kv task_hal_missing_vendor_source_list "$(join_csv "${missing_vendor[@]}")"
|
|
else
|
|
print_kv task_hal_missing_vendor_source_list "-"
|
|
fi
|
|
if [[ "${#mismatched_vendor[@]}" -gt 0 ]]; then
|
|
print_kv task_hal_mismatched_vendor_source_list "$(join_csv "${mismatched_vendor[@]}")"
|
|
else
|
|
print_kv task_hal_mismatched_vendor_source_list "-"
|
|
fi
|
|
print_kv task_hal_runtime_promoted 0
|
|
print_kv nativeTaskReady false
|
|
print_kv nativeHalSyncReady false
|
|
|
|
if [[ "$source_count" -eq 0 || "$reference_ready" != "1" ]]; then
|
|
exit 1
|
|
fi
|