forked from hpfxd/PandaSpigot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
panda
executable file
·81 lines (74 loc) · 2.01 KB
/
panda
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
#!/usr/bin/env bash
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
. "$basedir/scripts/init.sh"
paperstash() {
STASHED=$(git stash)
}
paperunstash() {
if [[ "$STASHED" != "No local changes to save" ]] ; then
git stash pop
fi
}
buildpaperclipjar() {
cp -f scripts/basepaperclip.sh base/Paper/paperclip.sh
cd base/Paper
./paperclip.sh
cd "$basedir"
}
case "$1" in
"setup")
cd "$basedir"
scripts/upstream.sh
;;
"build")
log_info "Preparing to build PandaSpigot"
cd "$basedir"
scripts/upstream.sh
scripts/apply.sh "$basedir"
./gradlew build
buildpaperclipjar
;;
"rb" | "rbp" | "rebuild")
(
set -e
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"p" | "patch" | "apply")
(
set -e
cd "$basedir"
scripts/apply.sh "$basedir"
log_info " Run './panda jar' to create a runnable JAR."
)
;;
"j" | "jar")
(
set -e
cd "$basedir"
./gradlew build
buildpaperclipjar
)
;;
*)
echo "PandaSpigot build tool."
echo ""
echo " Commands:"
echo " * setup | Setup the build environment"
echo " * build | Setup the build environment, apply patches, and create a runnable JAR"
echo " * p, patch | Apply patches"
echo " * rb, rebuild | Rebuild patches"
echo " * j, jar | Create a runnable JAR"
;;
esac
unset -f paperstash
unset -f paperunstash