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