devkitARM Compilation BASH Script

Since I’m working a lot on a Mac laptop recently (because it’s the only laptop I could mooch off for free) I spent the last good three hours researching BASH and stuff to make a script to compile my asm goodies. And I thought I’d share because I’m that kind of person. Here ya go. You’ll want to run it in Automator using these instructions.
(Obviously, change the second line to where you installed devkitpro)

#!/bin/bash

devkit=(Where you installed devkit pro)/devkitpro/devkitARM/bin/

FileDir=$(dirname "$1")
FILE=$(basename "$1")
FileName="${FILE%.*}"

$devkit/arm-none-eabi-as -g -mcpu=arm7tdmi -mthumb-interwork "$1" -o "$FileDir/$FileName.elf"

#Print symbol table
#Use this if you want, I guess? I never used it so...
#/arm-none-eabi-readelf/ -s "%~n1.elf" "%~n1.symbols.log"

# Extract raw assembly binary (text section) from elf
$devkit/arm-none-eabi-objcopy -S "$FileDir/$FileName.elf" -O binary "$FileDir/$FileName.dmp"

rm "$FileDir/$FileName.elf"

echo "Compiled."

Edit: It’s really difficult to get compiler output if you run this through Automator. So either get your code right, or just use Terminal

may as well add that if you’re on a unix-based system, you can run assemble-arm from shell/terminal directly by running the following in the folder containing “assemble-arm.sh” (or just “assemble-arm” or whatever)

sudo cp ./assemble-arm.sh /usr/bin/assemble-arm sudo chmod +x /usr/bin/assemble-arm