scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Nov 25 23:40:25 2009 +0100 (2009-11-25)
changeset 1657 0da038fd747b
parent 1521 7563a985370b
child 1658 5eccb5e9b3eb
permissions -rwxr-xr-x
scripts: fix WiKi table generation

The number of column in the top-most header was not updated to reflect the
fact that a new column was added to show the host (for canadian crosses).
     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         printf "| ''${sample}''  "
    74         printf "|  "
    75         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X"
    76         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B"
    77         printf '  |  '
    78         case "${CT_TOOLCHAIN_TYPE}" in
    79             cross)      ;;
    80             canadian)   printf "${CT_HOST}";;
    81             *)          ;;
    82         esac
    83         printf "  |  ''${CT_KERNEL}''  |"
    84         if [ "${CT_KERNEL}" != "bare-metal" ];then
    85             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
    86                 printf "  //custom//  "
    87             else
    88                 printf "  ${CT_KERNEL_VERSION}  "
    89             fi
    90         fi
    91         printf "|  ${CT_BINUTILS_VERSION}  "
    92         printf "|  ''${CT_CC}''  "
    93         printf "|  ${CT_CC_VERSION}  "
    94         printf "|  ''${CT_LIBC}''  |"
    95         if [ "${CT_LIBC}" != "none" ]; then
    96             printf "  ${CT_LIBC_VERSION}  "
    97         fi
    98         printf "|  ${CT_THREADS:-none}  "
    99         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
   100         printf "|  C"
   101         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
   102         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
   103         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   104         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   105         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   106         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   107         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   108         printf "  "
   109         ( . "${sample_top}/samples/${sample}/reported.by"
   110           if [ -n "${reporter_name}" ]; then
   111               if [ -n "${reporter_url}" ]; then
   112                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   113               else
   114                   printf "|  ${reporter_name}  "
   115               fi
   116           else
   117               printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
   118           fi
   119         )
   120         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   121         printf "|  ${sample_updated}  "
   122         echo "|"
   123     fi
   124 }
   125 
   126 # Get largest sample width
   127 width=0
   128 for sample in "${@}"; do
   129     [ ${#sample} -gt ${width} ] && width=${#sample}
   130 done
   131 
   132 if [ "${opt}" = -w ]; then
   133     echo "^ @@DATE@@  |||||||||||||||"
   134     printf "^ Target "
   135     printf "^  Status  "
   136     printf "^  Host  "
   137     printf "^  Kernel headers\\\\\\\\ version  ^"
   138     printf "^  binutils\\\\\\\\ version  "
   139     printf "^  C compiler\\\\\\\\ version  ^"
   140     printf "^  C library\\\\\\\\ version  ^"
   141     printf "^  Threading\\\\\\\\ model  "
   142     printf "^  Floating point\\\\\\\\ support  "
   143     printf "^  Languages  "
   144     printf "^  Initially\\\\\\\\ reported by  "
   145     printf "^  Last\\\\\\\\ updated  "
   146     echo   "^"
   147 fi
   148 
   149 for sample in "${@}"; do
   150     ( dump_single_sample ${opt} ${width} "${sample}" )
   151 done
   152 
   153 if [ "${opt}" = -w ]; then
   154     printf "^ Total: ${#@} samples  | ''X'': sample uses features marked as being EXPERIMENTAL.\\\\\\\\ ''B'': sample is curently BROKEN. ||||||||||||||"
   155     echo   ""
   156 elif [ -z "${opt}" ]; then
   157     echo '      l (local)       : sample was found in current directory'
   158     echo '      g (global)      : sample was installed with crosstool-NG'
   159     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   160     echo '      B (BROKEN)      : sample is currently broken'
   161 fi