2020-02-26 17:23:57 +01:00
|
|
|
#!/usr/bin/env bash
|
2020-07-15 21:01:05 +02:00
|
|
|
|
2020-08-03 18:48:42 +02:00
|
|
|
# Yatopia Build Script
|
2020-02-26 17:23:57 +01:00
|
|
|
|
2020-07-15 20:38:19 +02:00
|
|
|
############################################################################
|
|
|
|
# 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"
|
2020-02-26 17:23:57 +01:00
|
|
|
|
2020-07-17 04:55:24 +02:00
|
|
|
JAVA_VERSION=`java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'`
|
|
|
|
|
2020-02-26 17:23:57 +01:00
|
|
|
failed=0
|
|
|
|
case "$1" in
|
2020-08-03 18:48:42 +02:00
|
|
|
"reset")
|
|
|
|
(
|
|
|
|
$scriptdir/resetToUpstream.sh "$basedir"
|
|
|
|
) || failed=1
|
|
|
|
;;
|
|
|
|
"i" | "in" | "init" | "initsubmodules")
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
basedir
|
|
|
|
$scriptdir/initUpstream.sh "$basedir" || exit 1
|
|
|
|
) || failed=1
|
|
|
|
;;
|
2020-07-15 20:38:19 +02:00
|
|
|
"r" | "rb" | "rbp" | "rebuild")
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
basedir
|
2020-08-03 18:48:42 +02:00
|
|
|
#$scriptdir/importSources.sh "$basedir" || exit 1
|
2020-07-15 20:38:19 +02:00
|
|
|
$scriptdir/rebuildPatches.sh "$basedir" || exit 1
|
|
|
|
) || failed=1
|
|
|
|
;;
|
|
|
|
"a" | "p" | "patch" | "apply")
|
|
|
|
(
|
|
|
|
set -e
|
2020-07-17 04:02:27 +02:00
|
|
|
$scriptdir/applyPatches.sh "$basedir" || exit 1
|
2020-07-15 20:38:19 +02:00
|
|
|
) || failed=1
|
|
|
|
;;
|
|
|
|
"b" | "bu" | "build" | "install")
|
|
|
|
(
|
2020-07-17 05:05:44 +02:00
|
|
|
echo "$JAVA_VERSION"
|
|
|
|
basedir
|
|
|
|
$mvncmd -N install surefire-report:report
|
|
|
|
cd ${FORK_NAME}-API
|
2020-08-06 16:05:19 +02:00
|
|
|
$mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install
|
2020-07-15 20:38:19 +02:00
|
|
|
) || failed=1
|
|
|
|
;;
|
2020-07-17 04:02:27 +02:00
|
|
|
"j" | "launcher" | "jar" | "paperclip")
|
2020-07-15 20:38:19 +02:00
|
|
|
(
|
2020-07-17 05:05:44 +02:00
|
|
|
basedir
|
|
|
|
$scriptdir/installLauncher.sh "$basedir"
|
2020-07-17 04:02:27 +02:00
|
|
|
) || failed=1
|
2020-03-22 17:20:21 +01:00
|
|
|
;;
|
2020-07-15 20:38:19 +02:00
|
|
|
"u" | "up" | "upstream" | "update")
|
|
|
|
(
|
|
|
|
basedir
|
|
|
|
$scriptdir/updateUpstream.sh "$basedir" 1
|
|
|
|
)
|
|
|
|
;;
|
|
|
|
"r" | "root")
|
|
|
|
basedir
|
|
|
|
;;
|
|
|
|
"a" | "api")
|
2020-08-03 18:48:42 +02:00
|
|
|
cd "$basedir/Yatopia-API"
|
2020-07-15 20:38:19 +02:00
|
|
|
;;
|
|
|
|
"s" | "server")
|
2020-08-03 18:48:42 +02:00
|
|
|
cd "$basedir/Yatopia-Server"
|
2020-07-17 04:02:27 +02:00
|
|
|
;;
|
|
|
|
"fup" | "fetchupstream")
|
|
|
|
$scriptdir/fetchUpstream.sh "$basedir" || exit 1
|
2020-07-15 20:38:19 +02:00
|
|
|
;;
|
|
|
|
"c" | "clean")
|
2020-08-03 18:48:42 +02:00
|
|
|
rm -rf Yatopia-API
|
|
|
|
rm -rf Yatopia-Server
|
2020-07-15 20:38:19 +02:00
|
|
|
rm -rf Paper
|
|
|
|
echo "Cleaned build files"
|
|
|
|
;;
|
2020-07-17 04:02:27 +02:00
|
|
|
"f" | "fu" | "full" | "fullbuild")
|
|
|
|
(
|
2020-07-17 05:05:44 +02:00
|
|
|
echo "$JAVA_VERSION"
|
2020-08-03 18:48:42 +02:00
|
|
|
$scriptdir/initUpstream.sh "$basedir" || exit 1
|
2020-07-17 04:02:27 +02:00
|
|
|
basedir
|
|
|
|
$scriptdir/updateUpstream.sh "$basedir" || exit 1
|
|
|
|
set -e
|
|
|
|
$scriptdir/applyPatches.sh "$basedir" || exit 1
|
|
|
|
basedir
|
|
|
|
$mvncmd -N install surefire-report:report
|
|
|
|
cd ${FORK_NAME}-API
|
2020-08-03 18:48:42 +02:00
|
|
|
($mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install surefire-report:report) || exit 1
|
2020-07-17 05:44:48 +02:00
|
|
|
$scriptdir/installLauncher.sh "$basedir" || exit 1
|
|
|
|
) || failed=1
|
2020-07-17 04:02:27 +02:00
|
|
|
;;
|
2020-07-15 20:38:19 +02:00
|
|
|
"e" | "edit")
|
|
|
|
case "$2" in
|
|
|
|
"s" | "server")
|
2020-08-03 18:48:42 +02:00
|
|
|
export Yatopia_LAST_EDIT="$basedir/Yatopia-Server"
|
|
|
|
cd "$basedir/Yatopia-Server"
|
2020-07-15 20:38:19 +02:00
|
|
|
(
|
|
|
|
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
|
2020-08-03 18:48:42 +02:00
|
|
|
cd "$basedir/Yatopia-Server"
|
2020-07-15 20:38:19 +02:00
|
|
|
$gitcmd rebase -i upstream/upstream
|
|
|
|
gitunstash
|
|
|
|
)
|
|
|
|
;;
|
|
|
|
"a" | "api")
|
2020-08-03 18:48:42 +02:00
|
|
|
export Yatopia_LAST_EDIT="$basedir/Yatopia-API"
|
|
|
|
cd "$basedir/Yatopia-API"
|
2020-07-15 20:38:19 +02:00
|
|
|
(
|
|
|
|
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
|
2020-08-03 18:48:42 +02:00
|
|
|
cd "$basedir/Yatopia-API"
|
2020-07-15 20:38:19 +02:00
|
|
|
$gitcmd rebase -i upstream/upstream
|
|
|
|
gitunstash
|
|
|
|
)
|
|
|
|
;;
|
|
|
|
"c" | "continue")
|
2020-08-03 18:48:42 +02:00
|
|
|
cd "$Yatopia_LAST_EDIT"
|
|
|
|
unset Yatopia_LAST_EDIT
|
2020-07-15 20:38:19 +02:00
|
|
|
(
|
|
|
|
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
|
2020-08-03 18:48:42 +02:00
|
|
|
NAME="Yatopia"
|
2020-07-15 20:38:19 +02:00
|
|
|
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"
|
2020-08-03 18:48:42 +02:00
|
|
|
echo "You can now just type '$NAME' at any time to access the Yatopia tool."
|
2020-07-15 20:38:19 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
2020-08-03 18:48:42 +02:00
|
|
|
echo "Yatopia build tool command. This provides a variety of commands to build and manage the Yatopia build"
|
2020-07-15 20:38:19 +02:00
|
|
|
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."
|
2020-08-03 18:48:42 +02:00
|
|
|
echo " * a. api | Move to the Yatopia-API directory."
|
|
|
|
echo " * s, server | Move to the Yatopia-Server directory."
|
2020-07-15 20:38:19 +02:00
|
|
|
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:"
|
2020-08-03 18:48:42 +02:00
|
|
|
echo " | . ./Yatopia setup"
|
|
|
|
echo " | After you run this command you'll be able to just run 'Yatopia' from anywhere."
|
|
|
|
echo " | The default name for the resulting alias is 'Yatopia', you can give an argument to override"
|
2020-07-15 20:38:19 +02:00
|
|
|
echo " | this default, such as:"
|
2020-08-03 18:48:42 +02:00
|
|
|
echo " | . ./Yatopia setup example"
|
2020-07-15 20:38:19 +02:00
|
|
|
echo " | Which will allow you to run 'example' instead."
|
|
|
|
;;
|
2020-02-26 17:23:57 +01:00
|
|
|
esac
|
|
|
|
|
2020-07-15 20:38:19 +02:00
|
|
|
unset RCPATH
|
|
|
|
unset SOURCE
|
|
|
|
unset basedir
|
|
|
|
unset -f color
|
|
|
|
unset -f colorend
|
|
|
|
unset -f gitstash
|
|
|
|
unset -f gitunstash
|
|
|
|
if [[ "$failed" == "1" ]]; then
|
2020-02-26 17:23:57 +01:00
|
|
|
unset failed
|
|
|
|
false
|
|
|
|
else
|
|
|
|
unset failed
|
|
|
|
true
|
|
|
|
fi
|