💎💎💎💎💎
This commit is contained in:
36
genx.sh
36
genx.sh
@ -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
|
||||
|
Reference in New Issue
Block a user