#!/bin/bash
set -e
target_dir=$1/"ets_frontend/ets2panda"
excluded_dirs=("lsp" "test" "driver" "bindings" "scripts")
excluded_file="$target_dir/util/es2pandaMacros.h"
exclude_prune=()
for dir in "${excluded_dirs[@]}"; do
exclude_prune+=(-path "*/$dir" -o)
done
unset 'exclude_prune[${#exclude_prune[@]}-1]'
found_entries=$(find "$target_dir" \
-type d \( "${exclude_prune[@]}" \) -prune -o \
-type f ! -path "$excluded_file" \
-exec grep -HnwE 'ASSERT|UNREACHABLE' {} +) || true
if [[ -n "$found_entries" ]]; then
echo "ERROR: Depricated macroses ASSERT or UNREACHABLE found."
echo "Please use ES2PANDA_ASSERT(_POS) or ES2PANDA_UNREACHABLE(_POS)."
echo "It's better to use *_POS version of macroses to specify position in source code."
echo "$found_entries"
exit 1
else
exit 0
fi