mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-23 02:55:27 +01:00
Update yapfa
This commit is contained in:
parent
f72fe7e136
commit
f46463e082
301
yapfa
301
yapfa
@ -1,132 +1,201 @@
|
||||
#!/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
|
||||
# Akarin Build Script
|
||||
|
||||
paperstash() {
|
||||
STASHED=$(git stash)
|
||||
############################################################################
|
||||
# Multicore building #
|
||||
# By JosephWorks #
|
||||
# -------------------------------------------------------------------------#
|
||||
# To use multicore building, use "$mvncmd" instead of "maven" #
|
||||
# 20-50% speed improvement is quite common. #
|
||||
############################################################################
|
||||
|
||||
# Exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
source "./scripts/functions.sh"
|
||||
|
||||
function setupUpstreamAndPatch {
|
||||
basedir
|
||||
if [ "$1" == "--updatePaper" ]; then
|
||||
$scriptdir/updateUpstream.sh "$basedir" 1 || exit 1
|
||||
else
|
||||
if [ "$1" != "--skipPaper" ]; then
|
||||
$scriptdir/updateUpstream.sh "$basedir" 0 || exit 1 # not update submodule
|
||||
fi
|
||||
fi
|
||||
$scriptdir/applyPatches.sh "$basedir" || exit 1
|
||||
}
|
||||
|
||||
paperunstash() {
|
||||
if [[ "$STASHED" != "No local changes to save" ]] ; then
|
||||
git stash pop
|
||||
fi
|
||||
}
|
||||
failed=0
|
||||
case "$1" in
|
||||
"rb" | "rbp" | "rebuild")
|
||||
(
|
||||
set -e
|
||||
cd "$basedir"
|
||||
scripts/rebuildpatches.sh "$basedir" || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"p" | "patch" | "apply")
|
||||
(
|
||||
set -e
|
||||
cd "$basedir"
|
||||
scripts/apply.sh "$basedir" || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"b" | "bu" | "build")
|
||||
(
|
||||
basedir
|
||||
mvn -N install
|
||||
cd ${FORK_NAME}-API
|
||||
mvn clean install && cd ../${FORK_NAME}-Server && mvn clean install
|
||||
) || failed=1
|
||||
;;
|
||||
"jar" | "paperclip")
|
||||
"r" | "rb" | "rbp" | "rebuild")
|
||||
(
|
||||
set -e
|
||||
basedir
|
||||
$scriptdir/importSources.sh "$basedir" || exit 1
|
||||
$scriptdir/rebuildPatches.sh "$basedir" || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"a" | "p" | "patch" | "apply")
|
||||
(
|
||||
set -e
|
||||
setupUpstreamAndPatch $2 || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"b" | "bu" | "build" | "install")
|
||||
(
|
||||
set -e
|
||||
setupUpstreamAndPatch $2 || exit 1
|
||||
basedir
|
||||
$mvncmd -N install || exit 1
|
||||
cd ${FORK_NAME}-API
|
||||
$mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"j" | "launcher" | "jar" | "paperclip")
|
||||
(
|
||||
setupUpstreamAndPatch $2 || exit 1
|
||||
basedir
|
||||
cd "$basedir"
|
||||
./scripts/paperclip.sh
|
||||
$mvncmd -N install surefire-report:report
|
||||
cd ${FORK_NAME}-API
|
||||
$mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install surefire-report:report
|
||||
basedir
|
||||
$scriptdir/installLauncher.sh "$basedir"
|
||||
) || failed=1
|
||||
;;
|
||||
"d" | "de" | "deploy")
|
||||
(
|
||||
basedir
|
||||
$mvncmd -N install
|
||||
cd ${FORK_NAME}-API
|
||||
$mvncmd clean deploy && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd clean install
|
||||
)
|
||||
;;
|
||||
"d" | "de" | "deploy")
|
||||
(
|
||||
basedir
|
||||
mvn -N install
|
||||
cd ${FORK_NAME}-API
|
||||
mvn clean deploy && cd ../${FORK_NAME}-Server && mvn clean install
|
||||
) || failed=1
|
||||
;;
|
||||
"up" | "upstream")
|
||||
(
|
||||
cd "$basedir"
|
||||
scripts/upstream.sh "$2" || exit 1
|
||||
if [ "$2" == "up" ]; then
|
||||
(scripts/apply.sh "$basedir" && scripts/rebuildpatches.sh "$basedir" && scripts/commitup.sh) || exit 1
|
||||
fi
|
||||
) || failed=1
|
||||
;;
|
||||
"cup" | "commitup" | "upc" | "upcommit")
|
||||
(
|
||||
cd "$basedir"
|
||||
scripts/commitup.sh || exit 1
|
||||
) || failed=1
|
||||
;;
|
||||
"r" | "root")
|
||||
cd "$basedir"
|
||||
;;
|
||||
"a" | "api")
|
||||
cd "$basedir/YAPFA-API"
|
||||
;;
|
||||
"s" | "server")
|
||||
cd "$basedir/YAPFA-Server"
|
||||
;;
|
||||
"setup")
|
||||
if [[ -f ~/.bashrc ]] ; then
|
||||
NAME="ec"
|
||||
if [[ ! -z "${2+x}" ]] ; then
|
||||
NAME="$2"
|
||||
fi
|
||||
(grep "alias $NAME=" ~/.bashrc > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >> ~/.bashrc)
|
||||
alias "$NAME=. $SOURCE"
|
||||
echo "You can now just type '$NAME' at any time to access the paper tool."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "YAPFA build tool command. This provides a variety of commands to build and manage the PaperMC 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 " * rb, rebuild | Rebuild patches, can be called from anywhere."
|
||||
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
|
||||
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere."
|
||||
echo " * b, build | Build API and Server but no deploy. Can be ran anywhere."
|
||||
echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere."
|
||||
echo ""
|
||||
echo " These commands require the setup command before use:"
|
||||
echo " * r, root | Change directory to the root of the project."
|
||||
echo " * a. api | Move to the Paper-API directory."
|
||||
echo " * s, server | Move to the Paper-Server directory."
|
||||
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
|
||||
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
|
||||
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
|
||||
echo ""
|
||||
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
|
||||
echo " | . ./paper setup"
|
||||
echo " | After you run this command you'll be able to just run 'paper' from anywhere."
|
||||
echo " | The default name for the resulting alias is 'paper', you can give an argument to override"
|
||||
echo " | this default, such as:"
|
||||
echo " | . ./paper setup example"
|
||||
echo " | Which will allow you to run 'example' instead."
|
||||
;;
|
||||
"u" | "up" | "upstream" | "update")
|
||||
(
|
||||
basedir
|
||||
$scriptdir/updateUpstream.sh "$basedir" 1
|
||||
)
|
||||
;;
|
||||
"r" | "root")
|
||||
basedir
|
||||
;;
|
||||
"a" | "api")
|
||||
cd "$basedir/Akarin-API"
|
||||
;;
|
||||
"s" | "server")
|
||||
cd "$basedir/Akarin-Server"
|
||||
;;
|
||||
"c" | "clean")
|
||||
rm -rf Akarin-API
|
||||
rm -rf Akarin-Server
|
||||
rm -rf Paper
|
||||
echo "Cleaned build files"
|
||||
;;
|
||||
"e" | "edit")
|
||||
case "$2" in
|
||||
"s" | "server")
|
||||
export AKARIN_LAST_EDIT="$basedir/Akarin-Server"
|
||||
cd "$basedir/Akarin-Server"
|
||||
(
|
||||
set -e
|
||||
gitstash
|
||||
cd "$basedir/Paper/Paper-Server"
|
||||
$gitcmd fetch --all
|
||||
# Create the upstream branch in Paper project with current state
|
||||
$gitcmd checkout master # possibly already in
|
||||
$gitcmd branch -D upstream || true
|
||||
$gitcmd branch -f upstream HEAD
|
||||
cd "$basedir/Akarin-Server"
|
||||
$gitcmd rebase -i upstream/upstream
|
||||
gitunstash
|
||||
)
|
||||
;;
|
||||
"a" | "api")
|
||||
export AKARIN_LAST_EDIT="$basedir/Akarin-API"
|
||||
cd "$basedir/Akarin-API"
|
||||
(
|
||||
set -e
|
||||
gitstash
|
||||
cd "$basedir/Paper/Paper-API"
|
||||
$gitcmd fetch --all
|
||||
# Create the upstream branch in Paper project with current state
|
||||
$gitcmd checkout master # possibly already in
|
||||
$gitcmd branch -D upstream || true
|
||||
$gitcmd branch -f upstream HEAD
|
||||
cd "$basedir/Akarin-API"
|
||||
$gitcmd rebase -i upstream/upstream
|
||||
gitunstash
|
||||
)
|
||||
;;
|
||||
"c" | "continue")
|
||||
cd "$AKARIN_LAST_EDIT"
|
||||
unset AKARIN_LAST_EDIT
|
||||
(
|
||||
set -e
|
||||
$gitcmd add .
|
||||
$gitcmd commit --amend
|
||||
$gitcmd rebase --continue
|
||||
basedir
|
||||
$scriptdir/rebuildPatches.sh "$basedir"
|
||||
)
|
||||
;;
|
||||
*)
|
||||
echo "You must edit either the api or server."
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"setup")
|
||||
if [[ -f ~/.bashrc ]] ; then
|
||||
NAME="akarin"
|
||||
if [[ ! -z "${2+x}" ]] ; then
|
||||
NAME="$2"
|
||||
fi
|
||||
(grep "alias $NAME=" ~/.bashrc > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >> ~/.bashrc)
|
||||
alias "$NAME=. $SOURCE"
|
||||
echo "You can now just type '$NAME' at any time to access the akarin tool."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Akarin build tool command. This provides a variety of commands to build and manage the Akarin 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 " * r, rebuild | Rebuild patches, can be called from anywhere."
|
||||
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
|
||||
echo " * u, update | Update and patch the Paper submodule. Can be run from anywhere."
|
||||
echo " * b, build | Build the projects, including the API and the Server. Can be ran anywhere."
|
||||
echo " * j, jar | Build the projects and build the launcher jar. Can be ran anywhere."
|
||||
echo " * d, deploy | Build the projects and deploy through Maven. Can be ran anywhere."
|
||||
echo ""
|
||||
echo " These commands require the setup command before use:"
|
||||
echo " * r, root | Change directory to the root of the project."
|
||||
echo " * a. api | Move to the Akarin-API directory."
|
||||
echo " * s, server | Move to the Akarin-Server directory."
|
||||
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
|
||||
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
|
||||
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
|
||||
echo ""
|
||||
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
|
||||
echo " | . ./akarin setup"
|
||||
echo " | After you run this command you'll be able to just run 'akarin' from anywhere."
|
||||
echo " | The default name for the resulting alias is 'akarin', you can give an argument to override"
|
||||
echo " | this default, such as:"
|
||||
echo " | . ./akarin setup example"
|
||||
echo " | Which will allow you to run 'example' instead."
|
||||
;;
|
||||
esac
|
||||
|
||||
unset -f paperstash
|
||||
unset -f paperunstash
|
||||
if [ "$failed" == "1" ]; then
|
||||
unset RCPATH
|
||||
unset SOURCE
|
||||
unset basedir
|
||||
unset -f color
|
||||
unset -f colorend
|
||||
unset -f gitstash
|
||||
unset -f gitunstash
|
||||
if [[ "$failed" == "1" ]]; then
|
||||
unset failed
|
||||
false
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user