Skip to content

Commit

Permalink
Update bootstrap.sh
Browse files Browse the repository at this point in the history
- Fix some small mistakes
- Lower min gcc version to 10
- Some armv7 support by using system libraries
- Find premake when .local/bin is not in PATH
  • Loading branch information
forgee committed Dec 30, 2024
1 parent 12161f9 commit 1dad540
Showing 1 changed file with 34 additions and 46 deletions.
80 changes: 34 additions & 46 deletions bootstrap.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ GREEN="\033[0;32m"
ORANGE="\033[31;33m"
END="\033[0;0m"

premake_cmd="premake5"
premake_cmd="${HOME}/.local/bin/premake5"
premake_args=""

# Prerequisite packages
debian_install="apt -y install git zip build-essential uuid-dev"
debian_install="apt-get -y install git zip unzip tar curl build-essential uuid-dev"
arch_install="pacman -Syu git zip"
fedora_install="dnf install git make gcc-c++ libuuid-devel perl-IPC-Cmd"
suse_install="zypper install git-core make gcc-c++ libuuid-devel"
fedora_install="dnf -y install git make gcc-c++ libuuid-devel perl-IPC-Cmd"
suse_install="zypper -y install git-core make gcc-c++ libuuid-devel"

# https://stackoverflow.com/questions/45125516/possible-values-for-uname-m
arch=$(uname -m)

build_arch="64"
make_debug="make -j \`nproc\` config=debug_${build_arch}"
make_release="make -j \`nproc\` config=release_${build_arch}"

case "$arch" in
aarch64 | armv8* | armv9* | arm64)
Expand All @@ -32,9 +34,13 @@ case "$arch" in
;;
arm | armv7*)
build_arch="arm"
premake_args="${premake_args} --use-system-libs --use-lua=lua5.4"
debian_install="${debian_install} liblua5.4-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev"
export VCPKG_FORCE_SYSTEM_BINARIES=1
premake_args="${premake_args} --lua=lua5.4"
# Only works on Debian 12 and Ubuntu 24.04, older versions have to git clone tomlplusplus
debian_install="${debian_install} liblua5.4-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev libcurl4-openssl-dev libtomlplusplus-dev"
skip_vcpkg=true
echo -e "${ORANGE}Arm support is experimental and will likely require some manual setup.${END}"
read -p "Press [Enter] to continue or [Ctrl + C] to cancel." _
;;
armv6* | i386 | i686)
echo -e "${RED}=== 32 bit systems are not supported ===${END}"
Expand All @@ -54,35 +60,28 @@ check_deps () {
if ! command -v "git" &> /dev/null \
|| ! command -v "make" &> /dev/null \
|| ! command -v "zip" &> /dev/null \
|| ! command -v "curl" &> /dev/null \
|| ( command -v "pkg-config" &> /dev/null && ! pkg-config --exists uuid &> /dev/null ); then
echo "Missing build dependency. Make sure the prerequisite software is installed."
echo
echo "Debian/Ubuntu: ${debian_install}"
echo "Arch: ${arch_install}"
echo "Fedora: ${fedora_install}"
echo "OpenSUSE: ${suse_install}"

return 1
fi

if [ "$build_arch" = "ARM64" ] && ( ! command -v "cmake" &> /dev/null || ! command -v "ninja" &> /dev/null ); then
echo "Missing build dependency. Make sure the prerequisite software is installed."
echo
echo "Debian/Ubuntu: ${debian_install}"
echo "Arch: ${arch_install}"
echo "Fedora: ${fedora_install}"
echo "OpenSUSE: ${suse_install}"

if [ "$build_arch" == "ARM64" ] && ( ! command -v "cmake" &> /dev/null || ! command -v "ninja" &> /dev/null ); then
return 1
fi

return 0
}

gcc_version=`gcc --version | awk 'NR==1 {print $3}' | cut -f 1 -d "."`

if (( gcc_version < 10 )); then
echo -e "${RED}=== GCC version 10 or above is required. ===${END}"
exit 1
fi

if ! check_deps; then
echo "Some required software could not be found."
echo "Attempt automatic install? (y/n): " do_install
read -p "Attempt automatic install? (y/n): " do_install
if [ ! $do_install ] || [ $do_install == "n" ]; then
echo "Please install the prerequisite software using your package manager."
echo
Expand All @@ -95,7 +94,7 @@ if ! check_deps; then

