#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" manifest=${1:-linuxcnc-rs274-wasm-source-files.txt} filter_group=${2:-core} output_mode=${3:-relative} linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc} 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 case "$filter_group" in core|blocked|all) ;; *) echo "unknown manifest source filter: $filter_group" >&2 exit 1 ;; esac case "$output_mode" in relative|full) ;; *) echo "unknown manifest source output mode: $output_mode" >&2 exit 1 ;; esac seen_sources=() while IFS=: read -r group path note; do case "$group" in ""|\#*) continue ;; core|blocked) ;; *) echo "unknown manifest group: $group" >&2 exit 1 ;; esac if [[ ! -f "$linuxcnc_root/$path" ]]; then echo "missing manifest source: $path" >&2 exit 1 fi if printf '%s\n' "${seen_sources[@]}" | grep -Fx -- "$path" >/dev/null; then echo "duplicate manifest source: $path" >&2 exit 1 fi seen_sources+=("$path") if [[ "$filter_group" == "all" || "$filter_group" == "$group" ]]; then if [[ "$output_mode" == "full" ]]; then printf '%s\n' "$linuxcnc_root/$path" else printf '%s\n' "$path" fi fi done < "$manifest"