scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jan 12 19:24:03 2010 +0100 (2010-01-12)
changeset 1761 88020b2c3246
parent 1659 5f26745a915c
child 1788 9547490131d9
permissions -rwxr-xr-x
scripts/functions: change handling of nochdir

- 'nochdir' must be the first option
- have systematic pushd/popd, even if nochdir
     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     [ "$1" = "-v" ] && verbose=1 && shift
    20     [ "$1" = "-w" ] && wiki=1 && shift
    21     local width="$1"
    22     local sample="$2"
    23     if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    24         sample_top="${CT_TOP_DIR}"
    25         sample_type="l"
    26     else
    27         sample_top="${CT_LIB_DIR}"
    28         sample_type="g"
    29     fi
    30     . "${sample_top}/samples/${sample}/crosstool.config"
    31     if [ -z "${wiki}" ]; then
    32         t_width=13
    33         printf "%-*s  [%s" ${width} "${sample}" "${sample_type}"
    34         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    35         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    36         echo "]"
    37         if [ ${verbose} -ne 0 ]; then
    38             case "${CT_TOOLCHAIN_TYPE}" in
    39                 cross)  ;;
    40                 canadian)
    41                     printf "    %-*s : %s\n" ${t_width} "Host" "${CT_HOST}"
    42                     ;;
    43             esac
    44             printf "    %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
    45             if [ "${CT_GMP_MPFR}" = "y" ]; then
    46                 printf    "    %-*s : %s\n" ${t_width} "GMP/MPFR" "gmp-${CT_GMP_VERSION} / mpfr-${CT_MPFR_VERSION}"
    47             fi
    48             if [ "${CT_PPL_CLOOG_MPC}" = "y" ]; then
    49                 printf    "    %-*s : %s\n" ${t_width} "PPL/CLOOG/MPC" "ppl-${CT_PPL_VERSION} / cloog-${CT_CLOOG_VERSION} / mpc-${CT_MPC_VERSION}"
    50             fi
    51             printf  "    %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
    52             printf  "    %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
    53             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    54             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    55             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    56             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    57             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    58             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    59             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    60             printf ")\n"
    61             printf  "    %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
    62             printf  "    %-*s :" ${t_width} "Tools"
    63             [ "${CT_TOOL_libelf}"   ] && printf " libelf-${CT_LIBELF_VERSION}"
    64             [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
    65             [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    66             [ "${CT_DEBUG_duma}"    ] && printf " duma-${CT_DUMA_VERSION}"
    67             [ "${CT_DEBUG_gdb}"     ] && printf " gdb-${CT_GDB_VERSION}"
    68             [ "${CT_DEBUG_ltrace}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    69             [ "${CT_DEBUG_strace}"  ] && printf " strace-${CT_STRACE_VERSION}"
    70             printf "\n"
    71         fi
    72     else
    73         case "${CT_TOOLCHAIN_TYPE}" in
    74             cross)
    75                 printf "| ''${sample}''  | "
    76                 ;;
    77             canadian)
    78                 printf "| ''"
    79                 printf "${sample}" |sed -r -e 's/.*,//'
    80                 printf "''  | ${CT_HOST}  "
    81                 ;;
    82             *)          ;;
    83         esac
    84         printf "|  "
    85         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**"
    86         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**"
    87         printf "  |  ''${CT_KERNEL}''  |"
    88         if [ "${CT_KERNEL}" != "bare-metal" ];then
    89             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
    90                 printf "  //custom//  "
    91             else
    92                 printf "  ${CT_KERNEL_VERSION}  "
    93             fi
    94         fi
    95         printf "|  ${CT_BINUTILS_VERSION}  "
    96         printf "|  ''${CT_CC}''  "
    97         printf "|  ${CT_CC_VERSION}  "
    98         printf "|  ''${CT_LIBC}''  |"
    99         if [ "${CT_LIBC}" != "none" ]; then
   100             printf "  ${CT_LIBC_VERSION}  "
   101         fi
   102         printf "|  ${CT_THREADS:-none}  "
   103         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
   104         printf "|  C"
   105         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
   106         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
   107         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   108         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   109         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   110         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   111         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   112         printf "  "
   113         ( . "${sample_top}/samples/${sample}/reported.by"
   114           if [ -n "${reporter_name}" ]; then
   115               if [ -n "${reporter_url}" ]; then
   116                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   117               else
   118                   printf "|  ${reporter_name}  "
   119               fi
   120           else
   121               printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
   122           fi
   123         )
   124         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   125         printf "|  ${sample_updated}  "
   126         echo "|"
   127     fi
   128 }
   129 
   130 # Get largest sample width
   131 width=0
   132 for sample in "${@}"; do
   133     [ ${#sample} -gt ${width} ] && width=${#sample}
   134 done
   135 
   136 if [ "${opt}" = -w ]; then
   137     printf "^ %s  |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
   138     printf "^ Target  "
   139     printf "^ Host  "
   140     printf "^  Status  "
   141     printf "^  Kernel headers\\\\\\\\ version  ^"
   142     printf "^  binutils\\\\\\\\ version  "
   143     printf "^  C compiler\\\\\\\\ version  ^"
   144     printf "^  C library\\\\\\\\ version  ^"
   145     printf "^  Threading\\\\\\\\ model  "
   146     printf "^  Floating point\\\\\\\\ support  "
   147     printf "^  Languages  "
   148     printf "^  Initially\\\\\\\\ reported by  "
   149     printf "^  Last\\\\\\\\ updated  "
   150     echo   "^"
   151 fi
   152 
   153 for sample in "${@}"; do
   154     ( dump_single_sample ${opt} ${width} "${sample}" )
   155 done
   156 
   157 if [ "${opt}" = -w ]; then
   158     printf "^ Total: ${#@} samples  || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is curently BROKEN. |||||||||||||"
   159     echo   ""
   160 elif [ -z "${opt}" ]; then
   161     echo '      l (local)       : sample was found in current directory'
   162     echo '      g (global)      : sample was installed with crosstool-NG'
   163     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   164     echo '      B (BROKEN)      : sample is currently broken'
   165 fi