Posted at: 2018-10-18, 09:44
Just want to share my alternative compile script which has some advantages over the shipped compile script (compile.sh):
- It uses per default more processor cores: Available cores -1, so one core is preserved for doing other things during compiling. Compiling with ninja uses all cores, which make my system unusable for some time.
- The compile output get doubled: As usual the output during compiling is shown in the console, but additionally stored in a file. This can be helpful because the consoles cache is limited and one couldn't scroll to first output messages
The script assumes that you have the proposed directory structure:
~/widelands-repo
~/widelands-repo/trunk
~/widelands-repo/OTHER_BRANCHES
The script should be stored in the folder 'widelands-repo' and can be used in two ways:
- Call it from folder widelands-repo in form of
./compile.sh FOLDEROFBRANCH , e.g.: ./complie.sh trunk
- Call it from a branchs folder, say from '~/widelands-repo/trunk', in form of:
../compile.sh (Note the double points in front)
The file containing the compile output is stored always in the directory where this script lives and is called 'compile.txt'
One disadvantage: Changing compile options needs editing the script file. But i assume most people do always use the same options, so editing one time will suffice.
And here is the script. If you want to use it, don't forget to mark it as executable (chmod +x compile.sh):
#!/bin/bash
CALL_DIR="$(basename $PWD)"
SCRIPT_PATH="$(dirname $(readlink -e "$0"))"
SCRIPT_DIR="$(basename $SCRIPT_PATH)"
# Check the folder from where we are running this script
if [ "$1" == "" ]; then
if [ "$CALL_DIR" == "$SCRIPT_DIR" ]; then
# We're in the script folder but an argument is missing
echo "Use command: ./compile.sh DIRECTORY"
exit 0
else
# We're in the folder of the branch we want to compile
BRANCH_DIR="$(basename "$PWD")"
fi
fi
if [ -z $BRANCH_DIR ]; then
# We're not in the folder of the branch, so cd into it
cd $1
fi
# Set amount of available processor cores -1
CORES="$(nproc --ignore=1)"
# For systems with only one core
if [ $CORES == "0" ]; then
CORES=1
fi
echo "-------------------------------------------"
echo "Compiling branch $1 $BRANCH_DIR" | tee $SCRIPT_PATH/compile.txt
echo "-------------------------------------------"
# Check if directories / links already exists and create / update them if needed.
test -d build/locale || mkdir -p build/locale
test -e data/locale || ln -s ../build/locale data/locale
cd build
# Change the approriate compile option here!
cmake -DCMAKE_BUILD_TYPE=Debug \
-DOPTION_BUILD_WEBSITE_TOOLS=OFF \
-DOPTION_BUILD_TRANSLATIONS=ON \
-DOPTION_ASAN=OFF \
.. | tee -a $SCRIPT_PATH/compile.txt
make -j$CORES | tee -a $SCRIPT_PATH/compile.txt
rm -f ../VERSION || true
rm -f ../widelands || true
rm -f ../wl_map_object_info || true
rm -f ../wl_map_info || true
mv VERSION ../VERSION
mv src/widelands ../widelands
if [ -e ../build/src/website/wl_map_object_info ]; then
mv ../build/src/website/wl_map_object_info ../wl_map_object_info
mv ../build/src/website/wl_map_info ../wl_map_info
fi
Fight simulator for Widelands: https://wide-fighter.netlify.app/
Top
Quote
|