-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh.sh
More file actions
executable file
·58 lines (54 loc) · 1.53 KB
/
gh.sh
File metadata and controls
executable file
·58 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#THIS IS A "HOT" VERSON OF gba-dev.sh
#THIS ASSUMES THERE IS ONLY ONE .c FILE IN SAME DIR TO COMPILE
#DOES NOT PROMPT FOR FILENAME
#DOES NOT PROMPT FOR Y/N
#DEFAULTS TO ADDING TO PATH AND REMOVING .obj AND .elf FILES
#Designed for use with devkitARM toolchain.
#Developed on PopOs(ubuntu) 19.10 - 2020
#YMMV.
#Author: nfgrep
#This script needs to be in the same directory as the C file you wish to convert.
f=$(echo ./*.c)
compile_c () {
arm-none-eabi-gcc -c ./$1 -fno-strict-aliasing -mthumb-interwork -mthumb -O2 -o ${1//.c}.o
arm-none-eabi-gcc ${1//.c}.o -mthumb-interwork -mthumb -specs=gba.specs -o ${1//.c}.elf
}
compile_c $f
COMP_RES=$?
if [ $COMP_RES = 1 ]
then
echo "Does your C file have a \"Main\" function?"
exit 1
elif [ $COMP_RES = 127 ]
then
PATH=/opt/devkitpro/devkitARM/bin:$PATH
echo "Added /opt/devkitpro/devkitARM/bin to PATH"
echo "Retrying command..."
compile_c $f
if [ $? = 127 ]
then
echo "Still could not find command, check your installation"
exit 1
fi
fi
echo ${f//.c}
arm-none-eabi-objcopy -v -O binary ${f//.c}.elf ${f//.c}.gba
gbafix ${f//.c}.gba
if [ $? = 127 ]
then
PATH=$PATH:/opt/devkitpro/tools/bin
echo "/opt/devkitpro/tools/bin Added to PATH"
echo "Retrying command..."
gbafix ${f//.c}.gba
if [ $? = !0 ]
then
echo "gbafix may be installed in a different location."
echo "Exiting..."
exit 1
fi
fi
find ./ -wholename "${f//.c}.elf" -o -wholename "${f//.c}.o" | xargs rm -v
echo ""
echo "Done..."
echo ""