-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsm64AndroidBuilder2
110 lines (98 loc) · 2.06 KB
/
sm64AndroidBuilder2
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#Helper script
#non-v1 didn't have a built-in updater
BASEDIR=sm64-port-android
VERSION=4
VCHECK=https://raw.githubusercontent.com/VDavid003/sm64AndroidBuilder/master/helperVersion
UPDATE_HELPER=https://raw.githubusercontent.com/VDavid003/sm64AndroidBuilder/master/sm64AndroidBuilder2
ONLINEVERSION=$(wget --no-cache --no-cookies -q -O - $VCHECK)
if [ -z $ONLINEVERSION ]; then ONLINEVERSION=0; fi
fail() {
echo "$1"
exit 1
}
if [ $ONLINEVERSION -gt $VERSION ];
then
wget --no-cache --no-cookies $UPDATE_HELPER -O sm64AndroidBuilder2
./sm64AndroidBuilder2 "$@"
exit 0
fi
case "$1" in
# init
"init")
rm -rf $BASEDIR
git clone https://github.com/VDavid003/sm64-port-android $BASEDIR || fail "Failed to clone! Check your network connection!"
pushd $BASEDIR
./getSDL.sh
popd
;;
"make")
shift
while [[ $# -gt 0 ]]
do
key="$1"
shift
case $key in
#make params, -p <params>
-p|--parameters)
PARAMS=$1
shift
;;
#reset tree
-r|--reset)
RESET=1
;;
#make clean
-c|--clean)
CLEAN=1
;;
#update source code
-u|--update)
UPDATE=1
;;
#branch, -b <branch>
-b|--branch)
BRANCH=$1
shift
;;
#patches -pa <patches> (in quotes, space seperated)
-pa|--patches)
PATCHES=($1)
shift
;;
esac
done
pushd $BASEDIR
if [ ! -z "$RESET" ];
then
mv *.z64 .git #Yes I know I'm moving it to .git but it's temporary so it's okay
rm -rf ./*
git reset --hard
./getSDL.sh
mv .git/*.z64 .
fi
if [ ! -z "$BRANCH" ] && [ ! $(git symbolic-ref --short -q HEAD) = $BRANCH ];
then
git checkout $BRANCH || fail "Failed to switch branch! Try resetting!"
fi
if [ ! -z "$UPDATE" ];
then
git reset --hard
git pull || fail "Failed to update! Check your network connection!"
fi
if [ ! -z "PATCHES" ];
then
for patch in ${PATCHES[@]}; do
git apply enhancements/$patch.patch
done
fi
if [ ! -z "$CLEAN" ]; then make clean; fi
make $PARAMS
if [ ! -z "PATCHES" ];
then
for ((i=${#PATCHES[@]}-1; i>=0; i--)); do
git apply -R enhancements/${PATCHES[$i]}.patch
done
fi
popd
esac