#!/usr/bin/env bash # # Run the HLS pragma linter over the practicals. # # Usage: # ./lint.sh # every source under Practicals/ # ./lint.sh path/to/file.cpp [more.cpp ...] # just these # # Exits non-zero if anything is wrong, so it also works as a pre-commit or CI # check. For inline diagnostics inside nvim, see nvim/plugin/hls_pragma_lint.lua # set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ "$#" -gt 0 ]; then exec python3 "$here/hls_pragma_lint.py" "$@" fi # Resolve the parent properly: find returns the path as given, and # ".../hlsdev/.." would contain "/hlsdev/" and defeat the exclusions below. root="$(cd "$here/.." && pwd)" # Every hand-written source, skipping generated HLS build output and our own # tooling. Paths in the practicals never contain spaces (Vitis requires it). files="$(find "$root" -type f \( \ -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.c' \ -o -name '*.h' -o -name '*.hpp' \) \ -not -path '*/hls/*' -not -path '*/hlsdev/*' | sort)" if [ -z "$files" ]; then echo "no source files found" >&2 exit 0 fi echo "$files" | sed "s|^$root/| |" echo # shellcheck disable=SC2086 exec python3 "$here/hls_pragma_lint.py" $files