Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better compile.sh script #1089

Open
SergeyShorokhov opened this issue Jan 6, 2024 · 0 comments
Open

better compile.sh script #1089

SergeyShorokhov opened this issue Jan 6, 2024 · 0 comments

Comments

@SergeyShorokhov
Copy link
Contributor

image

#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant