print_toolchain_versions.sh
2.07 KB
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/sh
gcc_version() {
local cc
if [ -z "$1" ]; then
cc=gcc
else
cc=$1-gcc
fi
local ver=
if command -v "$cc" 2>&1 >/dev/null; then
ver=$("$cc" --version | head -n 1)
fi
if [ -z "$ver" ]; then
ver=missing/error
fi
printf "%s" "$ver"
}
get_define() {
local cc="$1"
local line=
if command -v "$cc" 2>&1 >/dev/null; then
line=$(echo "$3" | "$cc" -x c -include "$2" -E -o - - 2>&1 | sed -e '/^[ ]*#/d' -e '/^[ ]*$/d')
fi
if [ -z "$line" ]; then
line=missing/error
fi
printf "%s" "$line"
}
newlib_version() {
if [ -z "$1" ]; then
cc=gcc
else
cc=$1-gcc
fi
printf "%s" "$(get_define "$cc" newlib.h _NEWLIB_VERSION)"
}
avr_libc_version() {
if [ -z "$1" ]; then
cc=gcc
else
cc=$1-gcc
fi
printf "%s (%s)" "$(get_define "$cc" avr/version.h __AVR_LIBC_VERSION_STRING__)" "$(get_define "$cc" avr/version.h __AVR_LIBC_DATE_STRING__)"
}
cppcheck_version() {
local cmd="cppcheck"
if command -v "$cmd" 2>&1 >/dev/null; then
ver=$("$cmd" --version | head -n 1)
else
ver="missing"
fi
printf "%s" "$ver"
}
spatch_version() {
local cmd="spatch"
if command -v "$cmd" 2>&1 >/dev/null; then
ver=$("$cmd" --version | head -n 1)
else
ver="missing"
fi
printf "%s" "$ver"
}
printf "%s\n" "Installed toolchain versions"
printf "%s\n" "----------------------------"
VER=$(gcc --version | head -n 1)
if [ -n "$VER" ]; then
printf "%20s: %s\n" "native gcc" "$VER"
fi
for p in msp430 avr arm-none-eabi mips-mti-elf; do
printf "%20s: %s\n" "$p-gcc" "$(gcc_version "$p")"
done
VER=$(clang --version | head -n 1)
if [ -n "$VER" ]; then
printf "%20s: %s\n" "clang" "$VER"
fi
for p in arm-none-eabi mips-mti-elf; do
printf "%20s: %s\n" "$p-newlib" "$(newlib_version "$p")"
done
for p in avr; do
printf "%20s: %s\n" "$p-libc" "$(avr_libc_version "$p")"
done
printf "%20s: %s\n" "cppcheck" "$(cppcheck_version)"
printf "%20s: %s\n" "coccinelle" "$(spatch_version)"
exit 0