scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Mar 17 23:59:17 2010 +0100 (2010-03-17)
changeset 1845 085683652f7e
parent 1808 a1370757e6a1
child 1846 4220dec659c6
permissions -rwxr-xr-x
scripts: fix dumping config

libelf has been moved to being a companion library, now.
     1 #!/bin/sh
     2 # Yes, this is supposed to be a POSIX-compliant shell script.
     3 
     4 # Parses all samples on the command line, and for each of them, prints
     5 # the versions of the main tools
     6 
     7 # Use tools discovered by ./configure
     8 . "${CT_LIB_DIR}/paths.mk"
     9 
    10 [ "$1" = "-v" ] && opt="$1" && shift
    11 [ "$1" = "-w" ] && opt="$1" && shift
    12 
    13 # GREP_OPTIONS screws things up.
    14 export GREP_OPTIONS=
    15 
    16 # Dump a single sample
    17 dump_single_sample() {
    18     local verbose=0
    19     local complibs
    20     [ "$1" = "-v" ] && verbose=1 && shift
    21     [ "$1" = "-w" ] && wiki=1 && shift
    22     local width="$1"
    23     local sample="$2"
    24     case "${sample}" in
    25         current)
    26             sample_type="l"
    27             sample="${current_tuple}"
    28             width="${#sample}"
    29             . $(pwd)/.config
    30             ;;
    31         *)  if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    32                 sample_top="${CT_TOP_DIR}"
    33                 sample_type="l"
    34             else
    35                 sample_top="${CT_LIB_DIR}"
    36                 sample_type="g"
    37             fi
    38             . "${sample_top}/samples/${sample}/crosstool.config"
    39             ;;
    40     esac
    41     if [ -z "${wiki}" ]; then
    42         t_width=14
    43         printf "%-*s  [%s" ${width} "${sample}" "${sample_type}"
    44         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    45         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    46         echo "]"
    47         if [ ${verbose} -ne 0 ]; then
    48             case "${CT_TOOLCHAIN_TYPE}" in
    49                 cross)  ;;
    50                 canadian)
    51                     printf "    %-*s : %s\n" ${t_width} "Host" "${CT_HOST}"
    52                     ;;
    53             esac
    54             printf "    %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
    55             if [    -n "${CT_GMP}"              \
    56                  -o -n "${CT_MPFR}"             \
    57                  -o -n "${CT_PPL}"              \
    58                  -o -n "${CT_CLOOG}"            \
    59                  -o -n "${CT_MPC}"              \
    60                  -o -n "${CT_LIBELF}"           \
    61                ]; then
    62                 printf "    %-*s :" ${t_width} "Companion libs"
    63                 complibs=1
    64             fi
    65             [ -z "${CT_GMP}"    ] || printf " gmp-%s"       "${CT_GMP_VERSION}"
    66             [ -z "${CT_MPFR}"   ] || printf " mpfr-%s"      "${CT_MPFR_VERSION}"
    67             [ -z "${CT_PPL}"    ] || printf " ppl-%s"       "${CT_PPL_VERSION}"
    68             [ -z "${CT_CLOOG}"  ] || printf " cloog-ppl-%s" "${CT_CLOOG_VERSION}"
    69             [ -z "${CT_MPC}"    ] || printf " mpc-%s"       "${CT_MPC_VERSION}"
    70             [ -z "${CT_LIBELF}" ] || printf " libelf-%s"    "${CT_LIBELF_VERSION}"
    71             [ -z "${complibs}"  ] || printf "\n"
    72             printf  "    %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
    73             printf  "    %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
    74             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    75             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    76             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    77             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    78             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    79             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    80             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    81             printf ")\n"
    82             printf  "    %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
    83             printf  "    %-*s :" ${t_width} "Tools"
    84             [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
    85             [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    86             [ "${CT_DEBUG_duma}"    ] && printf " duma-${CT_DUMA_VERSION}"
    87             [ "${CT_DEBUG_gdb}"     ] && printf " gdb-${CT_GDB_VERSION}"
    88             [ "${CT_DEBUG_ltrace}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    89             [ "${CT_DEBUG_strace}"  ] && printf " strace-${CT_STRACE_VERSION}"
    90             printf "\n"
    91         fi
    92     else
    93         case "${CT_TOOLCHAIN_TYPE}" in
    94             cross)
    95                 printf "| ''${sample}''  | "
    96                 ;;
    97             canadian)
    98                 printf "| ''"
    99                 printf "${sample}" |sed -r -e 's/.*,//'
   100                 printf "''  | ${CT_HOST}  "
   101                 ;;
   102             *)          ;;
   103         esac
   104         printf "|  "
   105         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**"
   106         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**"
   107         printf "  |  ''${CT_KERNEL}''  |"
   108         if [ "${CT_KERNEL}" != "bare-metal" ];then
   109             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
   110                 printf "  //custom//  "
   111             else
   112                 printf "  ${CT_KERNEL_VERSION}  "
   113             fi
   114         fi
   115         printf "|  ${CT_BINUTILS_VERSION}  "
   116         printf "|  ''${CT_CC}''  "
   117         printf "|  ${CT_CC_VERSION}  "
   118         printf "|  ''${CT_LIBC}''  |"
   119         if [ "${CT_LIBC}" != "none" ]; then
   120             printf "  ${CT_LIBC_VERSION}  "
   121         fi
   122         printf "|  ${CT_THREADS:-none}  "
   123         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
   124         printf "|  C"
   125         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
   126         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
   127         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   128         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   129         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   130         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   131         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   132         printf "  "
   133         ( . "${sample_top}/samples/${sample}/reported.by"
   134           if [ -n "${reporter_name}" ]; then
   135               if [ -n "${reporter_url}" ]; then
   136                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   137               else
   138                   printf "|  ${reporter_name}  "
   139               fi
   140           else
   141               printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
   142           fi
   143         )
   144         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   145         printf "|  ${sample_updated}  "
   146         echo "|"
   147     fi
   148 }
   149 
   150 # Get largest sample width
   151 width=0
   152 for sample in "${@}"; do
   153     [ ${#sample} -gt ${width} ] && width=${#sample}
   154 done
   155 
   156 if [ "${opt}" = -w ]; then
   157     printf "^ %s  |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
   158     printf "^ Target  "
   159     printf "^ Host  "
   160     printf "^  Status  "
   161     printf "^  Kernel headers\\\\\\\\ version  ^"
   162     printf "^  binutils\\\\\\\\ version  "
   163     printf "^  C compiler\\\\\\\\ version  ^"
   164     printf "^  C library\\\\\\\\ version  ^"
   165     printf "^  Threading\\\\\\\\ model  "
   166     printf "^  Floating point\\\\\\\\ support  "
   167     printf "^  Languages  "
   168     printf "^  Initially\\\\\\\\ reported by  "
   169     printf "^  Last\\\\\\\\ updated  "
   170     echo   "^"
   171 fi
   172 
   173 for sample in "${@}"; do
   174     ( dump_single_sample ${opt} ${width} "${sample}" )
   175 done
   176 
   177 if [ "${opt}" = -w ]; then
   178     printf "^ Total: ${#@} samples  || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is curently BROKEN. |||||||||||||"
   179     echo   ""
   180 elif [ -z "${opt}" ]; then
   181     echo '      l (local)       : sample was found in current directory'
   182     echo '      g (global)      : sample was installed with crosstool-NG'
   183     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   184     echo '      B (BROKEN)      : sample is currently broken'
   185 fi