1#!/bin/bash 2# Copyright (c) 2025 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -e 16 17target_dir=$1/"ets_frontend/ets2panda" 18excluded_dirs=("lsp" "test" "driver" "bindings" "scripts") 19excluded_file="$target_dir/util/es2pandaMacros.h" 20 21# Build exclude conditions for find 22exclude_prune=() 23for dir in "${excluded_dirs[@]}"; do 24 exclude_prune+=(-path "*/$dir" -o) 25done 26unset 'exclude_prune[${#exclude_prune[@]}-1]' # Remove last -o 27 28# Find and process files 29found_entries=$(find "$target_dir" \ 30 -type d \( "${exclude_prune[@]}" \) -prune -o \ 31 -type f ! -path "$excluded_file" \ 32 -exec grep -HnwE 'ASSERT|UNREACHABLE' {} +) || true 33 34# Format output and exit 35if [[ -n "$found_entries" ]]; then 36 echo "ERROR: Depricated macroses ASSERT or UNREACHABLE found." 37 echo "Please use ES2PANDA_ASSERT(_POS) or ES2PANDA_UNREACHABLE(_POS)." 38 echo "It's better to use *_POS version of macroses to specify position in source code." 39 echo "$found_entries" 40 exit 1 41else 42 exit 0 43fi