Skip to content

Commit

Permalink
add build helper script
Browse files Browse the repository at this point in the history
- use clang as default compiler
- add depends check
- use split build directory for gcc/clang
  • Loading branch information
yetist committed May 24, 2022
1 parent 09e6cc7 commit ae49f13
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions build2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

cmake_flags=(
# CMAKE_BUILD_TYPE
# values: Release/Debug
-DCMAKE_BUILD_TYPE=Release

# CMAKE_VERBOSE_MAKEFILE
# ON: verbose build output, OFF: silent build output
-DCMAKE_VERBOSE_MAKEFILE=ON

-DOB_BUILD_RPM=OFF

# OB_USE_CLANG
# ON: use clang, OFF: use gcc
-DOB_USE_CLANG=ON

# OB_USE_LLVM_LIBTOOLS
# ON: use lld & llvm-objcopy, OFF: use ld & objcopy
-DOB_USE_LLVM_LIBTOOLS=ON

-DOB_COMPRESS_DEBUG_SECTIONS=OFF
-DOB_STATIC_LINK_LGPL_DEPS=OFF

-DOB_USE_CCACHE=OFF
-DOB_ENABLE_PCH=ON
-DOB_ENALBE_UNITY=ON
-DOB_MAX_UNITY_BATCH_SIZE=30
-DOB_USE_ASAN=OFF

-DOB_RELEASEID=1
)

# check the depends library
for i in openssl RapidJSON libisal; do
pkg-config --exists $i
if [ $? -ne 0 ];then
echo "Please install $i"
exit
fi
done

# use split build directory for gcc/clang (release/debug)
BUILD_DIR=build
eval "export `echo "${cmake_flags[@]}" | sed 's/\-D//g'`"
if [ $OB_USE_CLANG == "ON" ]; then
BUILD_DIR="${BUILD_DIR}.clang"
elif [ $OB_USE_CLANG == "OFF" ]; then
BUILD_DIR="${BUILD_DIR}.gcc"
fi

if [ $OB_USE_LLVM_LIBTOOLS == "ON" ]; then
BUILD_DIR="${BUILD_DIR}.lld"
elif [ $OB_USE_LLVM_LIBTOOLS == "OFF" ]; then
BUILD_DIR="${BUILD_DIR}.ld"
fi

if [ $CMAKE_BUILD_TYPE == "Release" ];then
BUILD_DIR="${BUILD_DIR}.release"
elif [ $CMAKE_BUILD_TYPE == "Debug" ];then
BUILD_DIR="${BUILD_DIR}.debug"
fi
eval "unset `echo "${cmake_flags[@]}" | sed 's/\-D//g' | sed 's/=[0-9a-zA-Z]*/ /g'`"

[ -d $BUILD_DIR ] || mkdir -p $BUILD_DIR
cd $BUILD_DIR

cmake "${cmake_flags[@]}" ..

make -j`nproc` 2>&1 | tee build.log

0 comments on commit ae49f13

Please sign in to comment.