scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Wed Feb 08 00:44:52 2012 +0100 (2012-02-08)
branch1.14
changeset 2871 1e090655c6ab
parent 2762 fabae8fa6187
child 2982 1e35d2fa54d7
permissions -rwxr-xr-x
1.14: update version to 1.14.1
yann@1188
     1
#!/bin/sh
yann@1188
     2
# Yes, this is supposed to be a POSIX-compliant shell script.
yann@74
     3
yann@74
     4
# Parses all samples on the command line, and for each of them, prints
yann@74
     5
# the versions of the main tools
yann@74
     6
yann@1188
     7
# Use tools discovered by ./configure
yann@2838
     8
. "${CT_LIB_DIR}/paths.sh"
yann@1188
     9
yann@560
    10
[ "$1" = "-v" ] && opt="$1" && shift
yann@560
    11
[ "$1" = "-w" ] && opt="$1" && shift
yann@474
    12
yann@74
    13
# GREP_OPTIONS screws things up.
yann@74
    14
export GREP_OPTIONS=
yann@74
    15
yann@74
    16
# Dump a single sample
yann@2468
    17
# Note: we can quite safely used the non-mangled .config.2
yann@74
    18
dump_single_sample() {
yann@474
    19
    local verbose=0
yann@1808
    20
    local complibs
yann@474
    21
    [ "$1" = "-v" ] && verbose=1 && shift
yann@560
    22
    [ "$1" = "-w" ] && wiki=1 && shift
yann@74
    23
    local width="$1"
yann@74
    24
    local sample="$2"
yann@1788
    25
    case "${sample}" in
yann@1788
    26
        current)
yann@1788
    27
            sample_type="l"
yann@1789
    28
            sample="${current_tuple}"
yann@1789
    29
            width="${#sample}"
yann@1804
    30
            . $(pwd)/.config
yann@1788
    31
            ;;
yann@1788
    32
        *)  if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
yann@1788
    33
                sample_top="${CT_TOP_DIR}"
yann@1876
    34
                sample_type="L"
yann@1788
    35
            else
yann@1788
    36
                sample_top="${CT_LIB_DIR}"
yann@1876
    37
                sample_type="G"
yann@1788
    38
            fi
yann@1788
    39
            . "${sample_top}/samples/${sample}/crosstool.config"
yann@1788
    40
            ;;
yann@1788
    41
    esac
yann@560
    42
    if [ -z "${wiki}" ]; then
yann@1808
    43
        t_width=14
yann@1682
    44
        printf "%-*s  [%s" ${width} "${sample}" "${sample_type}"
yann@825
    45
        [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
yann@825
    46
        [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
yann@825
    47
        echo "]"
yann@560
    48
        if [ ${verbose} -ne 0 ]; then
yann@1427
    49
            case "${CT_TOOLCHAIN_TYPE}" in
yann@1427
    50
                cross)  ;;
yann@1427
    51
                canadian)
yann@1519
    52
                    printf "    %-*s : %s\n" ${t_width} "Host" "${CT_HOST}"
yann@1427
    53
                    ;;
yann@1427
    54
            esac
yann@1519
    55
            printf "    %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
yann@1845
    56
            if [    -n "${CT_GMP}"              \
yann@1845
    57
                 -o -n "${CT_MPFR}"             \
yann@1845
    58
                 -o -n "${CT_PPL}"              \
yann@1845
    59
                 -o -n "${CT_CLOOG}"            \
yann@1845
    60
                 -o -n "${CT_MPC}"              \
yann@1845
    61
                 -o -n "${CT_LIBELF}"           \
yann@1846
    62
                 -o -n "${CT_GMP_TARGET}"       \
yann@1846
    63
                 -o -n "${CT_MPFR_TARGET}"      \
yann@1846
    64
                 -o -n "${CT_PPL_TARGET}"       \
yann@1846
    65
                 -o -n "${CT_CLOOG_TARGET}"     \
yann@1846
    66
                 -o -n "${CT_MPC_TARGET}"       \
yann@1846
    67
                 -o -n "${CT_LIBELF_TARGET}"    \
yann@1808
    68
               ]; then
