59 lines
1.3 KiB
Bash
Executable File
59 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
base_path=$(pwd)
|
|
build_path=${base_path}/build
|
|
libraries_root="/opt/3rdparty"
|
|
|
|
function cmake_scan() {
|
|
echo "scanning the project..."
|
|
if [ ! -d ${build_path} ]; then
|
|
mkdir -p ${build_path}
|
|
fi
|
|
cd ${build_path}
|
|
cmake -G Ninja -S ${base_path} -B ${build_path} \
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
-DMbedTLS_DIR=${libraries_root}/mbedtls-3.6.5/lib/cmake/MbedTLS \
|
|
-Dnng_DIR=${libraries_root}/nng-1.11/lib/cmake/nng \
|
|
-DBoost_DIR=${libraries_root}/boost_1_89_0/lib/cmake/Boost-1.89.0
|
|
}
|
|
|
|
function build() {
|
|
echo "building the project..."
|
|
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
|
|
cmake_scan
|
|
fi
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
cmake --build ${build_path} --target all
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function changelog(){
|
|
current_tag=$(git describe --tags --abbrev=0)
|
|
previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
|
|
git log ${previous_tag}..${current_tag} --reverse --pretty=format:"%B" | nl -w2 -s". " > CHANGELOG.txt
|
|
cat CHANGELOG.txt
|
|
}
|
|
|
|
function main() {
|
|
local cmd=$1
|
|
shift 1
|
|
case $cmd in
|
|
changelog)
|
|
changelog
|
|
;;
|
|
build)
|
|
build
|
|
;;
|
|
*)
|
|
build
|
|
;;
|
|
esac
|
|
}
|
|
|
|
main $@
|
|
|