1
0
Fork 0

compile.sh is now sh-compatible. (Unix, etc.)

This commit is contained in:
Safwat Halaby 2015-11-21 18:24:11 +02:00
parent 628ce5e394
commit 37921990a2
2 changed files with 31 additions and 33 deletions

View File

@ -22,7 +22,7 @@ There are several ways to obtain Cuberite.
##### The EasyInstall script ##### The EasyInstall script
This Linux script will download the correct binary from the project site. This Linux script will download the correct binary from the project site.
bash -c "$(wget -O - https://raw.githubusercontent.com/cuberite/cuberite/master/easyinstall.sh)" sh -c "$(wget -O - https://raw.githubusercontent.com/cuberite/cuberite/master/easyinstall.sh)"
#### Compiling #### Compiling
- You can compile automatically for Linux with the `compile.sh` script. The script is described below. - You can compile automatically for Linux with the `compile.sh` script. The script is described below.
@ -33,7 +33,7 @@ Compiling may provide better performance performance (1.5-3x as fast) and it sup
##### The compile.sh script ##### The compile.sh script
This script downloads the source code and compiles it. The script is smart enough to notify you of missing dependencies and instructing you on how to install them. The script doesn't work for Windows. This script downloads the source code and compiles it. The script is smart enough to notify you of missing dependencies and instructing you on how to install them. The script doesn't work for Windows.
bash -c "$(wget -O - https://raw.githubusercontent.com/cuberite/cuberite/master/compile.sh)" sh -c "$(wget -O - https://raw.githubusercontent.com/cuberite/cuberite/master/compile.sh)"
#### Hosted services #### Hosted services
- Hosted Cuberite is available DIY on DigitalOcean: [![Install on DigitalOcean](http://doinstall.bearbin.net/button.svg)](http:// doinstall.bearbin.net/install?url=https://github.com/cuberite/cuberite) and [Gamocosm](https://gamocosm.com) also offers Cuberite support. - Hosted Cuberite is available DIY on DigitalOcean: [![Install on DigitalOcean](http://doinstall.bearbin.net/button.svg)](http:// doinstall.bearbin.net/install?url=https://github.com/cuberite/cuberite) and [Gamocosm](https://gamocosm.com) also offers Cuberite support.

View File

@ -1,27 +1,29 @@
#!/bin/sh
#|| goto :windows_detected #|| goto :windows_detected
set -e
# Do we already have a repo? # Do we already have a repo?
if [[ -d .git && -f easyinstall.sh && -f src/BlockArea.cpp ]]; then # A good enough indicator that we're in the Cuberite git repo. if [ \( -d .git \) -a \( -f easyinstall.sh \) -a \( -f src/BlockArea.cpp \) ]; then # A good enough indicator that we're in the Cuberite git repo.
cd ../ cd ../
echo "Cuberite repository detected. This should make the process faster, especially if you compiled before." echo "Cuberite repository detected. This should make the process faster, especially if you compiled before."
fi fi
# Error functions. # Error functions.
function error error ()
{ {
echo echo
echo "-----------------" echo "-----------------"
echo "Script aborted, reason:" echo "Script aborted, reason:"
echo $1 echo $1
exit -1 exit 1
} }
function missingDepsExit missingDepsExit ()
{ {
echo echo
echo "Please install the dependencies, then come back." echo "Please install the dependencies, then come back."
echo echo
exit -2 exit 2
} }
@ -42,7 +44,7 @@ GCC_EXISTS=0
CLANG_EXISTS=0 CLANG_EXISTS=0
g++ --help > /dev/null 2> /dev/null && GCC_EXISTS=1 g++ --help > /dev/null 2> /dev/null && GCC_EXISTS=1
clang --help > /dev/null 2> /dev/null && CLANG_EXISTS=1 clang --help > /dev/null 2> /dev/null && CLANG_EXISTS=1
if [[ $GCC_EXISTS == 0 && $CLANG_EXISTS == 0 ]]; then if [ $GCC_EXISTS -eq 0 -a $CLANG_EXISTS -eq 0 ]; then
MISSING_PROGRAMS="gcc g++" MISSING_PROGRAMS="gcc g++"
fi fi
@ -54,7 +56,7 @@ git
make make
cmake cmake
EOF EOF
if [[ $MISSING_PROGRAMS != "" ]]; then if [ "$MISSING_PROGRAMS" != "" ]; then
echo echo
echo "-----------------" echo "-----------------"
echo "You have missing compilation dependencies:" echo "You have missing compilation dependencies:"
@ -88,7 +90,7 @@ fi
BRANCH="master" BRANCH="master"
### Inactive code start. ### ### Inactive code start. ###
function inactiveCode inactiveCode ()
{ {
# Echo: Branch choice. # Echo: Branch choice.
@ -109,12 +111,12 @@ echo
# Input: Branch choice. # Input: Branch choice.
echo -n "Choose the branch (s/t/d): " echo -n "Choose the branch (s/t/d): "
read BRANCH read BRANCH
if [[ ($BRANCH == "s") || ($BRANCH == "S" ) ]]; then if [ \( "$BRANCH" = "s" \) -o \( "$BRANCH" = "S" \) ]; then
#BRANCH="stable" #BRANCH="stable"
error "We don't have a stable branch yet, please use testing, sorry." error "We don't have a stable branch yet, please use testing, sorry."
elif [[ ($BRANCH == "t") || ($BRANCH == "T" ) ]]; then elif [ \( $BRANCH = "t" \) -o \( $BRANCH = "T" \) ]; then
BRANCH="testing" BRANCH="testing"
elif [[ ($BRANCH == "d") || ($BRANCH == "D" ) ]]; then elif [ \( $BRANCH = "d" \) -o \( $BRANCH = "D" \) ]; then
BRANCH="master" BRANCH="master"
else else
error "Unrecognized user input." error "Unrecognized user input."
@ -138,9 +140,9 @@ echo
# Input: Compile mode choice. # Input: Compile mode choice.
echo -n "Choose compile mode: (n/d): " echo -n "Choose compile mode: (n/d): "
read BUILDTYPE read BUILDTYPE
if [[ ($BUILDTYPE == "d") || ($BUILDTYPE == "D") ]]; then if [ \( "$BUILDTYPE" = "d" \) -o \( "$BUILDTYPE" = "D" \) ]; then
BUILDTYPE="Debug" BUILDTYPE="Debug"
elif [[ ($BUILDTYPE == "n") || ($BUILDTYPE == "N") ]]; then elif [ \( "$BUILDTYPE" = "n" \) -o \( "$BUILDTYPE" = "N" \) ]; then
BUILDTYPE="Release" BUILDTYPE="Release"
else else
error "Unrecognized user input." error "Unrecognized user input."
@ -152,21 +154,20 @@ echo
echo " --- Downloading Cuberite's source code from the $BRANCH branch..." echo " --- Downloading Cuberite's source code from the $BRANCH branch..."
# Git: Clone.
if [ ! -d cuberite ]; then if [ ! -d cuberite ]; then
# Git: Clone.
echo " --- Looks like your first run, cloning the whole code..." echo " --- Looks like your first run, cloning the whole code..."
git clone https://github.com/cuberite/cuberite.git git clone https://github.com/cuberite/cuberite.git
cd cuberite
else
# Git: Fetch.
cd cuberite
echo " --- Updating the $BRANCH branch..."
git fetch origin $BRANCH || error "git fetch failed"
git checkout $BRANCH || error "git checkout failed"
git merge origin/$BRANCH || error "git merge failed"
fi fi
# Git: Fetch.
pushd cuberite
echo " --- Updating the $BRANCH branch..."
git fetch origin $BRANCH || error "git fetch failed"
git checkout $BRANCH || error "git checkout failed"
git merge origin/$BRANCH || error "git merge failed"
# Git: Submodules. # Git: Submodules.
echo " --- Updating submodules..." echo " --- Updating submodules..."
git submodule update --init git submodule update --init
@ -175,7 +176,7 @@ git submodule update --init
# Cmake. # Cmake.
echo " --- Running cmake..." echo " --- Running cmake..."
if [ ! -d build-cuberite ]; then mkdir build-cuberite; fi if [ ! -d build-cuberite ]; then mkdir build-cuberite; fi
pushd build-cuberite cd build-cuberite
cmake .. -DCMAKE_BUILD_TYPE=$BUILDTYPE || error "cmake failed" cmake .. -DCMAKE_BUILD_TYPE=$BUILDTYPE || error "cmake failed"
@ -186,22 +187,19 @@ echo
# Echo: Compilation complete. # Echo: Compilation complete.
popd > /dev/null cd ../Server
pushd Server > /dev/null
echo echo
echo "-----------------" echo "-----------------"
echo "Compilation done!" echo "Compilation done!"
echo echo
echo "Cuberite awaits you at:" echo "Cuberite awaits you at:"
if [[ $BUILDTYPE == "Debug" ]]; then if [ "$BUILDTYPE" = "Debug" ]; then
echo "`pwd`/Cuberite_debug" echo "`pwd`/Cuberite_debug"
else else
echo "`pwd`/Cuberite" echo "`pwd`/Cuberite"
fi fi
echo echo
echo "Enjoy :)" echo "Enjoy :)"
popd > /dev/null
popd > /dev/null
exit 0 exit 0
:windows_detected :windows_detected