if command -v "apt" &> /dev/null; then
echo -e ${GREEN}Installing required software${END}
sudo apt -y update
sudo apt-get -y -q update
if ! sudo $debian_install; then
echo "Missing dependencies were not installed."
echo -e "${RED}=== Configuration is not finished ===${END}"
Expand Down Expand Up @@ -136,13 +135,6 @@ if ! check_deps; then
fi
fi

gcc_version=`gcc --version | awk 'NR==1 {print $3}' | cut -f 1 -d "."`

if (( gcc_version < 11 )); then
echo -e "${RED}=== GCC version 11 or above is required. ===${END}"
exit 1
fi

dir=`pwd`

if [ ! -d ~/.local/bin ]; then
Expand All @@ -157,25 +149,22 @@ if ! command -v "${premake_cmd}" &> /dev/null; then
cd ../premake-core
else
cd ../premake-core
if [[ "$(git pull --ff-only)" = "Already up to date." ]]; then
if [ "$(git pull --ff-only)" == "Already up to date." ]; then
already_uptodate=true
fi
fi
if [[ ! $already_uptodate ]] || [ ! -f ../premake-core/bin/release/premake5 ]; then

if [ ! $already_uptodate ] || [ ! -f bin/release/premake5 ]; then
if make -f Bootstrap.mak linux; then
cp -f ./bin/release/premake5 ~/.local/bin/premake5
cp -f bin/release/premake5 ~/.local/bin/premake5
else
echo -e "${RED}=== An error occured while compiling premake. Configuration is not complete. ===${END}"
exit 1
fi
else
echo "Found existing premake"
fi
premake_cmd="${HOME}/premake-core/bin/release/premake5"

fi

if [ ! skip_vcpkg ]; then
if [ ! $skip_vcpkg ]; then
# Check for vcpkg in env
if ! printenv VCPKG_ROOT &> /dev/null; then
if [ -d $HOME/vcpkg ]; then
Expand All @@ -185,7 +174,6 @@ if [ ! skip_vcpkg ]; then
fi
fi


if [ ! -d $VCPKG_ROOT ] || [ ! -f $VCPKG_ROOT/vcpkg ]; then
echo -e "${GREEN}Installing vcpkg${END}"
if [ ! -d $VCPKG_ROOT ]; then
Expand All @@ -196,7 +184,7 @@ if [ ! skip_vcpkg ]; then
echo -e "${RED}=== An error occured while installing vcpkg. Configuration is not complete. ===${END}"
exit 1
fi
cp ./vcpkg ~/.local/bin/vcpkg
cp -f ./vcpkg ~/.local/bin/vcpkg
fi
fi

Expand All @@ -208,7 +196,7 @@ if ! ${premake_cmd} gmake2 ${premake_args}; then
exit 1
fi

if [ ! skip_vcpkg ]; then
if [ ! $skip_vcpkg ]; then
if ! $VCPKG_ROOT/vcpkg install; then
echo -e "${RED}=== An error occured while executing vcpkg. Configuration is not complete. ===${END}"
exit 1
Expand All @@ -217,10 +205,6 @@ fi

echo -e "${GREEN}=== Configuration Finished ===${END}"
echo

make_debug="make -j \$(nproc) config=debug_${build_arch}"
make_release="make -j \$(nproc) config=release_${build_arch}"

read -p "Would you like to compile the server now? (n: No, d: Debug, r: Release) " compile

if [ ! $compile ] || [ $compile == "n" ]; then
Expand All @@ -240,10 +224,12 @@ elif [ $compile == "d" ]; then
echo "Debug: ${make_debug}"
echo "Release: ${make_release}"
echo "Alternatively re-run bootstrap.sh"
exit 0
else
echo
echo -e "${RED}=== Compilation Failed ===${END}"
fi
exit 1
fi
elif [ $compile == "r" ]; then
if make -j `nproc` "config=release_${build_arch}"; then
echo
Expand All @@ -256,8 +242,10 @@ elif [ $compile == "r" ]; then
echo "Debug: ${make_debug}"
echo "Release: ${make_release}"
echo "Alternatively re-run bootstrap.sh"
exit 0
else
echo
echo -e "${RED}=== Compilation Failed ===${END}"
exit 1
fi
fi

0 comments on commit 1dad540

Please sign in to comment.