💎💎💎💎💎

This commit is contained in:
Scarlett
2025-05-05 14:28:02 -04:00
parent e51bea728b
commit 76f98b93ab
2 changed files with 29 additions and 17 deletions

36
genx.sh
View File

@ -76,31 +76,39 @@ appendStd() {
mv "$temp_file" "$1"
}
ass() {
gcc "$1" library/alpha_lib_reg.s library/alpha_driver.s -no-pie -o binaries/${2}
if [ $? -eq 0 ]; then
echo -e "${GREEN}[GenX] ${WHITE}Executable file: binaries/${2}"
echo -e "${GREEN}[GenX] ${WHITE}Done!"
else
echo -e "${RED}[GenX] ${YELLOW}Error generating executable file!${WHITE}"
exit 1
fi
}
if [ $# -eq 1 ]; then
if [ -f "$1" ]; then
filename=$(basename -- "$1")
if [[ "$1" == *.alpha ]]; then
filename="${filename:0:${#filename}-6}"
s_name="out/${filename}.s"
appendStd "$1"
./alpha -cg "$1"
./alpha -ir -tc -asc -cg -st "$1"
backup_file="${1}.bak"
if [ -f "$backup_file" ]; then
mv "$backup_file" "$1"
echo -e "${GREEN}[GenX] ${WHITE}Reverted $1 to its original state."
fi
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
ass "$s_name" "$filename"
elif [[ "$1" == *.s ]]; then
filename="${filename:0:${#filename}-2}"
s_name="out/${filename}.s"
echo -e "${GREEN}[GenX] ${WHITE}File $1 is a .s file! (Skipping compiler)${WHITE}"
ass "$s_name" "$filename"
exit 1
else
echo -e "${RED}[GenX] ${YELLOW}File $1 is not a .alpha file!${WHITE}"
exit 1