This commit is contained in:
Scarlett
2025-05-04 18:41:02 -04:00
parent 8c6372fcfd
commit 3f7c79b801
3 changed files with 86 additions and 6 deletions

74
genx.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/bash
# GenX Tool #
# The Translators - Spring 2025 #
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
if [ ! -f "./alpha" ]; then
echo -e "${RED}[GenX] ${YELLOW}File ./alpha not found! Generating with 'make'.${WHITE}"
make
fi
help() {
echo -e "${WHITE}-----{ ${BLUE}GenX.sh Help ${WHITE}}-----\n"
echo -e "${YELLOW} Arguments: ${WHITE}"
echo -e "${GREEN} -help ${WHITE} Displays this message\n"
echo -e "${YELLOW} Usage: ${WHITE}"
echo -e "${GREEN} ./genx.sh <file.alpha>${WHITE} Generates executable file from <file.alpha>\n"
echo -e "${YELLOW} Notes: ${WHITE}"
echo -e "${ORANGE} Generates .s and links alpha driver and general library."
echo -e "${WHITE}-----------------------------------------\n"
exit 1
}
if [ $# -eq 0 ]; then
help
fi
if [ ! -d "binaries" ]; then
mkdir -p binaries
fi
if [ $# -eq 1 ]; then
if [ -f "$1" ]; then
if [[ "$1" == *.alpha ]]; then
./alpha -cg "$1"
filename=$(basename -- "$1")
filename="${filename:0:${#filename}-6}"
s_name="out/${filename}.s"
echo -e "${GREEN}[GenX] ${WHITE}Generated .s file..."
gcc ${s_name} library/alpha_lib_reg.s library/alpha_driver.s -no-pie -o binaries/${filename}
if [ $? -eq 0 ]; then
echo -e "${GREEN}[GenX] ${WHITE}Generated executable file..."
echo -e "${GREEN}[GenX] ${WHITE}Executable file: binaries/${filename}"
echo -e "${GREEN}[GenX] ${WHITE}Done!"
else
echo -e "${RED}[GenX] ${YELLOW}Error generating executable file!${WHITE}"
exit 1
fi
else
echo -e "${RED}[GenX] ${YELLOW}File $1 is not a .alpha file!${WHITE}"
exit 1
fi
else
echo -e "${RED}[GenX] ${YELLOW}File $1 not found!${WHITE}"
exit 1
fi
else
help
fi