Add initial codes
[it/test.git] / simulators / e2sim / tools / build_helper.bash
1
2 #
3 # Copyright 2019 AT&T Intellectual Property
4 # Copyright 2019 Nokia
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 #######################################
20 #            Helper Func
21 ######################################
22
23 black='\E[30m'
24 red='\E[31m'
25 green='\E[32m'
26 yellow='\E[33m'
27 blue='\E[34m'
28 magenta='\E[35m'
29 cyan='\E[36m'
30 white='\E[37m'
31 reset_color='\E[00m'
32
33 cecho()   # Color-echo. arg1 = message, arg2 = color
34 {
35     local default_msg="No Message."
36     message=${1:-$default_msg}
37     color=${2:-$green}
38     echo -e -n "$color$message$reset_color"
39     echo
40     return
41 }
42
43 echo_error() {
44     local my_string=""
45     until [ -z "$1" ]
46     do
47         my_string="$my_string$1"
48         shift
49         done
50         cecho "$my_string" $red
51 }
52
53 echo_fatal() {
54     local my_string=""
55     until [ -z "$1" ]
56     do
57         my_string="$my_string$1"
58         shift
59         done
60         echo_error "$my_string"
61     exit -1
62 }
63
64 echo_warning() {
65     local my_string=""
66     until [ -z "$1" ]
67     do
68         my_string="$my_string$1"
69         shift
70     done
71     cecho "$my_string" $yellow
72 }
73
74 echo_success() {
75     local my_string=""
76     until [ -z "$1" ]
77     do
78         my_string="$my_string$1"
79         shift
80     done
81     cecho "$my_string" $green
82 }
83
84 echo_info() {
85     local my_string=""
86     until [ -z "$1" ]
87     do
88         my_string="$my_string$1"
89         shift
90     done
91     cecho "$my_string" $blue
92 }