multi target
This commit is contained in:
parent
fb17f39bb1
commit
65bc945f66
1 changed files with 23 additions and 25 deletions
48
ch
48
ch
|
@ -6,15 +6,18 @@
|
||||||
BUILD_DEBUG_FOLDER="build/debug"
|
BUILD_DEBUG_FOLDER="build/debug"
|
||||||
BUILD_RELEASE_FOLDER="build/release"
|
BUILD_RELEASE_FOLDER="build/release"
|
||||||
DEFAULT_BUILD_TYPE="d" # "d" for debug and "r" for release
|
DEFAULT_BUILD_TYPE="d" # "d" for debug and "r" for release
|
||||||
EXECUTABLE_NAME="{{project-name}}" # should be the name of the executable beeing built, this is used for the run action
|
DEFAULT_TARGET="{{project-name}}" # should be the name of the executable beeing built, this is used for the run action
|
||||||
|
|
||||||
COLOR="\033[1;33m" # https://stackoverflow.com/a/5947802
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
## this is where the script starts you should not need to edit anything below this line
|
## this is where the script starts you should not need to edit anything below this line
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
if [ -n "$TARGET" ]; then
|
||||||
|
DEFAULT_TARGET=$TARGET
|
||||||
|
fi
|
||||||
|
|
||||||
NC="\033[0m" # No Color
|
NC="\033[0m" # No Color
|
||||||
|
COLOR="\033[1;33m"
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
then
|
then
|
||||||
|
@ -37,6 +40,7 @@ case $1 in
|
||||||
echo "b - build project"
|
echo "b - build project"
|
||||||
echo "r - run project"
|
echo "r - run project"
|
||||||
echo "s - strip executable"
|
echo "s - strip executable"
|
||||||
|
echo "d - debug with gdb"
|
||||||
echo ""
|
echo ""
|
||||||
echo "actions can be chained so gbr will first run generate then build and then run"
|
echo "actions can be chained so gbr will first run generate then build and then run"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -67,50 +71,44 @@ echo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ARG=$1
|
ARG=$1
|
||||||
|
if [[ $BUILD_TYPE == "d" ]]; then
|
||||||
|
BUILD_FOLDER=$BUILD_DEBUG_FOLDER
|
||||||
|
else
|
||||||
|
BUILD_FOLDER=$BUILD_RELEASE_FOLDER
|
||||||
|
fi
|
||||||
for (( i=0; i<${#ARG}; i++ )); do
|
for (( i=0; i<${#ARG}; i++ )); do
|
||||||
case ${ARG:$i:1} in
|
case ${ARG:$i:1} in
|
||||||
"c")
|
"c")
|
||||||
echo "cleaning project"
|
echo "cleaning project"
|
||||||
if [[ $BUILD_TYPE == "d" ]]; then
|
rm -rf $BUILD_FOLDER
|
||||||
rm -rf $BUILD_DEBUG_FOLDER
|
|
||||||
else
|
|
||||||
rm -rf $BUILD_RELEASE_FOLDER
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
"g")
|
"g")
|
||||||
echo "generating cmake files"
|
echo "generating cmake files"
|
||||||
|
mkdir -p $BUILD_FOLDER
|
||||||
if [[ $BUILD_TYPE == "d" ]]; then
|
if [[ $BUILD_TYPE == "d" ]]; then
|
||||||
mkdir -p $BUILD_DEBUG_FOLDER
|
|
||||||
cmake -S . -B $BUILD_DEBUG_FOLDER -DCMAKE_BUILD_TYPE=Debug
|
cmake -S . -B $BUILD_DEBUG_FOLDER -DCMAKE_BUILD_TYPE=Debug
|
||||||
else
|
else
|
||||||
mkdir -p $BUILD_RELEASE_FOLDER
|
|
||||||
cmake -S . -B $BUILD_RELEASE_FOLDER -DCMAKE_BUILD_TYPE=Release
|
cmake -S . -B $BUILD_RELEASE_FOLDER -DCMAKE_BUILD_TYPE=Release
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"b")
|
"b")
|
||||||
echo "building project"
|
echo "building project"
|
||||||
if [[ $BUILD_TYPE == "d" ]]; then
|
cmake --build $BUILD_FOLDER
|
||||||
cmake --build $BUILD_DEBUG_FOLDER
|
|
||||||
else
|
|
||||||
cmake --build $BUILD_RELEASE_FOLDER
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
"r")
|
"r")
|
||||||
echo "running project"
|
echo "running project"
|
||||||
if [[ $BUILD_TYPE == "d" ]]; then
|
./$BUILD_FOLDER/$DEFAULT_TARGET
|
||||||
./$BUILD_DEBUG_FOLDER/$EXECUTABLE_NAME
|
|
||||||
else
|
|
||||||
./$BUILD_RELEASE_FOLDER/$EXECUTABLE_NAME
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
"s")
|
"s")
|
||||||
echo "stripping executable"
|
echo "stripping executable"
|
||||||
if [[ $BUILD_TYPE == "d" ]]; then
|
strip -s $BUILD_FOLDER/$DEFAULT_TARGET -o "$BUILD_FOLDER/$DEFAULT_TARGET-stripped"
|
||||||
strip -s $BUILD_DEBUG_FOLDER/$EXECUTABLE_NAME -o "$BUILD_DEBUG_FOLDER/$EXECUTABLE_NAME-stripped"
|
|
||||||
else
|
|
||||||
strip -s $BUILD_RELEASE_FOLDER/$EXECUTABLE_NAME -o "$BUILD_RELEASE_FOLDER/$EXECUTABLE_NAME-stripped"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
"d")
|
||||||
|
echo "debug project"
|
||||||
|
if [[ $BUILD_TYPE == "r" ]]; then
|
||||||
|
echo "WARNING: debugging release build"
|
||||||
|
fi
|
||||||
|
gdb ./$BUILD_FOLDER/$DEFAULT_TARGET
|
||||||
*)
|
*)
|
||||||
echo "unknown action ${1:$i:1}"
|
echo "unknown action ${1:$i:1}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue