diff options
author | Yehonal <hw.2@hotmail.it> | 2016-07-08 23:58:11 +0200 |
---|---|---|
committer | Yehonal <hw.2@hotmail.it> | 2016-07-08 23:58:11 +0200 |
commit | 9fd22872c0e5f52ad47f8cd002111489738b7dda (patch) | |
tree | 4df701d097ff76cc566693979994b5befed3bc8d /bin | |
parent | eda1171939b6d7d951aef2da5b4bbb4e926c1f4a (diff) |
restructured repository based on following standards:
https://github.com/HW-Core/directory-structure
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bash_shared/defines.sh | 5 | ||||
-rw-r--r-- | bin/bash_shared/functions.sh | 16 | ||||
-rw-r--r-- | bin/bash_shared/includes.sh | 7 | ||||
-rwxr-xr-x | bin/compiler/1-clean.sh | 16 | ||||
-rwxr-xr-x | bin/compiler/2-configure.sh | 19 | ||||
-rwxr-xr-x | bin/compiler/3-build.sh | 17 | ||||
-rw-r--r-- | bin/compiler/config.sh.dist | 15 | ||||
-rw-r--r-- | bin/compiler/includes/common.sh | 5 | ||||
-rw-r--r-- | bin/compiler/includes/defines.sh (renamed from bin/compiler/defines.sh) | 15 | ||||
-rw-r--r-- | bin/compiler/includes/functions.sh | 55 | ||||
-rw-r--r-- | bin/compiler/includes/includes.sh | 19 | ||||
-rw-r--r-- | bin/runners/config.dist | 31 | ||||
-rwxr-xr-x | bin/runners/run-engine | 68 | ||||
-rwxr-xr-x | bin/runners/starter | 22 |
14 files changed, 253 insertions, 57 deletions
diff --git a/bin/bash_shared/defines.sh b/bin/bash_shared/defines.sh new file mode 100644 index 0000000000..67cde98ef9 --- /dev/null +++ b/bin/bash_shared/defines.sh @@ -0,0 +1,5 @@ +AZTH_PATH_ROOT=$(readlink -f "$AZTH_PATH_BIN/../") + +AZTH_PATH_CONF="$AZTH_PATH_ROOT/conf" + +AZTH_PATH_CUSTOM=$(readlink -f "$AZTH_PATH_ROOT/../azth_custom") diff --git a/bin/bash_shared/functions.sh b/bin/bash_shared/functions.sh new file mode 100644 index 0000000000..6da557adea --- /dev/null +++ b/bin/bash_shared/functions.sh @@ -0,0 +1,16 @@ +# par 1: hook_name +function runHooks() { + hook_name="HOOKS_MAP_$1" + read -r -a SRCS <<< ${!hook_name} + echo "Running hooks: $hook_name" + for i in "${SRCS[@]}" + do + $i # run registered hook + done +} + +function registerHooks() { + hook_name="HOOKS_MAP_$1" + hooks=${@:2} + declare -g "$hook_name+=$hooks " +} diff --git a/bin/bash_shared/includes.sh b/bin/bash_shared/includes.sh new file mode 100644 index 0000000000..3e53937a2b --- /dev/null +++ b/bin/bash_shared/includes.sh @@ -0,0 +1,7 @@ +AZTH_PATH_BIN="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" + +AZTH_PATH_SHARED="$AZTH_PATH_BIN/bash_shared" + +source "$AZTH_PATH_SHARED/defines.sh" + +source "$AZTH_PATH_SHARED/functions.sh" diff --git a/bin/compiler/1-clean.sh b/bin/compiler/1-clean.sh index 10c61b8527..7fbe9a84b5 100755 --- a/bin/compiler/1-clean.sh +++ b/bin/compiler/1-clean.sh @@ -1,16 +1,8 @@ #!/bin/bash +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. "defines.sh" +source "$CURRENT_PATH/includes/common.sh" -echo "Cleaning build files" - -CWD=$(pwd) - -cd $BUILDPATH - -make -f Makefile clean -make clean -find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ - -cd $CWD +source "$CURRENT_PATH/includes/includes.sh" +clean diff --git a/bin/compiler/2-configure.sh b/bin/compiler/2-configure.sh index c74b52f3e2..6acc934686 100755 --- a/bin/compiler/2-configure.sh +++ b/bin/compiler/2-configure.sh @@ -1,19 +1,8 @@ #!/bin/bash +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. "defines.sh" +source "$CURRENT_PATH/includes/common.sh" -CWD=$(pwd) +source "$CURRENT_PATH/includes/includes.sh" -cd $BUILDPATH - -echo "Build path: $BUILDPATH" -echo "DEBUG info: $CDEBUG" -echo "Compilation type: $CCTYPE" -# -DCMAKE_BUILD_TYPE=$CCTYPE disable optimization "slow and huge amount of ram" -# -DWITH_COREDEBUG=$CDEBUG compiled with debug information - -cmake $SRCPATH -DCMAKE_INSTALL_PREFIX=$BINPATH -DCONF_DIR=$CONFDIR -DSERVERS=$CSERVERS -DSCRIPTS=$CSCRIPTS \ --DCMAKE_C_COMPILER=$COMPILER_C -DCMAKE_CC_COMPILER=$COMPILER_CC -DCMAKE_CXX_COMPILER=$COMPILER_CXX \ --DTOOLS=$CTOOLS -DUSE_SCRIPTPCH=$CSCRIPTPCH -DUSE_COREPCH=$CCOREPCH -DWITH_COREDEBUG=$CDEBUG -DCMAKE_BUILD_TYPE=$CCTYPE -DWITH_WARNINGS=$CWARNINGS - -cd $CWD +configure diff --git a/bin/compiler/3-build.sh b/bin/compiler/3-build.sh index 2aee4d92b5..20b77ecb44 100755 --- a/bin/compiler/3-build.sh +++ b/bin/compiler/3-build.sh @@ -1,17 +1,8 @@ #!/bin/bash +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. "defines.sh" +source "$CURRENT_PATH/includes/common.sh" +source "$CURRENT_PATH/includes/includes.sh" -[ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2)) - -echo "Using $MTHREADS threads" - -CWD=$(pwd) - -cd $BUILDPATH - -time make -j $MTHREADS -make -j $MTHREADS install - -cd $CWD +build diff --git a/bin/compiler/config.sh.dist b/bin/compiler/config.sh.dist index e78c34e855..c7a4661b0e 100644 --- a/bin/compiler/config.sh.dist +++ b/bin/compiler/config.sh.dist @@ -1,8 +1,9 @@ #!/bin/bash -COMPILER_C="/usr/bin/gcc" -COMPILER_CC="/usr/bin/gcc" -COMPILER_CXX="/usr/bin/g++" + +# set preferred compilers +CCOMPILERC="/usr/bin/clang-3.6" +CCOMPILERCXX="/usr/bin/clang++-3.6" # how many thread must be used for compilation ( leave zero to use all available ) MTHREADS=0 @@ -23,12 +24,12 @@ CSCRIPTPCH=1 CCOREPCH=1 # AZTH -# compile azth plugins for custom features +# compile azth custom plugins +CAZTH_CUSTOM_PLG=1 +# compile azth plugins CAZTH_PLG=1 -# compile azth plugins for trinitycore features -CAZTH_TC_PLG=1 # enable unit test on TC load -CAZTH_UNIT_TEST=1 +CAZTH_UNIT_TEST=0 # absolute root path of your azerothshard repository SRCPATH= diff --git a/bin/compiler/includes/common.sh b/bin/compiler/includes/common.sh new file mode 100644 index 0000000000..61a73ca130 --- /dev/null +++ b/bin/compiler/includes/common.sh @@ -0,0 +1,5 @@ +source "./config.sh.dist" # "hack" to avoid missing conf variables + +if [ -f "./config.sh" ]; then + source "./config.sh" # should overwrite previous +fi diff --git a/bin/compiler/defines.sh b/bin/compiler/includes/defines.sh index 7fc6779bd2..e6b37f4eae 100644 --- a/bin/compiler/defines.sh +++ b/bin/compiler/includes/defines.sh @@ -1,21 +1,16 @@ #!/bin/bash -source ./config.sh.dist # "hack" to avoid missing conf variables - -source ./config.sh # should overwrite previous - # you can choose build type from cmd argument -if [ ! -z $1 ] -then +if [ ! -z $1 ] +then CCTYPE=$1 CCTYPE=${CCTYPE^} # capitalize first letter if it's not yet fi BUILDPATH=$BINPATH -[ $CCTYPE == "Debug" ] && BUILDPATH="$BUILDPATH/debug/build/" || BUILDPATH="$BUILDPATH/release/build/" +INSTALL_PATH=$(readlink -f "$BINPATH/../") -[ $CCTYPE == "Debug" ] && BINPATH="$BINPATH/debug" || BINPATH="$BINPATH/release" +[ $CCTYPE == "Debug" ] && BUILDPATH="$BUILDPATH/debug/build/" || BUILDPATH="$BUILDPATH/release/build/" -mkdir -p $BUILDPATH -mkdir -p $BINPATH +[ $CCTYPE == "Debug" ] && BINPATH="$BINPATH/debug" || BINPATH="$BINPATH/release" diff --git a/bin/compiler/includes/functions.sh b/bin/compiler/includes/functions.sh new file mode 100644 index 0000000000..9f97b43b80 --- /dev/null +++ b/bin/compiler/includes/functions.sh @@ -0,0 +1,55 @@ + +function clean() { + echo "Cleaning build files" + + CWD=$(pwd) + + cd $BUILDPATH + + make -f Makefile clean + make clean + find -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+ + + cd $CWD +} + +function configure() { + CWD=$(pwd) + + cd $BUILDPATH + + echo "Build path: $BUILDPATH" + echo "DEBUG info: $CDEBUG" + echo "Compilation type: $CCTYPE" + # -DCMAKE_BUILD_TYPE=$CCTYPE disable optimization "slow and huge amount of ram" + # -DWITH_COREDEBUG=$CDEBUG compiled with debug information + + cmake $SRCPATH -DCMAKE_INSTALL_PREFIX=$BINPATH -DCONF_DIR=$CONFDIR -DSERVERS=$CSERVERS \ + -DSCRIPTS=$CSCRIPTS -DSCRIPTS_COMMANDS=$CSCRIPTS -DSCRIPTS_CUSTOM=$CSCRIPTS -DSCRIPTS_EASTERNKINGDOMS=$CSCRIPTS -DSCRIPTS_EVENTS=$CSCRIPTS -DSCRIPTS_KALIMDOR=$CSCRIPTS \ + -DSCRIPTS_NORTHREND=$CSCRIPTS -DSCRIPTS_OUTDOORPVP=$CSCRIPTS -DSCRIPTS_OUTLAND=$CSCRIPTS -DSCRIPTS_PET=$CSCRIPTS -DSCRIPTS_SPELLS=$CSCRIPTS -DSCRIPTS_WORLD=$CSCRIPTS \ + -DTOOLS=$CTOOLS -DUSE_SCRIPTPCH=$CSCRIPTPCH -DUSE_COREPCH=$CCOREPCH -DWITH_COREDEBUG=$CDEBUG -DCMAKE_BUILD_TYPE=$CCTYPE -DWITH_WARNINGS=$CWARNINGS \ + -DAZTH_WITH_UNIT_TEST=$CAZTH_UNIT_TEST -DAZTH_WITH_CUSTOM_PLUGINS=$CAZTH_CUSTOM_PLG -DAZTH_WITH_PLUGINS=$CAZTH_PLG \ + -DCMAKE_C_COMPILER=$CCOMPILERC -DCMAKE_CXX_COMPILER=$CCOMPILERCXX + + cd $CWD + + runHooks "ON_AFTER_CONFIG" +} + + +function build() { + [ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2)) + + echo "Using $MTHREADS threads" + + CWD=$(pwd) + + cd $BUILDPATH + + time make -j $MTHREADS + make -j $MTHREADS install + + cd $CWD + + runHooks "ON_AFTER_BUILD" +} diff --git a/bin/compiler/includes/includes.sh b/bin/compiler/includes/includes.sh new file mode 100644 index 0000000000..4150841891 --- /dev/null +++ b/bin/compiler/includes/includes.sh @@ -0,0 +1,19 @@ +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_PATH/../../bash_shared/includes.sh" + +AZTH_PATH_COMPILER="$AZTH_PATH_BIN/compiler" + +function azth_on_after_build() { + # move the run engine + cp -rvf "$AZTH_PATH_BIN/runners/"* "$INSTALL_PATH/bin/" +} + +registerHooks "ON_AFTER_BUILD" azth_on_after_build + +source "$AZTH_PATH_COMPILER/includes/defines.sh" + +source "$AZTH_PATH_COMPILER/includes/functions.sh" + +mkdir -p $BUILDPATH +mkdir -p $BINPATH diff --git a/bin/runners/config.dist b/bin/runners/config.dist new file mode 100644 index 0000000000..6b5b275544 --- /dev/null +++ b/bin/runners/config.dist @@ -0,0 +1,31 @@ +#!/bin/bash + +###################### + +# enable/disable GDB execution +export GDB_ENABLED=0 + +# gdb file +export GDB="" + +# directory where binary are stored +exoirt BINPATH="" + + ### Put here the pid you configured on your worldserver.conf file ### +export SERVERPID="" + +# path to conf file +export CONFIG="" + +# path of log files +export LOGS_PATH=""; + +# exec name +export SERVERBIN="" + +# name of screen service ( for restarter ) +export SCREEN_NAME="" + +###################### + + diff --git a/bin/runners/run-engine b/bin/runners/run-engine new file mode 100755 index 0000000000..43aec1a7c5 --- /dev/null +++ b/bin/runners/run-engine @@ -0,0 +1,68 @@ +#!/bin/bash + +function checkStatus() { + if [ -d "/proc/"$1 ]; then + eval "TEST=1" + else + eval "TEST=0" + fi +} + +function starter() { + local CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + cd $BINPATH + + mkdir -p "$LOGS_PATH" + + TRACE_BEGIN_STRING="SIGSEGV" + TRACE_FILE="$LOGS_PATH/"$SCREEN_NAME"_trace.log" + ERR_FILE="$LOGS_PATH/"$SCREEN_NAME"_error.log" + SYSLOG="$LOGS_PATH/"$SCREEN_NAME"_system.log" + SYSERR="$LOGS_PATH/"$SCREEN_NAME"_system.err" + LINKS_FILE="$LOGS_PATH/"$SCREEN_NAME"_crash_links.link" + + $CURRENT_PATH/starter $SERVERBIN $GDB "$CONFIG" "$SYSLOG" "$SYSERR" $GDB_ENABLED +} + + +function restarter() { + local CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + cd $BINPATH + + mkdir -p "$LOGS_PATH" + + TRACE_BEGIN_STRING="SIGSEGV" + TRACE_FILE="$LOGS_PATH/"$SCREEN_NAME"_trace.log" + ERR_FILE="$LOGS_PATH/"$SCREEN_NAME"_error.log" + SYSLOG="$LOGS_PATH/"$SCREEN_NAME"_system.log" + SYSERR="$LOGS_PATH/"$SCREEN_NAME"_system.err" + LINKS_FILE="$LOGS_PATH/"$SCREEN_NAME"_crash_links.link" + + if [ ! -f $TRACE_FILE ]; then + touch $TRACE_FILE + fi + + while : + do + PID=$(cat $SERVERPID) + checkStatus $PID + if [ $TEST -eq 0 ]; then + DATE=$(date) + echo "Restarting $SCREEN_NAME Core blizz($DATE)" + if [ $GDB_ENABLED -eq 1 ]; then + echo "GDB enabled" + grep -B 10 -A 1800 "$TRACE_BEGIN_STRING" "$SYSLOG" >> "$TRACE_FILE" + cat "$SYSERR" > "$ERR_FILE" + screen -A -m -d -S $SCREEN_NAME "$CURRENT_PATH/starter" $SERVERBIN $GDB "$CONFIG" "$SYSLOG" "$SYSERR" 1 + fi + + if [ $GDB_ENABLED -eq 0 ]; then + echo "GDB disabled" + screen -A -m -d -S $SCREEN_NAME "$CURRENT_PATH/starter" $SERVERBIN null "$CONFIG" null null 0 + fi + fi + + sleep 15 + done +} diff --git a/bin/runners/starter b/bin/runners/starter new file mode 100755 index 0000000000..4cd6dd2411 --- /dev/null +++ b/bin/runners/starter @@ -0,0 +1,22 @@ +#!/bin/bash + +GDB_FILE="$2" +CONFIG="$3" +SYSLOG="$4" +SYSERR="$5" +GBD_ENABLED="$6" + +if [ $GBD_ENABLED -eq 1 ]; then + echo "run -c $3" > "$GDB_FILE" + echo "bt" >> "$GDB_FILE" + echo "bt full" >> "$GDB_FILE" + echo "info threads" >> "$GDB_FILE" + echo "thread apply all bt full" >> "$GDB_FILE" + + [ ! -f "$SYSLOG" ] && touch "$SYSLOG" + [ ! -f "$SYSERR" ] && touch "$SYSERR" + + gdb -x $GDB_FILE --batch $1 >> "$SYSLOG" 2>> "$SYSERR" +elif [ $GBD_ENABLED -eq 0 ]; then + "./$1" -c "$CONFIG" +fi
\ No newline at end of file |