1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/ci/print_toolchain_versions.sh
smlng 424830b06b dist/tools: parse version info from stderr
Currently version information of commands and tools is only parsed
from STDOUT, however some tools like openocd print version info
to STDERR only. This commits adds parsing of STDERR for version
infos if STDOUT does not contain such info.
2018-09-25 09:22:41 +02:00

81 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
get_cmd_version() {
if [ -z "$1" ]; then
return
fi
local cmd="$1"
if command -v "$cmd" 2>&1 >/dev/null; then
ver=$("$cmd" --version 2> /dev/null | head -n 1)
# some tools (eg. openocd) print version info to stderr
if [ -z "$ver" ]; then
ver=$("$cmd" --version 2>&1 | head -n 1)
fi
if [ -z "$ver" ]; then
ver="error"
fi
else
ver="missing"
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
fi
printf "%s" "$line"
}
newlib_version() {
if [ -z "$1" ]; then
printf "%s" "error"
else
local cc="$1"
printf "%s" "$(get_define "$cc" newlib.h _NEWLIB_VERSION)"
fi
}
avr_libc_version() {
if [ -z "$1" ]; then
printf "%s" "error"
else
local cc="$1"
printf "%s (%s)" "$(get_define "$cc" avr/version.h __AVR_LIBC_VERSION_STRING__)" "$(get_define "$cc" avr/version.h __AVR_LIBC_DATE_STRING__)"
fi
}
printf "%s\n" "Installed compiler toolchains "
printf "%s\n" "-----------------------------"
printf "%23s: %s\n" "native gcc" "$(get_cmd_version gcc)"
for p in arm-none-eabi avr mips-mti-elf msp430 riscv-none-embed; do
printf "%23s: %s\n" "$p-gcc" "$(get_cmd_version ${p}-gcc)"
done
printf "%23s: %s\n" "clang" "$(get_cmd_version clang)"
printf "\n"
printf "%s\n" "Installed compiler libs"
printf "%s\n" "-----------------------"
# platform specific newlib version
for p in arm-none-eabi mips-mti-elf riscv-none-embed; do
printf "%23s: %s\n" "$p-newlib" "$(newlib_version ${p}-gcc)"
done
# avr libc version
printf "%23s: %s\n" "avr-libc" "$(avr_libc_version avr-gcc)"
# tools
printf "\n"
printf "%s\n" "Installed development tools"
printf "%s\n" "---------------------------"
for c in cmake cppcheck doxygen flake8 git; do
printf "%23s: %s\n" "$c" "$(get_cmd_version $c)"
done
printf "%23s: %s\n" "coccinelle" "$(get_cmd_version spatch)"
exit 0