starting bash rewriting job [WIP]

This commit is contained in:
Yehonal
2016-07-28 13:33:10 +02:00
committed by Yehonal
parent 548d0db9d5
commit 42ad4da954
14 changed files with 213 additions and 156 deletions

View File

@@ -5,3 +5,9 @@ AZTH_PATH_SHARED="$AZTH_PATH_BIN/bash_shared"
source "$AZTH_PATH_SHARED/defines.sh"
source "$AZTH_PATH_SHARED/functions.sh"
source "$AZTH_PATH_CONF/config.sh.dist" # "hack" to avoid missing conf variables
if [ -f "$AZTH_PATH_CONF/config.sh" ]; then
source "$AZTH_PATH_CONF/config.sh" # should overwrite previous
fi

View File

@@ -1,8 +1,5 @@
#!/bin/bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/common.sh"
source "$CURRENT_PATH/includes/includes.sh"
clean
bash "$CURRENT_PATH/compiler.sh" 1

View File

@@ -1,8 +1,5 @@
#!/bin/bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/common.sh"
source "$CURRENT_PATH/includes/includes.sh"
configure
bash "$CURRENT_PATH/compiler.sh" 2

View File

@@ -1,8 +1,5 @@
#!/bin/bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/common.sh"
source "$CURRENT_PATH/includes/includes.sh"
build
bash "$CURRENT_PATH/compiler.sh" 3

View File

@@ -1,7 +1,7 @@
## How to compile:
first of all, if you need some custom configuration you have to copy and rename
config.sh.dist in config.sh and configure it
/conf/config.sh.dist in /conf/config.sh and configure it
* for a "clean" compilation you must run all scripts in their order:
@@ -21,4 +21,4 @@ config.sh.dist in config.sh and configure it
## Note:
For an optimal development process and **really faster** compilation time, is suggested to use clang instead of gcc
For an optimal development process and **really faster** compilation time, is suggested to use clang instead of gcc

43
bin/compiler/compiler.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
function all() {
clean
configure
build
}
function run_option() {
if test "${comp_functions[$1-1]+'test'}"; then
${comp_functions[$1-1]}
else
echo "invalid option"
fi
}
comp_options=("Clean" "Configure" "Build" "All")
comp_functions=("clean" "configure" "build" "all")
runHooks "ON_AFTER_OPTIONS" #you can create your custom options
# push exit after custom options
comp_options+=('Exit')
comp_functions+=('exit 0')
# run option directly if specified in argument
[ ! -z $1 ] && run_option $1 && exit 0
PS3='[ Please enter your choice ]: '
select opt in "${comp_options[@]}"
do
case $opt in
'Exit')
break
;;
*)
run_option $REPLY
;;
esac
done

View File

@@ -1,38 +0,0 @@
#!/bin/bash
# set preferred compilers
#CCOMPILERC="/usr/bin/clang-3.6"
#CCOMPILERCC="/usr/bin/clang-3.6"
#CCOMPILERCXX="/usr/bin/clang++-3.6"
CCOMPILERC="/usr/bin/gcc"
CCOMPILERCC="/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=1
# enable/disable some debug informations ( it's not a debug compilation )
CDEBUG=0
# specify compilation type
CCTYPE=Release
# compile scripts
CSCRIPTS=1
# compile server
CSERVERS=1
# compile tools
CTOOLS=0
# use precompiled headers ( fatest compilation but not optimized if you change headers often )
CSCRIPTPCH=1
CCOREPCH=1
# absolute root path of your azerothshard repository
SRCPATH=
# absolute path where binary files must be stored
BINPATH=
# absolute path where config. files must be stored
CONFDIR=

View File

@@ -1,5 +0,0 @@
source "./config.sh.dist" # "hack" to avoid missing conf variables
if [ -f "./config.sh" ]; then
source "./config.sh" # should overwrite previous
fi

View File

@@ -1,2 +1,2 @@
/output/
config.sh

View File

@@ -1,49 +0,0 @@
#!/bin/bash
# 0 if you want create an sql for each kind of following categories
# 1 to create a single big file to import ( suggested for new installations )
ALL_IN_ONE=0
DATABASES=(
"AUTH"
"CHARACTERS"
"WORLD"
)
OUTPUT_FOLDER="output/"
# FULL DB
DB_CHARACTERS_PATHS=(
$SRCPATH"/data/sql/databases/characters.sql"
)
DB_AUTH_PATHS=(
$SRCPATH"/data/sql/databases/auth.sql"
)
DB_WORLD_PATHS=(
$SRCPATH"/data/sql/databases/world.sql"
)
# UPDATES
DB_CHARACTERS_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/characters/"
)
DB_AUTH_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/auth/"
)
DB_WORLD_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/world/"
)
# CUSTOM
DB_CHARACTERS_CUSTOM_PATHS=(
)
DB_AUTH_CUSTOM_PATHS=(
)
DB_WORLD_CUSTOM_PATHS=(
)

