From 001a30ef4fabd9323addb01d9b649e0224687ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Tue, 17 Jan 2017 12:46:04 +0100 Subject: [PATCH] dist/tools/ci: Add script for printing installed toolchain versions to CI log --- dist/tools/ci/build_and_test.sh | 2 + dist/tools/ci/print_toolchain_versions.sh | 69 +++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 dist/tools/ci/print_toolchain_versions.sh diff --git a/dist/tools/ci/build_and_test.sh b/dist/tools/ci/build_and_test.sh index 4a9aba395..cfe7eccf0 100755 --- a/dist/tools/ci/build_and_test.sh +++ b/dist/tools/ci/build_and_test.sh @@ -78,6 +78,8 @@ then exit $RESULT fi + run ./dist/tools/ci/print_toolchain_versions.sh + run ./dist/tools/whitespacecheck/check.sh ${CI_BASE_BRANCH} run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0 run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=AC diff --git a/dist/tools/ci/print_toolchain_versions.sh b/dist/tools/ci/print_toolchain_versions.sh new file mode 100755 index 000000000..9d39938de --- /dev/null +++ b/dist/tools/ci/print_toolchain_versions.sh @@ -0,0 +1,69 @@ +#!/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__)" +} + +printf "Installed toolchain versions:\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; 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; 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 +exit 0