blob: a0cce6e99200df9095f8bb5cfcda8741dabf9022 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/bin/bash
#------------------------------------------
# Parse command line args
#------------------------------------------
function help {
cat <<EOHELP
Usage: $0 [--help|-h] [--no-color] [<vivado args>]
--no-color : Don't colorize command output
--help, -h : Shows this message.
EOHELP
}
viv_args=""
colorize=1
for i in "$@"; do
case $i in
-h|--help)
help
exit 0
;;
--no-color)
colorize=0
;;
*)
viv_args="$viv_args $i"
;;
esac
done
#------------------------------------------
# Colorize
#------------------------------------------
# VIV_COLOR_SCHEME must be defined in the environment setup script
if [ $colorize -eq 0 ]; then
VIV_COLOR_SCHEME=none
fi
case "$VIV_COLOR_SCHEME" in
default)
CLR_OFF='tput sgr0'
ERR_CLR='tput setaf 1'
CRIWARN_CLR='tput setaf 1'
WARN_CLR='tput setaf 3'
;;
*)
CLR_OFF=''
ERR_CLR=$CLR_OFF
CRIWARN_CLR=$CLR_OFF
WARN_CLR=$CLR_OFF
esac
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
VIVADO_COMMAND="vivado"
if command -v vivado_lab >/dev/null 2>&1; then
VIVADO_COMMAND=vivado_lab
fi
$VIVADO_COMMAND $viv_args 2>&1 | while IFS= read -r line
do
if [[ $line != \#* ]]; then # Ignore script output
case $(trim $line) in
*FATAL:*|*Fatal:*)
eval $ERR_CLR; echo "$line"; eval $CLR_OFF
;;
*ERROR:*|*Error:*)
eval $ERR_CLR; echo "$line"; eval $CLR_OFF
;;
*CRITICAL[[:space:]]WARNING:*|*Crtical[[:space:]]Warning:*)
eval $CRIWARN_CLR; echo "$line"; eval $CLR_OFF
;;
*WARNING:*|*Warning:*)
eval $WARN_CLR; echo "$line"; eval $CLR_OFF
;;
*)
echo "$line"
esac
else
echo "$line"
fi
done
exit ${PIPESTATUS[0]}
|