Merge pull request #3081 from Arthur2e5/master
Some careless review on compile.sh
This commit is contained in:
commit
64b136c6d8
98
compile.sh
98
compile.sh
@ -6,9 +6,9 @@ set -e
|
|||||||
#TODO command line parameter handling for non-interactive mode.
|
#TODO command line parameter handling for non-interactive mode.
|
||||||
|
|
||||||
# Do we already have a repo?
|
# Do we already have a 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.
|
if [ -d .git ] && [ -f easyinstall.sh ] && [ -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.
|
||||||
@ -17,7 +17,7 @@ error ()
|
|||||||
echo
|
echo
|
||||||
echo "-----------------"
|
echo "-----------------"
|
||||||
echo "Script aborted, reason:"
|
echo "Script aborted, reason:"
|
||||||
echo $1
|
echo "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,17 +69,16 @@ GCC_EXISTS=0
|
|||||||
CLANG_EXISTS=0
|
CLANG_EXISTS=0
|
||||||
$GCC_EXE_NAME --help > /dev/null 2> /dev/null && GCC_EXISTS=1
|
$GCC_EXE_NAME --help > /dev/null 2> /dev/null && GCC_EXISTS=1
|
||||||
$CLANG_EXE_NAME --help > /dev/null 2> /dev/null && CLANG_EXISTS=1
|
$CLANG_EXE_NAME --help > /dev/null 2> /dev/null && CLANG_EXISTS=1
|
||||||
if [ $GCC_EXISTS -eq 0 -a $CLANG_EXISTS -eq 0 ]; then
|
if [ "$GCC_EXISTS" -eq 0 ] && [ "$CLANG_EXISTS" -eq 0 ]; then
|
||||||
MISSING_PACKAGES=" $COMPILER_PACKAGE_NAME"
|
MISSING_PACKAGES=" $COMPILER_PACKAGE_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Depdendency check.
|
# Depdendency check.
|
||||||
checkPackages ()
|
checkPackages ()
|
||||||
{
|
{
|
||||||
echo "$PROGRAMS" | while read line; do
|
# note that IFS is a TAB here!
|
||||||
EXE_NAME=`echo "$line" | cut -f 1`
|
echo "$PROGRAMS" | while IFS=' ' read EXE_NAME PACKAGE_NAME __trash__; do
|
||||||
PACKAGE_NAME=`echo "$line" | cut -f 2`
|
command -v $EXE_NAME > /dev/null 2> /dev/null || printf %s " $PACKAGE_NAME"
|
||||||
command -v $EXE_NAME > /dev/null 2> /dev/null || echo -n " $PACKAGE_NAME"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
MISSING_PACKAGES="$MISSING_PACKAGES`checkPackages`"
|
MISSING_PACKAGES="$MISSING_PACKAGES`checkPackages`"
|
||||||
@ -93,23 +92,23 @@ if [ "$MISSING_PACKAGES" != "" ]; then
|
|||||||
|
|
||||||
# apt-get guide.
|
# apt-get guide.
|
||||||
apt-get --help > /dev/null 2> /dev/null && \
|
apt-get --help > /dev/null 2> /dev/null && \
|
||||||
missingDepsExit "sudo apt-get install$MISSING_PACKAGES"
|
missingDepsExit "sudo apt-get install $MISSING_PACKAGES"
|
||||||
|
|
||||||
# yum guide.
|
# yum guide.
|
||||||
yum --help > /dev/null 2> /dev/null && \
|
yum --help > /dev/null 2> /dev/null && \
|
||||||
missingDepsExit "sudo yum install$MISSING_PACKAGES"
|
missingDepsExit "sudo yum install $MISSING_PACKAGES"
|
||||||
|
|
||||||
# zypper guide.
|
# zypper guide.
|
||||||
zypper --help > /dev/null 2> /dev/null && \
|
zypper --help > /dev/null 2> /dev/null && \
|
||||||
missingDepsExit "sudo zypper install$MISSING_PACKAGES"
|
missingDepsExit "sudo zypper install $MISSING_PACKAGES"
|
||||||
|
|
||||||
# pacman guide.
|
# pacman guide.
|
||||||
pacman --help > /dev/null 2> /dev/null && \
|
pacman --help > /dev/null 2> /dev/null && \
|
||||||
missingDepsExit "sudo pacman -S$MISSING_PACKAGES"
|
missingDepsExit "sudo pacman -S $MISSING_PACKAGES"
|
||||||
|
|
||||||
# urpmi guide.
|
# urpmi guide.
|
||||||
urpmi --help > /dev/null 2> /dev/null && \
|
urpmi --help > /dev/null 2> /dev/null && \
|
||||||
missingDepsExit "sudo urpmi$MISSING_PACKAGES"
|
missingDepsExit "sudo urpmi $MISSING_PACKAGES"
|
||||||
|
|
||||||
missingDepsExit ""
|
missingDepsExit ""
|
||||||
fi
|
fi
|
||||||
@ -138,18 +137,22 @@ You can choose between 3 branches:
|
|||||||
|
|
||||||
|
|
||||||
# Input: Branch choice.
|
# Input: Branch choice.
|
||||||
echo -n "Choose the branch (s/t/d): "
|
printf %s "Choose the branch (s/t/d): "
|
||||||
read BRANCH
|
read BRANCH
|
||||||
if [ \( "$BRANCH" = "s" \) -o \( "$BRANCH" = "S" \) ]; then
|
case $BRANCH in
|
||||||
#BRANCH="stable"
|
s|S)
|
||||||
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" \) -o \( $BRANCH = "T" \) ]; then
|
;;
|
||||||
BRANCH="testing"
|
t|T)
|
||||||
elif [ \( $BRANCH = "d" \) -o \( $BRANCH = "D" \) ]; then
|
BRANCH="testing"
|
||||||
BRANCH="master"
|
;;
|
||||||
else
|
d|D)
|
||||||
error "Unrecognized user input."
|
BRANCH="master"
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
error "Unrecognized user input."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
### Inactive code end. ###
|
### Inactive code end. ###
|
||||||
@ -171,16 +174,19 @@ code after this step. It will then compile your program.
|
|||||||
"
|
"
|
||||||
|
|
||||||
# Input: Compile mode choice.
|
# Input: Compile mode choice.
|
||||||
echo -n "Choose compile mode: (n/d): "
|
printf %s "Choose compile mode: (n/d): "
|
||||||
read BUILDTYPE
|
read BUILDTYPE
|
||||||
if [ \( "$BUILDTYPE" = "d" \) -o \( "$BUILDTYPE" = "D" \) ]; then
|
case $BUILDTYPE in
|
||||||
BUILDTYPE="Debug"
|
d|D)
|
||||||
elif [ \( "$BUILDTYPE" = "n" \) -o \( "$BUILDTYPE" = "N" \) ]; then
|
BUILDTYPE="Debug"
|
||||||
BUILDTYPE="Release"
|
;;
|
||||||
else
|
n|N)
|
||||||
error "Unrecognized user input."
|
BUILDTYPE="Release"
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
error "Unrecognized user input."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Echo: Downloading began.
|
# Echo: Downloading began.
|
||||||
echo
|
echo
|
||||||
@ -190,15 +196,15 @@ echo " --- Downloading Cuberite's source code from the $BRANCH branch..."
|
|||||||
if [ ! -d cuberite ]; then
|
if [ ! -d cuberite ]; then
|
||||||
# Git: Clone.
|
# 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 --depth 1 https://github.com/cuberite/cuberite.git -b "$BRANCH"
|
||||||
cd cuberite
|
cd cuberite
|
||||||
else
|
else
|
||||||
# Git: Fetch.
|
# Git: Fetch.
|
||||||
cd cuberite
|
cd cuberite
|
||||||
echo " --- Updating the $BRANCH branch..."
|
echo " --- Updating the $BRANCH branch..."
|
||||||
git fetch origin $BRANCH || error "git fetch failed"
|
git fetch origin "$BRANCH" || error "git fetch failed"
|
||||||
git checkout $BRANCH || error "git checkout failed"
|
git checkout "$BRANCH" || error "git checkout failed"
|
||||||
git merge origin/$BRANCH || error "git merge failed"
|
git merge "origin/$BRANCH" || error "git merge failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Git: Submodules.
|
# Git: Submodules.
|
||||||
@ -210,7 +216,7 @@ git submodule update --init
|
|||||||
echo " --- Running cmake..."
|
echo " --- Running cmake..."
|
||||||
if [ ! -d build-cuberite ]; then mkdir build-cuberite; fi
|
if [ ! -d build-cuberite ]; then mkdir build-cuberite; fi
|
||||||
cd build-cuberite
|
cd build-cuberite
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=$BUILDTYPE || error "cmake failed"
|
cmake .. -DCMAKE_BUILD_TYPE="$BUILDTYPE" || error "cmake failed"
|
||||||
|
|
||||||
|
|
||||||
# Make.
|
# Make.
|
||||||
@ -227,9 +233,9 @@ 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
|
||||||
cd ..
|
cd ..
|
||||||
echo "
|
echo "
|
||||||
@ -240,7 +246,11 @@ Enjoy :)"
|
|||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
:windows_detected
|
:windows_detected
|
||||||
echo "This script is not available for Windows yet, sorry."
|
@echo off
|
||||||
echo "You can still download the Windows binaries from: http://cuberite.org"
|
rem Putting echo "Foo" in Windows CMD gives you "Foo" -- with quotes.
|
||||||
echo "You can also manually compile for Windows. See: https://github.com/cuberite/cuberite"
|
echo This script is not available for Windows yet, sorry.
|
||||||
|
echo You can still download the Windows binaries from: http://cuberite.org
|
||||||
|
echo You can also manually compile for Windows. See: https://github.com/cuberite/cuberite
|
||||||
|
rem windows_exit
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user