mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-12 13:10:43 +02:00
updating scripts
This commit is contained in:
parent
4d3c06304f
commit
08127bad50
@ -1,13 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
||||
set -e
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source $CURRENT_DIR/common.sh
|
||||
|
||||
trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ "$LASTRES" -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" == "true" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT
|
||||
|
||||
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
DIRNAME="${SRCDIR##*/}"
|
||||
SOURCE_DIR=$PWD
|
||||
|
||||
BUILDPATH=$SOURCE_DIR"/build/testcc"
|
||||
|
||||
38
scripts/common.sh
Normal file
38
scripts/common.sh
Normal file
@ -0,0 +1,38 @@
|
||||
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
||||
set -e
|
||||
|
||||
function exit_function() {
|
||||
LASTRES=$?; LAST=$BASH_COMMAND; # save last command and status
|
||||
if [[ "$LASTRES" -ne 0 ]]; then
|
||||
fail "Command: \"$LAST\" exited with exit code: $LASTRES";
|
||||
exit 1;
|
||||
elif [ "$FAIL" == "true" ]; then
|
||||
fail finished with error;
|
||||
exit 1;
|
||||
else
|
||||
pass "finished";
|
||||
fi
|
||||
}
|
||||
|
||||
trap exit_function EXIT
|
||||
|
||||
# ################
|
||||
# Output funcitons
|
||||
# ################
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
function info () {
|
||||
echo -e "[${BLUE} $@ ${NC}]"
|
||||
}
|
||||
|
||||
function pass() {
|
||||
echo -e "[${GREEN}PASS${NC}] $@"
|
||||
}
|
||||
|
||||
function fail() {
|
||||
FAIL="true"; echo -e "[${RED}FAIL${NC}] $@"
|
||||
}
|
||||
|
||||
@ -1,58 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
||||
set -e
|
||||
|
||||
trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ "$LASTRES" -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" == "true" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
DIRNAME="${CURRENT_DIR##*/}"
|
||||
source $CURRENT_DIR/common.sh
|
||||
|
||||
SOURCE_DIR=$PWD
|
||||
|
||||
exclude_dir=build
|
||||
check_dir=$SOURCE_DIR/src
|
||||
suppress="--suppress=missingInclude --suppress=unusedFunction"
|
||||
|
||||
FAIL=0
|
||||
main() {
|
||||
if [ ! -d src ]; then
|
||||
fail "src dir does not exists"
|
||||
else
|
||||
pass "src dir exits"
|
||||
fi
|
||||
|
||||
{ ERROR="$( { cppcheck $check_dir $suppress --enable=all -i $exclude_dir; } 2>&1 1>&3 3>&- )"; } 3>&1;
|
||||
|
||||
if [ ! -z "$ERROR" ]; then
|
||||
echo "----------------------------------"
|
||||
echo "$ERROR"
|
||||
echo "----------------------------------"
|
||||
fail "Cppcheck finished with error"
|
||||
fi
|
||||
}
|
||||
EXCLUDE_DIR=build
|
||||
CHECK_DIR=$SOURCE_DIR/src
|
||||
SUPPRESS="--suppress=missingInclude --suppress=unusedFunction"
|
||||
|
||||
|
||||
# ################
|
||||
# Output funcitons
|
||||
# ################
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
info cppcheck version: `cppcheck --version`
|
||||
if [ ! -d src ]; then
|
||||
fail "src dir does not exists"
|
||||
else
|
||||
pass "src dir exits"
|
||||
fi
|
||||
|
||||
function info () {
|
||||
echo -e "[${BLUE} $@ ${NC}]"
|
||||
}
|
||||
{ ERROR="$( { cppcheck $CHECK_DIR $SUPPRESS --enable=all -i $EXCLUDE_DIR; } 2>&1 1>&3 3>&- )"; } 3>&1;
|
||||
|
||||
function pass() {
|
||||
echo -e "[${GREEN}PASS${NC}] $@"
|
||||
}
|
||||
|
||||
function fail() {
|
||||
FAIL="true"; echo -e "[${RED}FAIL${NC}] $@"
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
if [ ! -z "$ERROR" ]; then
|
||||
echo "----------------------------------"
|
||||
echo "$ERROR"
|
||||
echo "----------------------------------"
|
||||
fail "Cppcheck finished with error"
|
||||
fi
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
||||
set -e
|
||||
|
||||
trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ "$LASTRES" -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" == "true" ]; then fail finished with error; exit 1; else pass "finished";fi' EXIT
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
DIR_NAME="${CURRENT_DIR##*/}"
|
||||
source $CURRENT_DIR/common.sh
|
||||
|
||||
FAIL=0
|
||||
SOURCE_DIR=$PWD
|
||||
BUILD_DIR=$SOURCE_DIR"/build"
|
||||
DOC_DIR=$BUILD_DIR"/doc"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user