diff --git a/bin/bash_shared/includes.sh b/bin/bash_shared/includes.sh index c8a419073..8dd3c9821 100644 --- a/bin/bash_shared/includes.sh +++ b/bin/bash_shared/includes.sh @@ -1,3 +1,5 @@ +[[ ${GUARDYVAR:-} -eq 1 ]] && return || readonly GUARDYVAR=1 # include it once + # force default language for applications LC_ALL=C @@ -17,6 +19,8 @@ source "$AC_PATH_CONF/config.sh.dist" # "hack" to avoid missing conf variables if [ -f "$AC_PATH_CONF/config.sh" ]; then source "$AC_PATH_CONF/config.sh" # should overwrite previous +else + echo "NOTICE: file <$AC_PATH_CONF/config.sh> has not been found, you should create and configure it." fi # diff --git a/bin/compiler/README.md b/bin/compiler/README.md index c50dae2ec..a4759ee23 100644 --- a/bin/compiler/README.md +++ b/bin/compiler/README.md @@ -19,6 +19,14 @@ first of all, if you need some custom configuration you have to copy and rename ./3-build.sh +## compiler.sh + +compiler.sh script contains an interactive menu to clean/compile/build. You can also run actions directly by command lines specifying the option. +Ex: + ./compiler.sh 3 + +It will start the build process (it's equivalent to ./3-build.sh) + ## Note: For an optimal development process and **really faster** compilation time, is suggested to use clang instead of gcc diff --git a/bin/compiler/compiler.sh b/bin/compiler/compiler.sh index f813be803..cb89bfb70 100755 --- a/bin/compiler/compiler.sh +++ b/bin/compiler/compiler.sh @@ -5,9 +5,9 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "$CURRENT_PATH/includes/includes.sh" function all() { - clean - configure - build + comp_clean + comp_configure + comp_build } function run_option() { @@ -19,7 +19,7 @@ function run_option() { } comp_options=("Clean" "Configure" "Build" "All") -comp_functions=("clean" "configure" "build" "all") +comp_functions=("comp_clean" "comp_configure" "comp_build" "all") runHooks "ON_AFTER_OPTIONS" #you can create your custom options diff --git a/bin/compiler/includes/functions.sh b/bin/compiler/includes/functions.sh index 5113391df..4dfaa4603 100644 --- a/bin/compiler/includes/functions.sh +++ b/bin/compiler/includes/functions.sh @@ -1,5 +1,5 @@ -function clean() { +function comp_clean() { echo "Cleaning build files" CWD=$(pwd) @@ -13,7 +13,7 @@ function clean() { cd $CWD } -function configure() { +function comp_configure() { CWD=$(pwd) cd $BUILDPATH @@ -39,7 +39,7 @@ function configure() { } -function build() { +function comp_build() { [ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2)) echo "Using $MTHREADS threads" diff --git a/bin/db_assembler/includes/functions.sh b/bin/db_assembler/includes/functions.sh index 8b4119d01..da0415948 100644 --- a/bin/db_assembler/includes/functions.sh +++ b/bin/db_assembler/includes/functions.sh @@ -220,7 +220,7 @@ function dbasm_db_import() { } function dbasm_import() { - dbasm_run $1 $2 $2 + dbasm_run $1 $2 $3 with_base=$1 with_updates=$2 diff --git a/bin/installer/includes/functions.sh b/bin/installer/includes/functions.sh new file mode 100644 index 000000000..2b8e9e976 --- /dev/null +++ b/bin/installer/includes/functions.sh @@ -0,0 +1,105 @@ +function inst_configureOS() { + echo "Platform: $OSTYPE" + case "$OSTYPE" in + solaris*) echo "Solaris is not supported yet" ;; + darwin*) source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;; + linux*) + # TODO: implement different configurations by distro + source "$AC_PATH_INSTALLER/includes/os_configs/linux.sh" ;; + ;; + bsd*) echo "BSD is not supported yet" ;; + msys*) source "$AC_PATH_INSTALLER/includes/os_configs/windows.sh" ;; + *) echo "This platform is not supported" ;; + esac +} + +function inst_updateRepo() { + git pull origin $(git rev-parse --abbrev-ref HEAD) +} + +function inst_resetRepo() { + git reset --hard $(git rev-parse --abbrev-ref HEAD) + git clean -f +} + +function inst_compile() { + comp_configure + comp_build +} + +function inst_cleanCompile() { + comp_clean + inst_compile +} + +function inst_assembleDb { + dbasm_import true true true +} + +function inst_allInOne() { + inst_configureOS + inst_updateRepo + inst_compile + inst_assembleDb +} + +function inst_module_search { + search="" + if [ -z "$1" ]; then + echo "Type what to search or leave blank for full list" + read -p "Insert name: " res + + search="+$res" + fi + echo "Searching ..." + echo ""; + + for i in `curl -s "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" | grep \"name\" | cut -d ':' -f 2-3|tr -d '",'`; do + echo "-> $i"; + done + + echo ""; + echo ""; +} + +function inst_module_install { + if [ -z "$1" ]; then + echo "Type the name of the module to install" + read -p "Insert name: " res + fi + + git clone "https://github.com/azerothcore/$res" "modules/$res" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information" + + echo ""; + echo ""; +} + +function inst_module_update { + if [ -z "$1" ]; then + echo "Type the name of the module to update" + read -p "Insert name: " res + fi + + cd "modules/$res" + + #git reset --hard master + #git clean -f + git pull origin master && echo "Done" + + cd "../../" + + echo ""; + echo ""; +} + +function inst_module_remove { + if [ -z "$1" ]; then + echo "Type the name of the module to remove" + read -p "Insert name: " res + fi + + rm -rf "modules/$res" && echo "Done" + + echo ""; + echo ""; +} \ No newline at end of file diff --git a/bin/installer/includes/includes.sh b/bin/installer/includes/includes.sh new file mode 100644 index 000000000..fdede154f --- /dev/null +++ b/bin/installer/includes/includes.sh @@ -0,0 +1,14 @@ +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_PATH/../../bash_shared/includes.sh" + +AC_PATH_INSTALLER="$AC_PATH_BIN/installer" + +if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then + source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous +fi + +source "$AC_PATH_BIN/compiler/includes/includes.sh" +source "$AC_PATH_BIN/db_assembler/includes/includes.sh" + +source "$AC_PATH_INSTALLER/includes/functions.sh" diff --git a/bin/installer/includes/os_configs/linux.sh b/bin/installer/includes/os_configs/linux.sh new file mode 100644 index 000000000..020e19477 --- /dev/null +++ b/bin/installer/includes/os_configs/linux.sh @@ -0,0 +1,4 @@ + + +sudo apt-get install git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server +sudo apt-get install libace-6.* libace-dev \ No newline at end of file diff --git a/bin/installer/includes/os_configs/osx.sh b/bin/installer/includes/os_configs/osx.sh new file mode 100644 index 000000000..5ea43f641 --- /dev/null +++ b/bin/installer/includes/os_configs/osx.sh @@ -0,0 +1,6 @@ +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +brew update + +brew install openssl readline cmake ace coreutils bash bash-completion md5sha1sum + diff --git a/bin/installer/includes/os_configs/windows.sh b/bin/installer/includes/os_configs/windows.sh new file mode 100644 index 000000000..9a5e13f6d --- /dev/null +++ b/bin/installer/includes/os_configs/windows.sh @@ -0,0 +1,17 @@ +echo "WARNING: Installer Script for Windows is not fully supported yet. Work in progress.." +echo "!!README!!: Please install openssl and mysql libraries manually following our wiki" + +# install chocolatey before + +@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" + +# install automatically following packages: +# cmake +# git +# microsoft-build-tools +# mysql 5.6 + +choco install -y --skip-checksums cmake git git.install microsoft-build-tools +choco install -y --skip-checksums mysql --version 5.6.12 + +echo "!!README!!: Please remember to install openssl and mysql libraries manually following our wiki" diff --git a/bin/installer/main.sh b/bin/installer/main.sh new file mode 100644 index 000000000..a71bca199 --- /dev/null +++ b/bin/installer/main.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_PATH/includes/includes.sh" + +cmdopt=$1 + +while true +do +echo "===== INSTALLER SCRIPT =====" +PS3='Please enter your choice: ' +options=( + "First Installation" "Configure OS dep" "Update Repository" "Reset & Clean Repository" + "Compile" "Clean & Compile" "Assemble & Import DB" "Module Search" "Module Install" "Module Update" "Module Remove" + "Sub Menu >> Compiler" "Sub Menu >> DB Assembler" + "Quit" + ) + +function _switch() { + case $1 in + "First Installation") + inst_allInOne + ;; + "Configure OS dep") + inst_configureOS + ;; + "Update Repository") + inst_updateRepo + ;; + "Reset & Clean Repository") + inst_resetRepo + ;; + "Compile") + inst_compile + ;; + "Clean & Compile") + inst_cleanCompile + ;; + "Assemble & Import DB") + inst_assembleDb + ;; + "Module Search") + inst_module_search $2 + ;; + "Module Install") + inst_module_install $2 + ;; + "Module Update") + inst_module_update $2 + ;; + "Module Remove") + inst_module_remove $2 + ;; + "Sub Menu >> Compiler") + bash "$AC_PATH_BIN/compiler/compiler.sh" + ;; + "Sub Menu >> DB Assembler") + bash "$AC_PATH_BIN/db_assembler/db_assembler.sh" + ;; + "Quit") + echo "Goodbye!" + exit + ;; + *) echo invalid option;; + esac +} + +# run option directly if specified in argument +[ ! -z $1 ] && _switch "${options[$cmdopt-1]}" && exit 0 + +select opt in "${options[@]}" +do + _switch "$opt" + break +done +done diff --git a/conf/config.sh.dist b/conf/config.sh.dist index ffcc26deb..497d3fc95 100644 --- a/conf/config.sh.dist +++ b/conf/config.sh.dist @@ -1,9 +1,14 @@ # absolute root path of your azerothshard repository SRCPATH="$AC_PATH_ROOT" + +# absolute path where build files must be stored +BUILDPATH="$AC_PATH_ROOT/build/" + # absolute path where binary files must be stored -BINPATH="$AC_PATH_ROOT/build/" +BINPATH="$AC_PATH_ROOT/build/bin/" + # absolute path where config. files must be stored -CONFDIR="$AC_PATH_ROOT/build/etc/" +CONFDIR="$AC_PATH_ROOT/build/bin/etc/" ############################################## # @@ -12,16 +17,19 @@ CONFDIR="$AC_PATH_ROOT/build/etc/" ############################################## -# set preferred compilers +# Set preferred compilers. +# To use gcc (not suggested) instead of clang change in: +# CCOMPILERC="/usr/bin/gcc" +# CCOMPILERCXX="/usr/bin/g++" +# CCOMPILERC="/usr/bin/clang" CCOMPILERCXX="/usr/bin/clang++" -#CCOMPILERC="/usr/bin/gcc" -#CCOMPILERCXX="/usr/bin/g++" + # how many thread must be used for compilation ( leave zero to use all available ) MTHREADS=0 # enable/disable warnings during compilation -CWARNINGS=OFF +CWARNINGS=ON # enable/disable some debug informations ( it's not a debug compilation ) CDEBUG=OFF # specify compilation type @@ -31,13 +39,18 @@ CSCRIPTS=ON # compile server CSERVERS=ON # compile tools -CTOOLS=OFF +CTOOLS=ON # use precompiled headers ( fatest compilation but not optimized if you change headers often ) CSCRIPTPCH=ON CCOREPCH=ON + +# Skip specific modules from compilation (cmake reconfigure needed) # use semicolon ; to separate modules CDISABLED_AC_MODULES="" + # you can add your custom definitions here ( -D ) +# example: CCUSTOMOPTIONS=" -DWITH_PERFTOOLS=ON -DENABLE_EXTRA_LOGS=ON" +# CCUSTOMOPTIONS="" @@ -47,6 +60,11 @@ CCUSTOMOPTIONS="" # ############################################## +# +# Basically you don't have to edit it +# but if you have another database you can add it here +# and create relative confiugurations below +# DATABASES=( "AUTH" "CHARACTERS" diff --git a/install.sh b/install.sh index c467afe77..8be9c9970 100755 --- a/install.sh +++ b/install.sh @@ -6,6 +6,10 @@ PATH_MODULES="$CUR_PATH/modules/" source "$PATH_MODULES/drassil/joiner/joiner.sh" +# installing repository dependencies if [[ $1 == "dev" ]]; then git submodule update --init "$CUR_PATH/data/doc" fi + + +source "$CUR_PATH/bin/installer/main.sh"