Files
Purpur/purpur
2020-07-30 12:00:00 -05:00

107 lines
2.7 KiB
Bash
Executable File

#!/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
purpurstash() {
STASHED=$(git stash)
}
purpurunstash() {
if [[ "$STASHED" != "No local changes to save" ]]; then
git stash pop
fi
}
case "$1" in
"p" | "patch" | "apply")
(
set -e
cd "$basedir"
scripts/apply.sh "$basedir"
)
;;
"b" | "bu" | "build")
(
basedir
mvn -N install
cd Purpur-API
mvn -e clean install
cd ../Paper/Paper-MojangAPI
mvn -e clean install
cd ../../Purpur-Server
mvn -e clean install
)
;;
"rb" | "rbp" | "rebuild")
(
set -e
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"am" | "amend")
(
cd "$basedir"/Purpur-API/
git add .
git commit --amend --no-edit
cd "$basedir"/Purpur-Server/
git add .
git commit --amend --no-edit
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"up" | "upstream")
(
cd "$basedir"
scripts/upstream.sh "$2"
)
;;
"jar" | "purpurclip")
(
basedir
cd "$basedir"
if [ "$2" != "fast" ]; then
scripts/upstream.sh
fi
./scripts/apply.sh "$basedir"
cd "$basedir"
mvn -N install
cd Purpur-API
mvn -e clean install
cd ../Paper/Paper-MojangAPI
mvn -e clean install
cd ../../Purpur-Server
mvn -e clean install
cd "$basedir"
./scripts/purpurclip.sh
)
;;
*)
echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build"
echo "environment. For all of the functionality of this command to be available, you must first run the"
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo ""
echo " Normal commands:"
echo " * p, patch | Apply all patches to top of Paper without building it"
echo " * b, build | Build Purpur API and Server"
echo " * rb, rebuild | Rebuild patches"
echo " * am, amend | Amend current edits to last patches"
echo " * up, upstream | Build Paper upstream, pass arg up to update paper"
echo " * jar, purpurclip | Apply all patches and build the project, purpurclip.jar will be output"
;;
esac
unset -f purpurstash
unset -f purpurunstash