View File

@@ -26,8 +26,8 @@ function assemble() {
database=$1
start_sql=$2
var_full="DB_"$database"_PATHS"
full=${!var_full}
var_base="DB_"$database"_PATHS"
base=${!var_full}
var_updates="DB_"$database"_UPDATE_PATHS"
updates=${!var_updates}
@@ -47,16 +47,27 @@ function assemble() {
echo "" > $OUTPUT_FOLDER$database$suffix_base".sql"
if [ ! ${#full[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_based ..."
if [ ! ${#base[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_base ..."
for entry in "${full[@]}"
for d in "${base[@]}"
do
if [ ! -z $entry ]; then
if [ -e $entry ]; then
cat "$entry" >> $OUTPUT_FOLDER$database$suffix_base".sql"
fi
fi
for entry in "$d"/*.sql "$d"/**/*.sql
do
if [ ! -z $d ]; then
file=$(basename $entry)
if [[ "$file" > "$start_sql" ]]
then
if [ -e $entry ]; then
if [[ "$gtversion" < "$file" ]]; then
gtversion=$file
fi
cat "$entry" >> $OUTPUT_FOLDER$database$suffix_base".sql"
fi
fi
fi
done
done
fi

View File

@@ -1,31 +0,0 @@
#!/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=""
######################

View File

@@ -7,11 +7,10 @@ SYSERR="$5"
GBD_ENABLED="$6"
if [ $GBD_ENABLED -eq 1 ]; then
echo "run -c $3" > "$GDB_FILE"
echo "set logging on" > "$GDB_FILE"
echo "set debug timestamp" >> "$GDB_FILE"
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"
@@ -19,4 +18,4 @@ if [ $GBD_ENABLED -eq 1 ]; then
gdb -x $GDB_FILE --batch $1 >> "$SYSLOG" 2>> "$SYSERR"
elif [ $GBD_ENABLED -eq 0 ]; then
"./$1" -c "$CONFIG"
fi
fi

130
conf/config.sh.dist Normal file
View File

@@ -0,0 +1,130 @@
#!/bin/bash
#!/bin/bash
# absolute root path of your azerothshard repository
SRCPATH="$AZTH_PATH_ROOT"
# absolute path where binary files must be stored
BINPATH="$AZTH_PATH_ROOT/build/"
# absolute path where config. files must be stored
CONFDIR="$AZTH_PATH_ROOT/build/etc/"
##############################################
#
# COMPILER_CONFIGURATIONS
#
##############################################
# set preferred compilers
#CCOMPILERC="/usr/bin/clang-3.6"
#CCOMPILERCC="/usr/bin/clang-3.6"
#CCOMPILERCXX="/usr/bin/clang++-3.6"
CCOMPILERC="/usr/bin/gcc"
CCOMPILERCC="/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=1
# enable/disable some debug informations ( it's not a debug compilation )
CDEBUG=0
# specify compilation type
CCTYPE=Release
# compile scripts
CSCRIPTS=1
# compile server
CSERVERS=1
# compile tools
CTOOLS=0
# use precompiled headers ( fatest compilation but not optimized if you change headers often )
CSCRIPTPCH=1
CCOREPCH=1
##############################################
#
# RUNNER CONFIGURATION
#
##############################################
# 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=""
##############################################
#
# DB ASSEMBLER CONFIGURATIONS
#
##############################################
# 0 if you want create an sql for each kind of following categories
# 1 to create a single big file to import ( suggested for new installations )
ALL_IN_ONE=0
DATABASES=(
"AUTH"
"CHARACTERS"
"WORLD"
)
OUTPUT_FOLDER="output/"
# FULL DB
DB_CHARACTERS_PATHS=(
$SRCPATH"/data/sql/databases/"
)
DB_AUTH_PATHS=(
$SRCPATH"/data/sql/databases/"
)
DB_WORLD_PATHS=(
$SRCPATH"/data/sql/databases/"
)
# UPDATES
DB_CHARACTERS_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/characters/"
)
DB_AUTH_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/auth/"
)
DB_WORLD_UPDATE_PATHS=(
$SRCPATH"/data/sql/updates/world/"
)
# CUSTOM
DB_CHARACTERS_CUSTOM_PATHS=(
)
DB_AUTH_CUSTOM_PATHS=(
)
DB_WORLD_CUSTOM_PATHS=(
)