From 93a2a7b3f8e8f8f92efc225ee48d7095b9cd157d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Sun, 28 Jan 2024 18:32:26 +0100 Subject: [PATCH] Add include folder for extra functions --- include/common/colors.inc | 63 +++++++++++++++++++++++++++++++ include/common/compiler.inc | 14 +++++++ include/common/input_to_array.inc | 11 ++++++ include/common/loggy.inc | 7 ++++ include/common/numcpu.inc | 4 ++ include/common/slash_to_array.inc | 9 +++++ 6 files changed, 108 insertions(+) create mode 100755 include/common/colors.inc create mode 100644 include/common/compiler.inc create mode 100644 include/common/input_to_array.inc create mode 100644 include/common/loggy.inc create mode 100644 include/common/numcpu.inc create mode 100644 include/common/slash_to_array.inc diff --git a/include/common/colors.inc b/include/common/colors.inc new file mode 100755 index 0000000..cd74996 --- /dev/null +++ b/include/common/colors.inc @@ -0,0 +1,63 @@ +# Here you set the colors you want in the output of view and search +# +# Black 0;30 Dark Gray 1;30 +# Blue 0;34 Light Blue 1;34 +# Green 0;32 Light Green 1;32 +# Cyan 0;36 Light Cyan 1;36 +# Red 0;31 Light Red 1;31 +# Purple 0;35 Light Purple 1;35 +# Brown 0;33 Yellow 1;33 +# Light Gray 0;37 White 1;37 +LIGHTGREEN="\033[1;32m" +YELLOW="\033[1;33m" +WHITE="\033[1;37m" +BLACK="\033[0;30m" +BLUE="\033[0;34m" +GREEN="\033[0;32m" +CYAN="\033[0;36m" +RED="\033[0;31m" +PURPLE="\033[0;35m" +BROWN="\033[0;33m" +LIGHTGRAY="\033[0;37m" +DARKGRAY="\033[1;30m" +LIGHTBLUE="\033[1;34m" +LIGHTCYAN="\033[1;36m" +LIGHTRED="\033[1;31m" +LIGHTPURPLE="\033[1;35m" +END="\033[0m" + +LightGreen="\033[1;32m" +Yellow="\033[1;33m" +White="\033[1;37m" +Black="\033[0;30m" +Blue="\033[0;34m" +Green="\033[0;32m" +Cyan="\033[0;36m" +Red="\033[0;31m" +Purple="\033[0;35m" +Brown="\033[0;33m" +LightGray="\033[0;37m" +DarkGray="\033[1;30m" +LightBlue="\033[1;34m" +LightCyan="\033[1;36m" +LightRed="\033[1;31m" +LightPurple="\033[1;35m" +End="\033[0m" + +lightgreen="\033[1;32m" +yellow="\033[1;33m" +white="\033[1;37m" +black="\033[0;30m" +blue="\033[0;34m" +green="\033[0;32m" +cyan="\033[0;36m" +red="\033[0;31m" +purple="\033[0;35m" +brown="\033[0;33m" +lightgray="\033[0;37m" +darkgray="\033[1;30m" +lightblue="\033[1;34m" +lightcyan="\033[1;36m" +lightred="\033[1;31m" +lightpurple="\033[1;35m" +end="\033[0m" diff --git a/include/common/compiler.inc b/include/common/compiler.inc new file mode 100644 index 0000000..601a4a6 --- /dev/null +++ b/include/common/compiler.inc @@ -0,0 +1,14 @@ +function doClang() { + export CC=clang + export CXX=clang++ +} + +function doGcc() { + export CC=gcc + export CXX=g++ +} + +function undoCompiler() { + unset CC + unset CXX +} diff --git a/include/common/input_to_array.inc b/include/common/input_to_array.inc new file mode 100644 index 0000000..7e172be --- /dev/null +++ b/include/common/input_to_array.inc @@ -0,0 +1,11 @@ +# Converts a --with=option,option2 into an array +# Usage: InputToArray +# Returns: $InputArray + +function InputToArray () { + + if [[ ${@} =~ "--with" ]]; then + InputArray=( $( echo ${@} | cut -d= -f2 | sed -e 's/\,/\ /g' ) ) + fi + +} diff --git a/include/common/loggy.inc b/include/common/loggy.inc new file mode 100644 index 0000000..dd205a7 --- /dev/null +++ b/include/common/loggy.inc @@ -0,0 +1,7 @@ +# Function: LOGGER +# Usage: loggy +function loggy () { + + echo "$$ - $(date +%T) - ${KODIVERSION} - ${@}" >> ${LOGGYLOGFILE} + +} diff --git a/include/common/numcpu.inc b/include/common/numcpu.inc new file mode 100644 index 0000000..b7c1867 --- /dev/null +++ b/include/common/numcpu.inc @@ -0,0 +1,4 @@ +# Find the number of available cores and return variable NUMCPU +# You can use this i.e. to "make -j${NUMCPU}" + +NUMCPU=$(getconf _NPROCESSORS_ONLN) diff --git a/include/common/slash_to_array.inc b/include/common/slash_to_array.inc new file mode 100644 index 0000000..43d0790 --- /dev/null +++ b/include/common/slash_to_array.inc @@ -0,0 +1,9 @@ +# This function creates an array of a *nix path +# Example: /home/user/bin becomes an array of ( home user bin ) + +function slash_to_array () { + + sta=( $( echo ${1} | sed -e "s/\//\ /g" ) ) + # return ${sta} + +} \ No newline at end of file