scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Sep 02 21:14:47 2008 +0000 (2008-09-02)
changeset 825 7e90583334e0
parent 822 04a1937d5f0b
child 828 f11e2ba89d7f
permissions -rwxr-xr-x
Beautify samples listing.

/trunk/scripts/showSamples.sh | 8 4 4 0 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
     1 #!/bin/bash
     2 
     3 # Parses all samples on the command line, and for each of them, prints
     4 # the versions of the main tools
     5 
     6 [ "$1" = "-v" ] && opt="$1" && shift
     7 [ "$1" = "-w" ] && opt="$1" && shift
     8 
     9 # GREP_OPTIONS screws things up.
    10 export GREP_OPTIONS=
    11 
    12 # Dump a single sample
    13 dump_single_sample() {
    14     local verbose=0
    15     [ "$1" = "-v" ] && verbose=1 && shift
    16     [ "$1" = "-w" ] && wiki=1 && shift
    17     local width="$1"
    18     local sample="$2"
    19     if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    20         sample_top="${CT_TOP_DIR}"
    21         sample_type="l"
    22     else
    23         sample_top="${CT_LIB_DIR}"
    24         sample_type="g"
    25     fi
    26     . "${sample_top}/samples/${sample}/crosstool.config"
    27     if [ -z "${wiki}" ]; then
    28         printf "  %-*s  [%s" ${width} "${sample}" "${sample_type}"
    29         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    30         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    31         echo "]"
    32         if [ ${verbose} -ne 0 ]; then
    33             echo    "    OS        : ${CT_KERNEL}-${CT_KERNEL_VERSION}"
    34             if [ "${CT_GMP_MPFR}" = "y" ]; then
    35                 echo    "    GMP/MPFR  : gmp-${CT_GMP_VERSION} / mpfr-${CT_MPFR_VERSION}"
    36             fi
    37             echo    "    binutils  : binutils-${CT_BINUTILS_VERSION}"
    38             printf  "    C compiler: ${CT_CC}-${CT_CC_VERSION} (C"
    39             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    40             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    41             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    42             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    43             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    44             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    45             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    46             echo    ")"
    47             echo    "    C library : ${CT_LIBC}-${CT_LIBC_VERSION}"
    48             printf  "    Tools     :"
    49             [ "${CT_LIBELF}"  ] && printf " libelf-${CT_LIBELF_VERSION}"
    50             [ "${CT_SSTRIP}"  ] && printf " sstrip"
    51             [ "${CT_DMALLOC}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    52             [ "${CT_DUMA}"    ] && printf " duma-${CT_DUMA_VERSION}"
    53             [ "${CT_GDB}"     ] && printf " gdb-${CT_GDB_VERSION}"
    54             [ "${CT_LTRACE}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    55             [ "${CT_STRACE}"  ] && printf " strace-${CT_STRACE_VERSION}"
    56             echo
    57         fi
    58     else
    59         printf "| ''${sample}''  "
    60         printf "|  ''${CT_KERNEL}''  "
    61         if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
    62             printf "|  //custom//  "
    63         else
    64             printf "|  ${CT_KERNEL_VERSION}  "
    65         fi
    66         printf "|  ${CT_BINUTILS_VERSION}  "
    67         printf "|  ''${CT_CC}''  "
    68         printf "|  ${CT_CC_VERSION}  "
    69         printf "|  ''${CT_LIBC}''  "
    70         printf "|  ${CT_LIBC_VERSION}  "
    71         printf "|  ${CT_THREADS_NPTL:+NPTL}${CT_THREADS_LINUXTHREADS:+linuxthreads}${CT_THREADS_NONE:+none}  "
    72         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
    73         printf "|  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 "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
    81         printf "  "
    82         if [ -f "${sample_top}/samples/${sample}/reported.by" ]; then
    83             ( . "${sample_top}/samples/${sample}/reported.by"
    84               if [ -n "${reporter_url}" ]; then
    85                   printf "|  [[${reporter_url}|${reporter_name}]]  "
    86               else
    87                   printf "|  ${reporter_name}  "
    88               fi
    89             )
    90         else
    91             printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
    92         fi
    93         sample_updated=$(date -u "+%Y%m%d"                                                  \
    94                               -d "$(LC_ALL=C svn info ${sample_top}/samples/${sample}       \
    95                                     |GREP_OPTIONS= egrep '^Last Changed Date:'              \
    96                                     |sed -r -e 's/^[^:]+: //;'                              \
    97                                             -e 's/^(.+:.. [+-][[:digit:]]{4}) \(.+\)$/\1/;' \
    98                                    )"                                                       \
    99                         )
   100         printf "|  ${sample_updated}  "
   101         echo "|"
   102     fi
   103 }
   104 
   105 # Get largest sample width
   106 width=0
   107 for sample in "${@}"; do
   108     [ ${#sample} -gt ${width} ] && width=${#sample}
   109 done
   110 
   111 if [ "${opt}" = -w ]; then
   112     echo "^ @@DATE@@  ^ ||||||||||||"
   113     printf "^ Target "
   114     printf "^  Kernel headers\\\\\\\\ version  ^"
   115     printf "^  binutils version  "
   116     printf "^  C compiler\\\\\\\\ version  ^"
   117     printf "^  C library version  ^"
   118     printf "^  Threading model  "
   119     printf "^  Floating point\\\\\\\\ support  "
   120     printf "^  Languages  "
   121     printf "^  Initially\\\\\\\\ reported by  "
   122     printf "^  Last\\\\\\\\ updated  "
   123     echo   "^"
   124 fi
   125 
   126 for sample in "${@}"; do
   127     ( dump_single_sample ${opt} ${width} "${sample}" )
   128 done
   129 
   130 if [ "${opt}" = -w ]; then
   131     printf "^ Total: ${#@} samples  | ||||||||||||"
   132     echo   ""
   133 elif [ -z "${opt}" ]; then
   134     echo '      l (local)       : sample was found in current directory'
   135     echo '      g (global)      : sample was installed with crosstool-NG'
   136     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   137     echo '      B (BORKEN)      : sample is currently broken'
   138 fi