🤯🤯🤯🤯🤯🤯🤯🤯🤯

This commit is contained in:
Scarlett
2025-05-04 23:54:42 -04:00
parent 8b0d191409
commit 0fc796aa25
32 changed files with 867 additions and 1021 deletions

44
genx.sh
View File

@ -44,17 +44,57 @@ if [ ! -d "binaries" ]; then
mkdir -p binaries
fi
appendStd() {
if [ ! -f "$1" ]; then
echo "File not found: $1"
return 1
fi
backup_file="${1}.bak"
cp "$1" "$backup_file"
temp_file=$(mktemp)
while IFS= read -r line || [ -n "$line" ]; do
echo "$line" >> "$temp_file"
if [[ $line =~ ^#include\ \"[^\"]+\" ]]; then
include_file=$(echo "$line" | sed -n 's/.*"\([^"]*\)".*/\1/p')
if [[ $include_file == "std.alpha" ]]; then
echo -e "${GREEN}[GenX] ${WHITE}Including ${BLUE}std.alpha${WHITE}..."
if [ -f "library/std.alpha" ]; then
cat library/std.alpha >> "$temp_file"
else
echo -e "${RED}[GenX] ${YELLOW}File library/std.alpha not found!${WHITE}"
rm "$temp_file"
return 1
fi
fi
fi
done < "$1"
mv "$temp_file" "$1"
}
if [ $# -eq 1 ]; then
if [ -f "$1" ]; then
if [[ "$1" == *.alpha ]]; then
appendStd "$1"
./alpha -cg "$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..."
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}Generated executable file."
echo -e "${GREEN}[GenX] ${WHITE}Executable file: binaries/${filename}"
echo -e "${GREEN}[GenX] ${WHITE}Done!"
else