Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VCMI build benchmark for different compilers, linkers and build systems
#!/bin/bash
# All compilation done in tmpfs
CFG_VCMI_GIT="https://github.com/vcmi/vcmi.git"
CFG_SRC_DIR="/dev/shm/vcmi_src"
CFG_BUILD_DIR="/dev/shm/vcmi_build"
CFG_BUILD_OPTIONS="-j 9"
# File size function
__check_files() {
echo "RESULT FILE SIZES:"
for _filename in launcher/vcmilauncher client/vcmiclient server/vcmiserver lib/libvcmi.so lib/minizip/libminizip.so AI/BattleAI/libBattleAI.so AI/EmptyAI/libEmptyAI.so AI/StupidAI/libStupidAI.so AI/VCAI/libVCAI.so
do
du -h $CFG_BUILD_DIR/$_filename
done
}
# Get VCMI source
if [ ! -d "$CFG_SRC_DIR" ]; then
mkdir $CFG_SRC_DIR
cd $CFG_SRC_DIR
git clone $CFG_VCMI_GIT .
fi
# bench
for _compiler in GCC Clang
do
for _linker in LD Gold
do
# Set compiler
if [ "$_compiler" == "GCC" ]; then
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --set c++ /usr/bin/g++
elif [ "$_compiler" == "Clang" ]; then
sudo update-alternatives --set cc /usr/bin/clang-3.7
sudo update-alternatives --set c++ /usr/bin/clang++-3.7
else
echo "O_o"
exit
fi
# Set linker
if [ "$_linker" == "LD" ]; then
sudo update-alternatives --set ld /usr/bin/ld.bfd
elif [ "$_linker" == "Gold" ]; then
sudo update-alternatives --set ld /usr/bin/ld.gold
else
echo "O_o"
exit
fi
# Build using "make"
rm -rf $CFG_BUILD_DIR
mkdir $CFG_BUILD_DIR
cd $CFG_BUILD_DIR
cmake -q $CFG_SRC_DIR -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr
echo "Build using $_compiler + $_linker + make:"
time make -s $CFG_BUILD_OPTIONS
__check_files
cd ..
printf "\n\n\n\n\n\n"
# Build using "ninja"
rm -rf $CFG_BUILD_DIR
mkdir $CFG_BUILD_DIR
cd $CFG_BUILD_DIR
cmake -q $CFG_SRC_DIR -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -G Ninja -DCMAKE_MAKE_PROGRAM=ninja
echo "Build using $_compiler + $_linker + ninja:"
time ninja $CFG_BUILD_OPTIONS
__check_files
cd ..
printf "\n\n\n\n\n\n"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment