Changeset a35b458 in mainline for tools/toolchain.sh


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/toolchain.sh

    r3061bc1 ra35b458  
    8585        HEADER="$2"
    8686        BODY="$3"
    87        
     87
    8888        FNAME="/tmp/conftest-$$"
    89        
     89
    9090        echo "#include ${HEADER}" > "${FNAME}.c"
    9191        echo >> "${FNAME}.c"
     
    9595        echo "  return 0;" >> "${FNAME}.c"
    9696        echo "}" >> "${FNAME}.c"
    97        
     97
    9898        cc $CFLAGS -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
    9999        RC="$?"
    100        
     100
    101101        if [ "$RC" -ne "0" ] ; then
    102102                if [ "${DEPENDENCY}" == "isl" ]; then
    103103                        BUILD_ISL=true
    104                        
     104
    105105                        echo " isl not found. Will be downloaded and built with GCC."
    106106                else
     
    134134                echo
    135135                echo "Script failed: $2"
    136                
     136
    137137                exit 1
    138138        fi
     
    142142        FILE="$1"
    143143        SUM="$2"
    144        
     144
    145145        COMPUTED="`md5sum "${FILE}" | cut -d' ' -f1`"
    146146        if [ "${SUM}" != "${COMPUTED}" ] ; then
    147147                echo
    148148                echo "Checksum of ${FILE} does not match."
    149                
     149
    150150                exit 2
    151151        fi
     
    193193        echo "feature that is not fully supported."
    194194        echo
    195        
     195
    196196        exit 3
    197197}
     
    203203show_countdown() {
    204204        TM="$1"
    205        
     205
    206206        if [ "${TM}" -eq 0 ] ; then
    207207                echo
    208208                return 0
    209209        fi
    210        
     210
    211211        echo -n "${TM} "
    212212        change_title "${TM}"
    213213        sleep 1
    214        
     214
    215215        TM="`expr "${TM}" - 1`"
    216216        show_countdown "${TM}"
     
    243243        FILE="$2"
    244244        CHECKSUM="$3"
    245        
     245
    246246        if [ ! -f "${FILE}" ] ; then
    247247                change_title "Downloading ${FILE}"
    248248                wget -c "${SOURCE}${FILE}" -O "${FILE}".part
    249249                check_error $? "Error downloading ${FILE}."
    250                
     250
    251251                mv "${FILE}".part "${FILE}"
    252252        fi
    253        
     253
    254254        check_md5 "${FILE}" "${CHECKSUM}"
    255255}
     
    257257source_check() {
    258258        FILE="$1"
    259        
     259
    260260        if [ ! -f "${FILE}" ] ; then
    261261                echo
    262262                echo "File ${FILE} not found."
    263                
     263
    264264                exit 4
    265265        fi
     
    268268cleanup_dir() {
    269269        DIR="$1"
    270        
     270
    271271        if [ -d "${DIR}" ] ; then
    272272                change_title "Removing ${DIR}"
     
    279279        DIR="$1"
    280280        DESC="$2"
    281        
     281
    282282        change_title "Creating ${DESC}"
    283283        echo ">>> Creating ${DESC}"
    284        
     284
    285285        mkdir -p "${DIR}"
    286286        test -d "${DIR}"
     
    292292        BASE="$2"
    293293        ORIGINAL="`pwd`"
    294        
     294
    295295        mkdir -p "${OUTSIDE}"
    296        
     296
    297297        cd "${OUTSIDE}"
    298298        check_error $? "Unable to change directory to ${OUTSIDE}."
    299299        ABS_OUTSIDE="`pwd`"
    300        
     300
    301301        cd "${BASE}"
    302302        check_error $? "Unable to change directory to ${BASE}."
    303303        ABS_BASE="`pwd`"
    304        
     304
    305305        cd "${ORIGINAL}"
    306306        check_error $? "Unable to change directory to ${ORIGINAL}."
    307        
     307
    308308        BASE_LEN="${#ABS_BASE}"
    309309        OUTSIDE_TRIM="${ABS_OUTSIDE:0:${BASE_LEN}}"
    310        
     310
    311311        if [ "${OUTSIDE_TRIM}" == "${ABS_BASE}" ] ; then
    312312                echo
    313313                echo "CROSS_PREFIX cannot reside within the working directory."
    314                
     314
    315315                exit 5
    316316        fi
     
    320320        FILE="$1"
    321321        DESC="$2"
    322        
     322
    323323        change_title "Unpacking ${DESC}"
    324324        echo " >>> Unpacking ${DESC}"
    325        
     325
    326326        case "${FILE}" in
    327327                *.gz)
     
    345345        PATCH_STRIP="$2"
    346346        DESC="$3"
    347        
     347
    348348        change_title "Patching ${DESC}"
    349349        echo " >>> Patching ${DESC} with ${PATCH_FILE}"
    350        
     350
    351351        patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE"
    352352        check_error $? "Error patching ${DESC}."
     
    357357        check_dependecies
    358358        show_countdown 10
    359        
     359
    360360        BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
    361361        GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
    362362        GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
    363363        ISL_SOURCE="http://isl.gforge.inria.fr/"
    364        
     364
    365365        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "9e8340c96626b469a603c15c9d843727"
    366366        download_fetch "${GCC_SOURCE}" "${GCC}" "6bf56a2bca9dac9dbbf8e8d1036964a8"
    367367        download_fetch "${GDB_SOURCE}" "${GDB}" "06c8f40521ed65fe36ebc2be29b56942"
    368        
     368
    369369        if $BUILD_ISL ; then
    370370                download_fetch "${ISL_SOURCE}" "${ISL}" "11436d6b205e516635b666090b94ab32"
     
    426426build_target() {
    427427        PLATFORM="$1"
    428        
     428
    429429        # This sets the *_TARGET variables
    430430        set_target_from_platform "$PLATFORM"
     
    434434                TARGET="$LINUX_TARGET"
    435435        fi
    436        
     436
    437437        WORKDIR="${BASEDIR}/${TARGET}"
    438438        INSTALL_DIR="${WORKDIR}/PKG"
     
    442442        OBJDIR="${WORKDIR}/gcc-obj"
    443443        GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
    444        
     444
    445445        if [ -z "${CROSS_PREFIX}" ] ; then
    446446                CROSS_PREFIX="/usr/local/cross"
    447447        fi
    448        
     448
    449449        PREFIX="${CROSS_PREFIX}/${TARGET}"
    450        
     450
    451451        echo ">>> Downloading tarballs"
    452452        source_check "${BASEDIR}/${BINUTILS}"
     
    456456                source_check "${BASEDIR}/${ISL}"
    457457        fi
    458        
     458
    459459        echo ">>> Removing previous content"
    460460        cleanup_dir "${WORKDIR}"
    461        
     461
    462462        create_dir "${OBJDIR}" "GCC object directory"
    463        
     463
    464464        check_dirs "${PREFIX}" "${WORKDIR}"
    465        
     465
    466466        echo ">>> Unpacking tarballs"
    467467        cd "${WORKDIR}"
    468468        check_error $? "Change directory failed."
    469        
     469
    470470        unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
    471471        unpack_tarball "${BASEDIR}/${GCC}" "GCC"
     
    475475                mv "${ISLDIR}" "${GCCDIR}"/isl
    476476        fi
    477        
     477
    478478        echo ">>> Applying patches"
    479479        for p in $BINUTILS_PATCHES ; do
     
    486486                patch_sources "${SRCDIR}/${p}" 0 "GDB"
    487487        done
    488        
     488
    489489        echo ">>> Processing binutils (${PLATFORM})"
    490490        cd "${BINUTILSDIR}"
    491491        check_error $? "Change directory failed."
    492        
     492
    493493        change_title "binutils: configure (${PLATFORM})"
    494494        CFLAGS=-Wno-error ./configure \
     
    498498                --enable-deterministic-archives
    499499        check_error $? "Error configuring binutils."
    500        
     500
    501501        change_title "binutils: make (${PLATFORM})"
    502502        make all
    503503        check_error $? "Error compiling binutils."
    504        
     504
    505505        change_title "binutils: install (${PLATFORM})"
    506506        make install "DESTDIR=${INSTALL_DIR}"
    507507        check_error $? "Error installing binutils."
    508        
    509        
     508
     509
    510510        echo ">>> Processing GCC (${PLATFORM})"
    511511        cd "${OBJDIR}"
    512512        check_error $? "Change directory failed."
    513        
     513
    514514        change_title "GCC: configure (${PLATFORM})"
    515515        PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
     
    521521                --disable-shared --enable-lto --disable-werror
    522522        check_error $? "Error configuring GCC."
    523        
     523
    524524        change_title "GCC: make (${PLATFORM})"
    525525        PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
    526526        check_error $? "Error compiling GCC."
    527        
     527
    528528        change_title "GCC: install (${PLATFORM})"
    529529        PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
    530530        check_error $? "Error installing GCC."
    531        
    532        
     531
     532
    533533        # No GDB support for RISC-V so far
    534534        if [ "$PLATFORM" != "riscv64" ] ; then
     
    536536                cd "${GDBDIR}"
    537537                check_error $? "Change directory failed."
    538                
     538
    539539                change_title "GDB: configure (${PLATFORM})"
    540540                PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
     
    543543                        --enable-werror=no --without-guile
    544544                check_error $? "Error configuring GDB."
    545                
     545
    546546                change_title "GDB: make (${PLATFORM})"
    547547                PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
    548548                check_error $? "Error compiling GDB."
    549                
     549
    550550                change_title "GDB: make (${PLATFORM})"
    551551                PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
    552552                check_error $? "Error installing GDB."
    553553        fi
    554        
     554
    555555        # Symlink clang and lld to the install path.
    556556        CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
    557557        LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
    558        
     558
    559559        ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
    560560        ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
    561        
     561
    562562        if $REAL_INSTALL ; then
    563563                echo ">>> Moving to the destination directory."
     
    566566                mv "${INSTALL_DIR}/${PREFIX}" "${PREFIX}"
    567567        fi
    568        
     568
    569569        cd "${BASEDIR}"
    570570        check_error $? "Change directory failed."
    571        
     571
    572572        echo ">>> Cleaning up"
    573573        cleanup_dir "${WORKDIR}"
    574        
     574
    575575        echo
    576576        echo ">>> Cross-compiler for ${TARGET} installed."
     
    647647                build_target "arm32" &
    648648                wait
    649                
     649
    650650                build_target "ia32" &
    651651                build_target "ia64" &
    652652                wait
    653                
     653
    654654                build_target "mips32" &
    655655                build_target "mips32eb" &
    656656                wait
    657                
     657
    658658                build_target "mips64" &
    659659                build_target "ppc32" &
    660660                wait
    661                
     661
    662662                build_target "riscv64" &
    663663                build_target "ppc64" &
    664664                wait
    665                
     665
    666666                build_target "sparc64" &
    667667                wait
Note: See TracChangeset for help on using the changeset viewer.