Changeset 1510 for trunk/kBuild/env.sh


Ignore:
Timestamp:
Apr 9, 2008, 3:19:35 AM (17 years ago)
Author:
bird
Message:

Fixed hash bang line. Added an eval mode and shut up the debug info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/env.sh

    r1507 r1510  
    1 #!/bin/sh should work fine too, just needs testing.
     1#!/bin/sh
    22# $Id$
    33## @file
     
    2828
    2929#
     30# Check if we're in eval mode or not.
     31#
     32ERR_REDIR=1
     33DBG_REDIR=1
     34EVAL_OPT=
     35DBG_OPT=
     36QUIET_OPT=
     37if test "$1" = "--debug"; then
     38    DBG_OPT="true"
     39    shift
     40fi
     41if test "$1" = "--quiet"; then
     42    QUIET_OPT="true"
     43    shift
     44fi
     45if test "$1" = "--eval"; then
     46    EVAL_OPT="true"
     47    ERR_REDIR=2
     48    DBG_REDIR=2
     49    shift
     50fi
     51
     52
     53#
    3054# Determin the kBuild path from the script location.
    3155#
     
    3559fi
    3660if test ! -f "$PATH_KBUILD/footer.kmk" -o ! -f "$PATH_KBUILD/header.kmk" -o ! -f "$PATH_KBUILD/rules.kmk"; then
    37     echo "$0: error: PATH_KBUILD ($PATH_KBUILD) is not pointing to a popluated kBuild directory.";
     61    echo "$0: error: PATH_KBUILD ($PATH_KBUILD) is not pointing to a popluated kBuild directory." 1>&${ERR_REDIR}
    3862    sleep 1;
    3963    exit 1;
    4064fi
    4165export PATH_KBUILD
    42 echo "dbg: PATH_KBUILD=$PATH_KBUILD"
     66test -n "$DBG_OPT" && echo "dbg: PATH_KBUILD=$PATH_KBUILD" 1>&${DBG_REDIR}
    4367
    4468
     
    5074fi
    5175export BUILD_TYPE
    52 echo "dbg: BUILD_TYPE=$BUILD_TYPE"
     76test -n "$DBG_OPT" && echo "dbg: BUILD_TYPE=$BUILD_TYPE" 1>&${DBG_REDIR}
    5377
    5478#
     
    95119
    96120        *)
    97             echo "$0: unknown os $BUILD_PLATFORM"
     121            echo "$0: unknown os $BUILD_PLATFORM" 1>&${ERR_REDIR}
    98122            sleep 1
    99123            exit 1
     
    102126fi
    103127export BUILD_PLATFORM
    104 echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM"
     128test -n "$DBG_OPT" && echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM" 1>&${DBG_REDIR}
    105129
    106130if test -z "$BUILD_PLATFORM_ARCH"; then
     
    173197            ;;
    174198
    175         *)  echo "$0: unknown cpu/arch - $BUILD_PLATFORM_ARCH"
     199        *)  echo "$0: unknown cpu/arch - $BUILD_PLATFORM_ARCH" 1>&${ERR_REDIR}
    176200            sleep 1
    177201            exit 1
     
    181205fi
    182206export BUILD_PLATFORM_ARCH
    183 echo "dbg: BUILD_PLATFORM_ARCH=$BUILD_PLATFORM_ARCH"
     207test -n "$DBG_OPT" && echo "dbg: BUILD_PLATFORM_ARCH=$BUILD_PLATFORM_ARCH" 1>&${DBG_REDIR}
    184208
    185209if test -z "$BUILD_PLATFORM_CPU"; then
     
    187211fi
    188212export BUILD_PLATFORM_CPU
    189 echo "dbg: BUILD_PLATFORM_CPU=$BUILD_PLATFORM_CPU"
     213test -n "$DBG_OPT" && echo "dbg: BUILD_PLATFORM_CPU=$BUILD_PLATFORM_CPU" 1>&${DBG_REDIR}
    190214
    191215#
     
    197221fi
    198222export BUILD_TARGET
    199 echo "dbg: BUILD_TARGET=$BUILD_TARGET"
     223test -n "$DBG_OPT" && echo "dbg: BUILD_TARGET=$BUILD_TARGET" 1>&${DBG_REDIR}
    200224
    201225if test -z "$BUILD_TARGET_ARCH"; then
     
    203227fi
    204228export BUILD_TARGET_ARCH
    205 echo "dbg: BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH"
     229test -n "$DBG_OPT" && echo "dbg: BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH" 1>&${DBG_REDIR}
    206230
    207231if test -z "$BUILD_TARGET_CPU"; then
     
    213237fi
    214238export BUILD_TARGET_CPU
    215 echo "dbg: BUILD_TARGET_CPU=$BUILD_TARGET_CPU"
     239test -n "$DBG_OPT" && echo "dbg: BUILD_TARGET_CPU=$BUILD_TARGET_CPU" 1>&${DBG_REDIR}
    216240
    217241
     
    233257    PATH_KBUILD_BIN="${PATH_KBUILD}/bin/${BUILD_PLATFORM}.${BUILD_PLATFORM_ARCH}"
    234258fi
    235 echo "dbg: PATH_KBUILD_BIN=${PATH_KBUILD_BIN} (not exported)"
     259test -n "$DBG_OPT" && echo "dbg: PATH_KBUILD_BIN=${PATH_KBUILD_BIN} (not exported)" 1>&${DBG_REDIR}
    236260
    237261# Make shell. OS/2 and DOS only?
    238 export MAKESHELL="${PATH_KBUILD_BIN}/kmk_ash${_SUFF_EXE}";
     262if test "$BUILD_PLATFORM" = "os2"; then
     263    export MAKESHELL="${PATH_KBUILD_BIN}/kmk_ash${_SUFF_EXE}";
     264fi
    239265
    240266#
     
    242268# NOTE! Once bootstrapped this is the only thing that is actually necessary.
    243269#
    244 PATH="${PATH_KBUILD_BIN}/${_PATH_SEP}$PATH"
     270PATH="${PATH_KBUILD_BIN}${_PATH_SEP}$PATH"
    245271export PATH
    246 echo "dbg: PATH=$PATH"
     272test -n "$DBG_OPT" && echo "dbg: PATH=$PATH" 1>&${DBG_REDIR}
    247273
    248274# Sanity and x bits.
    249275if test ! -d "${PATH_KBUILD_BIN}/"; then
    250     echo "$0: warning: The bin directory for this platform doesn't exists. (${PATH_KBUILD_BIN}/)"
     276    echo "$0: warning: The bin directory for this platform doesn't exists. (${PATH_KBUILD_BIN}/)" 1>&${ERR_REDIR}
    251277else
    252278    for prog in kmk kDepPre kDepIDB kmk_append kmk_ash kmk_cat kmk_cp kmk_echo kmk_install kmk_ln kmk_mkdir kmk_mv kmk_rm kmk_rmdir kmk_sed;
     
    254280        chmod a+x ${PATH_KBUILD_BIN}/${prog} > /dev/null 2>&1
    255281        if test ! -f "${PATH_KBUILD_BIN}/${prog}${_SUFF_EXE}"; then
    256             echo "$0: warning: The ${prog} program doesn't exist for this platform. (${PATH_KBUILD_BIN}/${prog}${_SUFF_EXE})"
     282            echo "$0: warning: The ${prog} program doesn't exist for this platform. (${PATH_KBUILD_BIN}/${prog}${_SUFF_EXE})" 1>&${ERR_REDIR}
    257283        fi
    258284    done
     
    262288unset _PATH_SEP
    263289
    264 # Execute command or spawn shell.
    265 if test $# -eq 0; then
    266     echo "$0: info: Spawning work shell..."
    267     if test "$TERM" != 'dumb'  -a  -n "$BASH"; then
    268         export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
     290if test -n "$EVAL_OPT"; then
     291    test -n "$DBG_OPT" && echo "dbg: echoing exported variables" 1>&${DBG_REDIR}
     292    echo "export BUILD_PLATFORM=${BUILD_PLATFORM}"
     293    echo "export BUILD_PLATFORM_ARCH=${BUILD_PLATFORM_ARCH}"
     294    echo "export BUILD_PLATFORM_CPU=${BUILD_PLATFORM_CPU}"
     295    echo "export BUILD_TARGET=${BUILD_TARGET}"
     296    echo "export BUILD_TARGET_ARCH=${BUILD_TARGET_ARCH}"
     297    echo "export BUILD_TARGET_CPU=${BUILD_TARGET_CPU}"
     298    echo "export BUILD_TYPE=${BUILD_TYPE}"
     299    echo "export PATH_KBUILD=${PATH_KBUILD}"
     300    echo "export PATH=${PATH}"
     301    test -n "$DBG_OPT" && echo "dbg: finished" 1>&${DBG_REDIR}
     302else
     303    # Execute command or spawn shell.
     304    if test $# -eq 0; then
     305        test -z "${QUIET_OPT}" && echo "$0: info: Spawning work shell..." 1>&${ERR_REDIR}
     306        if test "$TERM" != 'dumb'  -a  -n "$BASH"; then
     307            export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
     308        fi
     309        $SHELL -i
     310    else
     311        echo "$0: info: Executing command: $*"
     312        $*
    269313    fi
    270     $SHELL -i
    271 else
    272     echo "$0: info: Executing command: $*"
    273     $*
    274 fi
    275 
     314fi
     315
Note: See TracChangeset for help on using the changeset viewer.