1 Star 0 Fork 178

zhao_jd/drogon

forked from an-tao/drogon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.sh 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env bash
#build drogon
function build_drogon() {
#Update the submodule and initialize
git submodule update --init
#Remove the config.h generated by the old version of drogon.
rm -f lib/inc/drogon/config.h
#Save current directory
current_dir="${PWD}"
#The folder in which we will build drogon
build_dir='./build'
if [ -d $build_dir ]; then
echo "Deleted folder: ${build_dir}"
rm -rf $build_dir
fi
#Create building folder
echo "Created building folder: ${build_dir}"
mkdir $build_dir
echo "Entering folder: ${build_dir}"
cd $build_dir
echo "Start building drogon ..."
if [ $1 -eq 1 ]; then
cmake .. -DBUILD_TESTING=YES $cmake_gen
elif [ $1 -eq 2 ]; then
cmake .. -DBUILD_TESTING=YES -DBUILD_DROGON_SHARED=ON -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=1 $cmake_gen
else
cmake .. -DCMAKE_BUILD_TYPE=release $cmake_gen
fi
#If errors then exit
if [ "$?" != "0" ]; then
exit -1
fi
$make_program $make_flags
#If errors then exit
if [ "$?" != "0" ]; then
exit -1
fi
echo "Installing ..."
sudo $make_program install
#Go back to the current directory
cd $current_dir
#Ok!
}
make_program=make
make_flags=''
cmake_gen=''
parallel=1
case $(uname) in
FreeBSD)
nproc=$(sysctl -n hw.ncpu)
;;
Darwin)
nproc=$(sysctl -n hw.ncpu) # sysctl -n hw.ncpu is the equivalent to nproc on macOS.
;;
*)
nproc=$(nproc)
;;
esac
# simulate ninja's parallelism
case nproc in
1)
parallel=$(( nproc + 1 ))
;;
2)
parallel=$(( nproc + 1 ))
;;
*)
parallel=$(( nproc + 2 ))
;;
esac
if [ -f /bin/ninja ]; then
make_program=ninja
cmake_gen='-GNinja'
else
make_flags="$make_flags -j$parallel"
fi
if [ "$1" = "-t" ]; then
build_drogon 1
elif [ "$1" = "-tshared" ]; then
build_drogon 2
else
build_drogon 0
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhao_jd/drogon.git
git@gitee.com:zhao_jd/drogon.git
zhao_jd
drogon
drogon
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385