serene/builder

146 lines
2.8 KiB
Plaintext
Raw Normal View History

2020-07-10 20:41:46 +01:00
#! /bin/bash
command=$1
export CCC_CC=clang
export CCC_CXX=clang++
export CC=clang
export CXX=clang++
2020-07-10 20:41:46 +01:00
ROOT_DIR=`pwd`
BUILD_DIR=$ROOT_DIR/build
2020-08-01 19:58:34 +01:00
scanbuild=scan-build-11
2020-07-10 20:41:46 +01:00
function pushed_build() {
pushd $BUILD_DIR > /dev/null
}
function popd_build() {
popd > /dev/null
}
2020-07-10 20:41:46 +01:00
function compile() {
pushed_build
2020-07-10 20:41:46 +01:00
ninja
popd_build
2020-07-10 20:41:46 +01:00
}
function build() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug "$@" $ROOT_DIR
2020-07-10 21:00:14 +01:00
ninja -j `nproc`
popd_build
2020-07-10 20:41:46 +01:00
}
function build-release() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release $ROOT_DIR
2020-07-10 21:00:14 +01:00
ninja -j `nproc`
popd_build
}
function build-docs() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Docs $ROOT_DIR
ninja -j `nproc`
popd_build
}
2020-07-10 20:41:46 +01:00
function clean() {
rm -rf $BUILD_DIR
}
function run() {
pushed_build
$BUILD_DIR/bin/serenec "$@"
popd_build
2020-07-10 20:41:46 +01:00
}
function memcheck() {
pushed_build
2020-07-10 20:41:46 +01:00
ctest -T memcheck
popd_build
2020-07-10 20:41:46 +01:00
}
function tests() {
pushed_build
2020-07-10 20:41:46 +01:00
ctest
popd_build
2020-07-10 20:41:46 +01:00
}
case "$command" in
# We need to fix this to have some instructions about how to build the dependencies
2020-07-10 20:41:46 +01:00
"deps")
echo "You need the following dependencies"
echo "sudo apt update"
echo "sudo apt install -y llvm-10 llvm-10-tools clang-10 clang-format-10 clang-tidy-10 clang-tools-10 valgrind cmake ninja-build doxygen"
2020-07-10 20:41:46 +01:00
;;
2020-07-23 21:53:42 +01:00
"setup")
pushd ./scripts
./scripts/git-pre-commit-format install
popd
;;
2020-07-10 20:41:46 +01:00
"build")
clean
mkdir -p $BUILD_DIR
build "${@:2}"
2020-07-10 20:41:46 +01:00
;;
"build-docs")
clean
mkdir -p $BUILD_DIR
build-docs "${@:2}"
;;
"build-release")
clean
mkdir -p $BUILD_DIR
build-release "${@:2}"
;;
2020-07-10 20:41:46 +01:00
"compile")
compile
2020-07-10 20:41:46 +01:00
;;
"run")
2020-07-21 22:23:11 +01:00
run "${@:2}"
2020-07-10 20:41:46 +01:00
;;
"scan-build")
clean
mkdir -p $BUILD_DIR
pushed_build
2020-07-10 20:41:46 +01:00
exec $scanbuild cmake $ROOT_DIR
exec $scanbuild scan-build make -j 4
popd_build
2020-07-10 20:41:46 +01:00
;;
"memcheck")
memcheck
;;
"memcheck")
tests
;;
"clean")
rm -rf $BUILD_DIR
;;
"full-build")
clean
mkdir -p $BUILD_DIR
build
tests
memcheck
;;
*)
echo "Commands: "
echo "full-build - Build and test Serene."
echo "build - Build Serene from scratch in DEBUG mode."
echo "build-release - Build Serene from scratch in RELEASE mode."
2020-07-10 20:41:46 +01:00
echo "compile - reCompiles the project using the already exist cmake configuration"
echo "run - Runs the serene executable"
echo "scan-build - Compiles serene with static analyzer"
echo "tests - Runs the test cases"
echo "memcheck - Runs the memcheck tool."
echo "clean - :D"
;;
esac