2020-07-10 20:41:46 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
command=$1
|
|
|
|
|
|
|
|
|
2021-03-21 16:25:12 +00:00
|
|
|
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
|
|
|
|
2020-07-23 17:13:16 +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() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2020-07-10 20:41:46 +01:00
|
|
|
ninja
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function build() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
|
|
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug "$@" $ROOT_DIR
|
2020-07-10 21:00:14 +01:00
|
|
|
ninja -j `nproc`
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 19:56:54 +01:00
|
|
|
function build-20() {
|
|
|
|
pushed_build
|
|
|
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCPP_20_SUPPORT=ON "$@" $ROOT_DIR
|
|
|
|
ninja -j `nproc`
|
|
|
|
popd_build
|
|
|
|
}
|
|
|
|
|
2020-07-10 20:55:37 +01:00
|
|
|
function build-release() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2020-07-10 20:55:37 +01:00
|
|
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release $ROOT_DIR
|
2020-07-10 21:00:14 +01:00
|
|
|
ninja -j `nproc`
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:55:37 +01:00
|
|
|
}
|
|
|
|
|
2021-04-05 17:51:09 +01:00
|
|
|
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() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2021-03-28 23:14:32 +01:00
|
|
|
$BUILD_DIR/bin/serenec "$@"
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function memcheck() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2020-07-10 20:41:46 +01:00
|
|
|
ctest -T memcheck
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-06 00:21:43 +01:00
|
|
|
function run-tests() {
|
2021-04-14 18:14:39 +01:00
|
|
|
$BUILD_DIR/src/tests/tests
|
2021-04-06 00:21:43 +01:00
|
|
|
}
|
|
|
|
|
2020-07-10 20:41:46 +01:00
|
|
|
function tests() {
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2021-04-06 00:21:43 +01:00
|
|
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON $ROOT_DIR
|
|
|
|
ninja -j `nproc`
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$command" in
|
2020-07-23 21:53:42 +01:00
|
|
|
"setup")
|
|
|
|
pushd ./scripts
|
2021-04-13 10:39:13 +01:00
|
|
|
./git-pre-commit-format install
|
2020-07-23 21:53:42 +01:00
|
|
|
popd
|
|
|
|
;;
|
2020-07-10 20:41:46 +01:00
|
|
|
"build")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
2020-07-23 17:13:16 +01:00
|
|
|
build "${@:2}"
|
2020-07-10 20:41:46 +01:00
|
|
|
;;
|
2021-04-07 19:56:54 +01:00
|
|
|
"build-20")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
build-20 "${@:2}"
|
|
|
|
;;
|
|
|
|
|
2021-04-05 17:51:09 +01:00
|
|
|
"build-docs")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
build-docs "${@:2}"
|
|
|
|
;;
|
|
|
|
|
2020-07-10 20:55:37 +01:00
|
|
|
"build-release")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
2021-04-05 17:51:09 +01:00
|
|
|
build-release "${@:2}"
|
2020-07-10 20:55:37 +01:00
|
|
|
;;
|
2020-07-10 20:41:46 +01:00
|
|
|
"compile")
|
2020-07-16 15:48:06 +01:00
|
|
|
compile
|
2020-07-10 20:41:46 +01:00
|
|
|
;;
|
2021-04-06 00:21:43 +01:00
|
|
|
"compile-and-test")
|
|
|
|
compile
|
|
|
|
run-tests
|
|
|
|
;;
|
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
|
|
|
;;
|
2021-04-08 19:59:47 +01:00
|
|
|
"run-tests")
|
|
|
|
run-tests "${@:2}"
|
|
|
|
;;
|
2020-07-10 20:41:46 +01:00
|
|
|
|
|
|
|
"scan-build")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
2020-07-23 17:13:16 +01:00
|
|
|
pushed_build
|
2020-07-10 20:41:46 +01:00
|
|
|
exec $scanbuild cmake $ROOT_DIR
|
|
|
|
exec $scanbuild scan-build make -j 4
|
2020-07-23 17:13:16 +01:00
|
|
|
popd_build
|
2020-07-10 20:41:46 +01:00
|
|
|
;;
|
|
|
|
"memcheck")
|
|
|
|
memcheck
|
|
|
|
;;
|
2021-04-06 00:21:43 +01:00
|
|
|
"tests")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
2020-07-10 20:41:46 +01:00
|
|
|
tests
|
2021-04-06 00:21:43 +01:00
|
|
|
run-tests
|
2020-07-10 20:41:46 +01:00
|
|
|
;;
|
|
|
|
"clean")
|
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
;;
|
|
|
|
"full-build")
|
|
|
|
clean
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
build
|
|
|
|
tests
|
2021-04-06 00:21:43 +01:00
|
|
|
run-tests
|
2020-07-10 20:41:46 +01:00
|
|
|
memcheck
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Commands: "
|
|
|
|
echo "full-build - Build and test Serene."
|
2020-07-10 20:55:37 +01:00
|
|
|
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"
|
2021-04-13 10:39:13 +01:00
|
|
|
echo "compile-and-tests - reCompiles the project using the already exist cmake configuration and runs the tests"
|
2020-07-10 20:41:46 +01:00
|
|
|
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
|