diff --git a/scripts/build.sh b/scripts/build.sh index fcf1324c71322ac6993bdc69174cc19cbd19f13f..7e41ca8e8ad62ce6667ab4d9c549f2ea613d28aa 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,8 +1,17 @@ #!/bin/sh +# Check if release or debug build +CMAKE_BUILD_DIR="build" +CMAKE_FLAGS="" +if [ "$1" = "--debug" ]; then + CMAKE_BUILD_DIR="cmake-build-debug" + CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Debug" +elif [ "$1" = "--release" ]; then + CMAKE_BUILD_DIR="cmake-build-release" + CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Release" +fi # Navigate to the main directory of the cloned repository -BASEDIR=$(dirname "$0") -cd $BASEDIR +cd "$(dirname "$0")" || exit cd .. # Setup git lfs and the submodules @@ -11,9 +20,14 @@ git submodule init git submodule update # Setup build directory -mkdir build -cd build +mkdir $CMAKE_BUILD_DIR +cd $CMAKE_BUILD_DIR || exit +BUILD_THREADS=$(($(nproc --all) - 1)) + +if [ $BUILD_THREADS -lt 1 ]; then + BUILD_THREADS=1 +fi # Build process -cmake .. -make \ No newline at end of file +cmake $CMAKE_FLAGS .. +make -j $BUILD_THREADS "$@" \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..8e2ead5541695b9186350a3486cc7f60ca4a598b --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Navigate to the scripts directory +cd "$(dirname "$0")" || exit + +# Check if there is a project name as argument +if [ $# -lt 1 ]; then + echo "You need to specify a project name to run!">&2 + exit +fi + +PROJECT=$1 +PROJECT_DIR="../projects/$PROJECT" + +# Check if the project name is valid +if [ ! -d "$PROJECT_DIR" ]; then + echo "There is no project with the name '$PROJECT'!">&2 + exit +fi + +./build.sh $PROJECT +cd "$PROJECT_DIR" || exit + +if [ ! -f "$PROJECT" ]; then + echo "Building the project '$PROJECT' failed!">&2 + exit +fi + +./$PROJECT \ No newline at end of file