diff options
Diffstat (limited to 'apps/compiler')
-rw-r--r-- | apps/compiler/.gitignore | 2 | ||||
-rw-r--r-- | apps/compiler/1-clean.sh | 5 | ||||
-rw-r--r-- | apps/compiler/2-configure.sh | 5 | ||||
-rw-r--r-- | apps/compiler/3-build.sh | 5 | ||||
-rw-r--r-- | apps/compiler/README.md | 32 | ||||
-rw-r--r-- | apps/compiler/compiler.sh | 44 | ||||
-rw-r--r-- | apps/compiler/includes/defines.sh | 7 | ||||
-rw-r--r-- | apps/compiler/includes/functions.sh | 57 | ||||
-rw-r--r-- | apps/compiler/includes/includes.sh | 23 |
9 files changed, 180 insertions, 0 deletions
diff --git a/apps/compiler/.gitignore b/apps/compiler/.gitignore new file mode 100644 index 0000000000..ba57f2bccf --- /dev/null +++ b/apps/compiler/.gitignore @@ -0,0 +1,2 @@ +config.sh + diff --git a/apps/compiler/1-clean.sh b/apps/compiler/1-clean.sh new file mode 100644 index 0000000000..558c093e3f --- /dev/null +++ b/apps/compiler/1-clean.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +bash "$CURRENT_PATH/compiler.sh" 1 diff --git a/apps/compiler/2-configure.sh b/apps/compiler/2-configure.sh new file mode 100644 index 0000000000..0d59b1caac --- /dev/null +++ b/apps/compiler/2-configure.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +bash "$CURRENT_PATH/compiler.sh" 2 diff --git a/apps/compiler/3-build.sh b/apps/compiler/3-build.sh new file mode 100644 index 0000000000..6956f82fd3 --- /dev/null +++ b/apps/compiler/3-build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +bash "$CURRENT_PATH/compiler.sh" 3 diff --git a/apps/compiler/README.md b/apps/compiler/README.md new file mode 100644 index 0000000000..a4759ee232 --- /dev/null +++ b/apps/compiler/README.md @@ -0,0 +1,32 @@ +## How to compile: + +first of all, if you need some custom configuration you have to copy and rename +/conf/config.sh.dist in /conf/config.sh and configure it + +* for a "clean" compilation you must run all scripts in their order: + + ./1-clean.sh + ./2-configure.sh + ./3-build.sh + +* if you add/rename/delete some sources and you need to compile it you have to run: + + ./2-configure.sh + ./3-build.sh + +* if you have modified code only, you just need to run + + ./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/apps/compiler/compiler.sh b/apps/compiler/compiler.sh new file mode 100644 index 0000000000..cb89bfb705 --- /dev/null +++ b/apps/compiler/compiler.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_PATH/includes/includes.sh" + +function all() { + comp_clean + comp_configure + comp_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=("comp_clean" "comp_configure" "comp_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 diff --git a/apps/compiler/includes/defines.sh b/apps/compiler/includes/defines.sh new file mode 100644 index 0000000000..57c809c470 --- /dev/null +++ b/apps/compiler/includes/defines.sh @@ -0,0 +1,7 @@ +# you can choose build type from cmd argument +if [ ! -z $1 ] +then + CCTYPE=$1 + CCTYPE=${CCTYPE^} # capitalize first letter if it's not yet +fi + diff --git a/apps/compiler/includes/functions.sh b/apps/compiler/includes/functions.sh new file mode 100644 index 0000000000..4dfaa46038 --- /dev/null +++ b/apps/compiler/includes/functions.sh @@ -0,0 +1,57 @@ + +function comp_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 comp_configure() { + CWD=$(pwd) + + cd $BUILDPATH + + echo "Build path: $BUILDPATH" + echo "DEBUG info: $CDEBUG" + echo "Compilation type: $CTYPE" + # -DCMAKE_BUILD_TYPE=$CCTYPE disable optimization "slow and huge amount of ram" + # -DWITH_COREDEBUG=$CDEBUG compiled with debug information + + #-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 \ + #-DAC_WITH_UNIT_TEST=$CAC_UNIT_TEST -DAC_WITH_PLUGINS=$CAC_PLG \ + + cmake $SRCPATH -DCMAKE_INSTALL_PREFIX=$BINPATH -DCONF_DIR=$CONFDIR -DSERVERS=$CSERVERS \ + -DSCRIPTS=$CSCRIPTS \ + -DTOOLS=$CTOOLS -DUSE_SCRIPTPCH=$CSCRIPTPCH -DUSE_COREPCH=$CCOREPCH -DWITH_COREDEBUG=$CDEBUG -DCMAKE_BUILD_TYPE=$CTYPE -DWITH_WARNINGS=$CWARNINGS \ + -DCMAKE_C_COMPILER=$CCOMPILERC -DCMAKE_CXX_COMPILER=$CCOMPILERCXX "-DDISABLED_AC_MODULES=$CDISABLED_AC_MODULES" $CCUSTOMOPTIONS + + cd $CWD + + runHooks "ON_AFTER_CONFIG" +} + + +function comp_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/apps/compiler/includes/includes.sh b/apps/compiler/includes/includes.sh new file mode 100644 index 0000000000..ffde93a73e --- /dev/null +++ b/apps/compiler/includes/includes.sh @@ -0,0 +1,23 @@ +CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_PATH/../../bash_shared/includes.sh" + +AC_PATH_COMPILER="$AC_PATH_BIN/compiler" + +if [ -f "$AC_PATH_COMPILER/config.sh" ]; then + source "$AC_PATH_COMPILER/config.sh" # should overwrite previous +fi + +function ac_on_after_build() { + # move the run engine + cp -rvf "$AC_PATH_MODULES/acore/startup-scripts/"* "$BINPATH" +} + +registerHooks "ON_AFTER_BUILD" ac_on_after_build + +source "$AC_PATH_COMPILER/includes/defines.sh" + +source "$AC_PATH_COMPILER/includes/functions.sh" + +mkdir -p $BUILDPATH +mkdir -p $BINPATH |