yann@1808
    69
                printf "    %-*s :" ${t_width} "Companion libs"
yann@1808
    70
                complibs=1
yann@807
    71
            fi
yann@1846
    72
            [ -z "${CT_GMP}"    -a -z "${CT_GMP_TARGET}"    ] || printf " gmp-%s"       "${CT_GMP_VERSION}"
yann@1846
    73
            [ -z "${CT_MPFR}"   -a -z "${CT_MPFR_TARGET}"   ] || printf " mpfr-%s"      "${CT_MPFR_VERSION}"
yann@1846
    74
            [ -z "${CT_PPL}"    -a -z "${CT_PPL_TARGET}"    ] || printf " ppl-%s"       "${CT_PPL_VERSION}"
yann@1846
    75
            [ -z "${CT_CLOOG}"  -a -z "${CT_CLOOG_TARGET}"  ] || printf " cloog-ppl-%s" "${CT_CLOOG_VERSION}"
yann@1846
    76
            [ -z "${CT_MPC}"    -a -z "${CT_MPC_TARGET}"    ] || printf " mpc-%s"       "${CT_MPC_VERSION}"
yann@1846
    77
            [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s"    "${CT_LIBELF_VERSION}"
yann@1808
    78
            [ -z "${complibs}"  ] || printf "\n"
yann@1519
    79
            printf  "    %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
yann@1519
    80
            printf  "    %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
yann@642
    81
            [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
yann@642
    82
            [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
yann@642
    83
            [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
yann@642
    84
            [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
yann@642
    85
            [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
yann@642
    86
            [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
yann@649
    87
            [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
yann@1519
    88
            printf ")\n"
yann@1519
    89
            printf  "    %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
yann@1519
    90
            printf  "    %-*s :" ${t_width} "Tools"
yann@1520
    91
            [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
yann@1520
    92
            [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
yann@1520
    93
            [ "${CT_DEBUG_duma}"    ] && printf " duma-${CT_DUMA_VERSION}"
yann@1520
    94
            [ "${CT_DEBUG_gdb}"     ] && printf " gdb-${CT_GDB_VERSION}"
yann@1520
    95
            [ "${CT_DEBUG_ltrace}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
yann@1520
    96
            [ "${CT_DEBUG_strace}"  ] && printf " strace-${CT_STRACE_VERSION}"
yann@1519
    97
            printf "\n"
yann@560
    98
        fi
yann@560
    99
    else
yann@1658
   100
        case "${CT_TOOLCHAIN_TYPE}" in
yann@1658
   101
            cross)
yann@1658
   102
                printf "| ''${sample}''  | "
yann@1658
   103
                ;;
yann@1658
   104
            canadian)
yann@1658
   105
                printf "| ''"
yann@1658
   106
                printf "${sample}" |sed -r -e 's/.*,//'
yann@1658
   107
                printf "''  | ${CT_HOST}  "
yann@1658
   108
                ;;
yann@1658
   109
            *)          ;;
yann@1658
   110
        esac
yann@828
   111
        printf "|  "
yann@1659
   112
        [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**"
yann@1659
   113
        [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**"
yann@1427
   114
        printf "  |  ''${CT_KERNEL}''  |"
yann@1026
   115
        if [ "${CT_KERNEL}" != "bare-metal" ];then
yann@1026
   116
            if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
yann@1026
   117
                printf "  //custom//  "
yann@1026
   118
            else
yann@1026
   119
                printf "  ${CT_KERNEL_VERSION}  "
yann@1026
   120
            fi
yann@722
   121
        fi
yann@642
   122
        printf "|  ${CT_BINUTILS_VERSION}  "
yann@691
   123
        printf "|  ''${CT_CC}''  "
yann@642
   124
        printf "|  ${CT_CC_VERSION}  "
yann@1026
   125
        printf "|  ''${CT_LIBC}''  |"
yann@1026
   126
        if [ "${CT_LIBC}" != "none" ]; then
yann@1026
   127
            printf "  ${CT_LIBC_VERSION}  "
yann@1026
   128
        fi
yann@1026
   129
        printf "|  ${CT_THREADS:-none}  "
yann@2762
   130
        printf "|  ${CT_ARCH_FLOAT}  "
yann@649
   131
        printf "|  C"
yann@649
   132
        [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
yann@649
   133
        [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
yann@649
   134
        [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
yann@649
   135
        [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
yann@649
   136
        [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
yann@649
   137
        [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
yann@649
   138
        [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
yann@691
   139
        printf "  "
yann@935
   140
        ( . "${sample_top}/samples/${sample}/reported.by"
yann@935
   141
          if [ -n "${reporter_name}" ]; then
yann@617
   142
              if [ -n "${reporter_url}" ]; then
yann@642
   143
                  printf "|  [[${reporter_url}|${reporter_name}]]  "
yann@617
   144
              else
yann@642
   145
                  printf "|  ${reporter_name}  "
yann@617
   146
              fi
yann@935
   147
          else
yann@2725
   148
              printf "|  (//unknown//)  "
yann@935
   149
          fi
yann@935
   150
        )
yann@1427
   151
        sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
yann@750
   152
        printf "|  ${sample_updated}  "
yann@560
   153
        echo "|"
yann@474
   154
    fi
yann@74
   155
}
yann@74
   156
yann@74
   157
# Get largest sample width
yann@74
   158
width=0
yann@74
   159
for sample in "${@}"; do
yann@74
   160
    [ ${#sample} -gt ${width} ] && width=${#sample}
yann@74
   161
done
yann@74
   162
yann@560
   163
if [ "${opt}" = -w ]; then
yann@1659
   164
    printf "^ %s  |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
yann@1658
   165
    printf "^ Target  "
yann@1658
   166
    printf "^ Host  "
yann@828
   167
    printf "^  Status  "
yann@691
   168
    printf "^  Kernel headers\\\\\\\\ version  ^"
yann@851
   169
    printf "^  binutils\\\\\\\\ version  "
yann@691
   170
    printf "^  C compiler\\\\\\\\ version  ^"
yann@851
   171
    printf "^  C library\\\\\\\\ version  ^"
yann@851
   172
    printf "^  Threading\\\\\\\\ model  "
yann@651
   173
    printf "^  Floating point\\\\\\\\ support  "
yann@651
   174
    printf "^  Languages  "
yann@750
   175
    printf "^  Initially\\\\\\\\ reported by  "
yann@750
   176
    printf "^  Last\\\\\\\\ updated  "
yann@642
   177
    echo   "^"
yann@1876
   178
elif [ -z "${opt}" ]; then
yann@1876
   179
    printf "%-*s  Status\n" ${width} "Sample name"
yann@560
   180
fi
yann@724
   181
yann@74
   182
for sample in "${@}"; do
yann@474
   183
    ( dump_single_sample ${opt} ${width} "${sample}" )
yann@1682
   184
done
yann@724
   185
yann@724
   186
if [ "${opt}" = -w ]; then
antony@2564
   187
    printf "^ Total: ${#@} samples  || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is currently BROKEN. |||||||||||||"
yann@724
   188
    echo   ""
yann@822
   189
elif [ -z "${opt}" ]; then
yann@1876
   190
    echo '      L (Local)       : sample was found in current directory'
yann@1876
   191
    echo '      G (Global)      : sample was installed with crosstool-NG'
yann@822
   192
    echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
yann@999
   193
    echo '      B (BROKEN)      : sample is currently broken'
yann@724
   194
fi