#!/bin/bash
# ANSI color codes
RED=$(tput setaf 1)
ORANGE=$(tput setaf 3)
NC=$(tput sgr0)
# The working directory is the same directory where this script is located
workspaceRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
processFile() {
file="$1"
# Print the name of the file being processed
echo -e "Processing file: $file"
# Run the compiler and color-code the output
"$workspaceRoot/amxxpc" "-d2" "$file" 2>&1 | \
sed -e "s/\(.*error.*\)/${RED}\1${NC}/" \
-e "s/\(.*warning.*\)/${ORANGE}\1${NC}/"
}
# If no command line arguments are provided, process all .sma files
if [ "$1" == "" ]; then
for file in "$workspaceRoot"/*.sma; do
processFile "$file"
done
read -p "Press Enter to continue..."
else
# For each command line argument
for file in "$@"; do
processFile "$file"
done
fi