scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Feb 13 21:47:25 2012 +0100 (2012-02-13)
changeset 2883 cea814c9932a
parent 2762 fabae8fa6187
child 2982 1e35d2fa54d7
permissions -rwxr-xr-x
libc/glibc: do not consume parameters when parsing them

Currently, there are two constructs used to parse arguments in
glibc backends, one that consumes args as they are parsed, and
one that does not.

Always use the construct that does not eat args as they are parsed.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     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.sh"
     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 # Note: we can quite safely used the non-mangled .config.2
    18 dump_single_sample() {
    19     local verbose=0
    20     local complibs
    21     [ "$1" = "-v" ] && verbose=1 && shift
    22     [ "$1" = "-w" ] && wiki=1 && shift
    23     local width="$1"
    24     local sample="$2"
    25     case "${sample}" in
    26         current)
    27             sample_type="l"
    28             sample="${current_tuple}"
    29             width="${#sample}"
    30             . $(pwd)/.config
    31             ;;
    32         *)  if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    33                 sample_top="${CT_TOP_DIR}"
    34                 sample_type="L"
    35             else
    36                 sample_top="${CT_LIB_DIR}"
    37                 sample_type="G"
    38             fi
    39             . "${sample_top}/samples/${sample}/crosstool.config"
    40             ;;
    41     esac
    42     if [ -z "${wiki}" ]; then
    43         t_width=14
    44         printf "%-*s  [%s" ${width} "${sample}" "${sample_type}"
    45         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    46         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    47         echo "]"
    48         if [ ${verbose} -ne 0 ]; then
    49             case "${CT_TOOLCHAIN_TYPE}" in
    50                 cross)  ;;
    51                 canadian)
    52                     printf "    %-*s : %s\n" ${t_width} "Host" "${CT_HOST}"
    53                     ;;
    54             esac
    55             printf "    %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
    56             if [    -n "${CT_GMP}"              \
    57                  -o -n "${CT_MPFR}"             \
    58                  -o -n "${CT_PPL}"              \
    59                  -o -n "${CT_CLOOG}"            \
    60                  -o -n "${CT_MPC}"              \
    61                  -o -n "${CT_LIBELF}"           \
    62                  -o -n "${CT_GMP_TARGET}"       \
    63                  -o -n "${CT_MPFR_TARGET}"      \
    64                  -o -n "${CT_PPL_TARGET}"       \
    65                  -o -n "${CT_CLOOG_TARGET}"     \
    66                  -o -n "${CT_MPC_TARGET}"       \
    67                  -o -n "${CT_LIBELF_TARGET}"    \
    68                ]; then
    69                 printf "    %-*s :" ${t_width} "Companion libs"
    70                 complibs=1
    71             fi
    72             [ -z "${CT_GMP}"    -a -z "${CT_GMP_TARGET}"    ] || printf " gmp-%s"       "${CT_GMP_VERSION}"
    73             [ -z "${CT_MPFR}"   -a -z "${CT_MPFR_TARGET}"   ] || printf " mpfr-%s"      "${CT_MPFR_VERSION}"
    74             [ -z "${CT_PPL}"    -a -z "${CT_PPL_TARGET}"    ] || printf " ppl-%s"       "${CT_PPL_VERSION}"
    75             [ -z "${CT_CLOOG}"  -a -z "${CT_CLOOG_TARGET}"  ] || printf " cloog-ppl-%s" "${CT_CLOOG_VERSION}"
    76             [ -z "${CT_MPC}"    -a -z "${CT_MPC_TARGET}"    ] || printf " mpc-%s"       "${CT_MPC_VERSION}"
    77             [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s"    "${CT_LIBELF_VERSION}"
    78             [ -z "${complibs}"  ] || printf "\n"
    79             printf  "    %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
    80             printf  "    %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
    81             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    82             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    83             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    84             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    85             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    86             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    87             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    88             printf ")\n"
    89             printf  "    %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
    90             printf  "    %-*s :" ${t_width} "Tools"
    91             [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
    92             [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    93             [ "${CT_DEBUG_duma}"    ] && printf " duma-${CT_DUMA_VERSION}"
    94             [ "${CT_DEBUG_gdb}"     ] && printf " gdb-${CT_GDB_VERSION}"
    95             [ "${CT_DEBUG_ltrace}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    96             [ "${CT_DEBUG_strace}"  ] && printf " strace-${CT_STRACE_VERSION}"
    97             printf "\n"
    98         fi
    99     else
   100         case "${CT_TOOLCHAIN_TYPE}" in
   101             cross)
   102                 printf "| ''${sample}''  | "
   103                 ;;
   104             canadian)
   105                 printf "| ''"
   106                 printf "${sample}" |sed -r -e 's/.*,//'
   107                 printf "''  | ${CT_HOST}  "
   108                 ;;
   109             *)          ;;
   110         esac
   111         printf "|  "
   112         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**"
   113         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**"
   114         printf "  |  ''${CT_KERNEL}''  |"
   115         if [ "${CT_KERNEL}" != "bare-metal" ];then
   116             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
   117                 printf "  //custom//  "
   118             else
   119                 printf "  ${CT_KERNEL_VERSION}  "
   120             fi
   121         fi
   122         printf "|  ${CT_BINUTILS_VERSION}  "
   123         printf "|  ''${CT_CC}''  "
   124         printf "|  ${CT_CC_VERSION}  "
   125         printf "|  ''${CT_LIBC}''  |"
   126         if [ "${CT_LIBC}" != "none" ]; then
   127             printf "  ${CT_LIBC_VERSION}  "
   128         fi
   129         printf "|  ${CT_THREADS:-none}  "
   130         printf "|  ${CT_ARCH_FLOAT}  "
   131         printf "|  C"
   132         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
   133         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
   134         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   135         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   136         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   137         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   138         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   139         printf "  "
   140         ( . "${sample_top}/samples/${sample}/reported.by"
   141           if [ -n "${reporter_name}" ]; then
   142               if [ -n "${reporter_url}" ]; then
   143                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   144               else
   145                   printf "|  ${reporter_name}  "
   146               fi
   147           else
   148               printf "|  (//unknown//)  "
   149           fi
   150         )
   151         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   152         printf "|  ${sample_updated}  "
   153         echo "|"
   154     fi
   155 }
   156 
   157 # Get largest sample width
   158 width=0
   159 for sample in "${@}"; do
   160     [ ${#sample} -gt ${width} ] && width=${#sample}
   161 done
   162 
   163 if [ "${opt}" = -w ]; then
   164     printf "^ %s  |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
   165     printf "^ Target  "
   166     printf "^ Host  "
   167     printf "^  Status  "
   168     printf "^  Kernel headers\\\\\\\\ version  ^"
   169     printf "^  binutils\\\\\\\\ version  "
   170     printf "^  C compiler\\\\\\\\ version  ^"
   171     printf "^  C library\\\\\\\\ version  ^"
   172     printf "^  Threading\\\\\\\\ model  "
   173     printf "^  Floating point\\\\\\\\ support  "
   174     printf "^  Languages  "
   175     printf "^  Initially\\\\\\\\ reported by  "
   176     printf "^  Last\\\\\\\\ updated  "
   177     echo   "^"
   178 elif [ -z "${opt}" ]; then
   179     printf "%-*s  Status\n" ${width} "Sample name"
   180 fi
   181 
   182 for sample in "${@}"; do
   183     ( dump_single_sample ${opt} ${width} "${sample}" )
   184 done
   185 
   186 if [ "${opt}" = -w ]; then
   187     printf "^ Total: ${#@} samples  || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is currently BROKEN. |||||||||||||"
   188     echo   ""
   189 elif [ -z "${opt}" ]; then
   190     echo '      L (Local)       : sample was found in current directory'
   191     echo '      G (Global)      : sample was installed with crosstool-NG'
   192     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   193     echo '      B (BROKEN)      : sample is currently broken'
   194 fi