output_env.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #! /usr/bin/env sh
  2. # output_env.sh
  3. #
  4. # Copyright The Mbed TLS Contributors
  5. # SPDX-License-Identifier: Apache-2.0
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. # not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. # Purpose
  20. #
  21. # To print out all the relevant information about the development environment.
  22. #
  23. # This includes:
  24. # - architecture of the system
  25. # - type and version of the operating system
  26. # - version of make and cmake
  27. # - version of armcc, clang, gcc-arm and gcc compilers
  28. # - version of libc, clang, asan and valgrind if installed
  29. # - version of gnuTLS and OpenSSL
  30. print_version()
  31. {
  32. BIN="$1"
  33. shift
  34. ARGS="$1"
  35. shift
  36. VARIANT="$1"
  37. shift
  38. if [ -n "$VARIANT" ]; then
  39. VARIANT=" ($VARIANT)"
  40. fi
  41. if ! type "$BIN" > /dev/null 2>&1; then
  42. echo " * ${BIN##*/}$VARIANT: Not found."
  43. return 0
  44. fi
  45. BIN=`which "$BIN"`
  46. VERSION_STR=`$BIN $ARGS 2>&1`
  47. # Apply all filters
  48. while [ $# -gt 0 ]; do
  49. FILTER="$1"
  50. shift
  51. VERSION_STR=`echo "$VERSION_STR" | $FILTER`
  52. done
  53. if [ -z "$VERSION_STR" ]; then
  54. VERSION_STR="Version could not be determined."
  55. fi
  56. echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} "
  57. }
  58. echo "** Platform:"
  59. echo
  60. if [ `uname -s` = "Linux" ]; then
  61. echo "Linux variant"
  62. lsb_release -d -c
  63. else
  64. echo "Unknown Unix variant"
  65. fi
  66. echo
  67. print_version "uname" "-a" ""
  68. echo
  69. echo
  70. echo "** Tool Versions:"
  71. echo
  72. print_version "make" "--version" "" "head -n 1"
  73. echo
  74. print_version "cmake" "--version" "" "head -n 1"
  75. echo
  76. if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
  77. : "${ARMC5_CC:=armcc}"
  78. print_version "$ARMC5_CC" "--vsn" "" "head -n 2"
  79. echo
  80. : "${ARMC6_CC:=armclang}"
  81. print_version "$ARMC6_CC" "--vsn" "" "head -n 2"
  82. echo
  83. fi
  84. print_version "arm-none-eabi-gcc" "--version" "" "head -n 1"
  85. echo
  86. print_version "gcc" "--version" "" "head -n 1"
  87. echo
  88. print_version "clang" "--version" "" "head -n 2"
  89. echo
  90. print_version "ldd" "--version" "" "head -n 1"
  91. echo
  92. print_version "valgrind" "--version" ""
  93. echo
  94. print_version "gdb" "--version" "" "head -n 1"
  95. echo
  96. print_version "perl" "--version" "" "head -n 2" "grep ."
  97. echo
  98. print_version "python" "--version" "" "head -n 1"
  99. echo
  100. print_version "python3" "--version" "" "head -n 1"
  101. echo
  102. # Find the installed version of Pylint. Installed as a distro package this can
  103. # be pylint3 and as a PEP egg, pylint. In test scripts We prefer pylint over
  104. # pylint3
  105. if type pylint >/dev/null 2>/dev/null; then
  106. print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
  107. elif type pylint3 >/dev/null 2>/dev/null; then
  108. print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
  109. else
  110. echo " * pylint or pylint3: Not found."
  111. fi
  112. echo
  113. : ${OPENSSL:=openssl}
  114. print_version "$OPENSSL" "version" "default"
  115. echo
  116. if [ -n "${OPENSSL_LEGACY+set}" ]; then
  117. print_version "$OPENSSL_LEGACY" "version" "legacy"
  118. else
  119. echo " * openssl (legacy): Not configured."
  120. fi
  121. echo
  122. if [ -n "${OPENSSL_NEXT+set}" ]; then
  123. print_version "$OPENSSL_NEXT" "version" "next"
  124. else
  125. echo " * openssl (next): Not configured."
  126. fi
  127. echo
  128. : ${GNUTLS_CLI:=gnutls-cli}
  129. print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
  130. echo
  131. : ${GNUTLS_SERV:=gnutls-serv}
  132. print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
  133. echo
  134. if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
  135. print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
  136. else
  137. echo " * gnutls-cli (legacy): Not configured."
  138. fi
  139. echo
  140. if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
  141. print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
  142. else
  143. echo " * gnutls-serv (legacy): Not configured."
  144. fi
  145. echo
  146. echo " * Installed asan versions:"
  147. if type dpkg-query >/dev/null 2>/dev/null; then
  148. if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
  149. awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
  150. grep .
  151. then
  152. echo " No asan versions installed."
  153. fi
  154. else
  155. echo " Unable to determine the asan version without dpkg."
  156. fi
  157. echo