Skip to content
Snippets Groups Projects
Verified Commit f0eba63b authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#107] Added basic script to run projects with proper working directory

parent a2a9ed7a
No related branches found
No related tags found
1 merge request!99Resolve "Automatische Generierung von cmake-Files für Projekte"
Pipeline #27317 passed
#!/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
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment