OSDN Git Service

IML70B
[android-x86/build.git] / envsetup.sh
index 4c62e8e..bab2d25 100644 (file)
@@ -54,8 +54,9 @@ function check_product()
         return
     fi
     CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
-        TARGET_PRODUCT=$1 TARGET_BUILD_VARIANT= \
-        TARGET_SIMULATOR= TARGET_BUILD_TYPE= \
+        TARGET_PRODUCT=$1 \
+        TARGET_BUILD_VARIANT= \
+        TARGET_BUILD_TYPE= \
         TARGET_BUILD_APPS= \
         get_build_var TARGET_DEVICE > /dev/null
     # hide successful answers, but allow the errors to show
@@ -104,6 +105,8 @@ function setpaths()
     fi
     if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
         export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
+        # strip trailing ':', if any
+        export PATH=${PATH/%:/}
     fi
 
     # and in with the new
@@ -129,12 +132,11 @@ function setpaths()
     export PATH=$PATH$ANDROID_BUILD_PATHS
 
     unset ANDROID_JAVA_TOOLCHAIN
+    unset ANDROID_PRE_BUILD_PATHS
     if [ -n "$JAVA_HOME" ]; then
         export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
-    fi
-    export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN
-    if [ -n "$ANDROID_PRE_BUILD_PATHS" ]; then
-        export PATH=$ANDROID_PRE_BUILD_PATHS:$PATH
+        export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
+        export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
     fi
 
     unset ANDROID_PRODUCT_OUT
@@ -147,9 +149,6 @@ function setpaths()
     # needed for building linux on MacOS
     # TODO: fix the path
     #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
-
-    # needed for OProfile to post-process collected samples
-    export OPROFILE_EVENTS_DIR=$prebuiltdir/oprofile
 }
 
 function printconfig()
@@ -214,74 +213,6 @@ function addcompletions()
     fi
 }
 
-case `uname -s` in
-    Linux)
-        function choosesim()
-        {
-            echo "Build for the simulator or the device?"
-            echo "     1. Device"
-            echo "     2. Simulator"
-            echo
-
-            export TARGET_SIMULATOR=
-            local ANSWER
-            while [ -z $TARGET_SIMULATOR ]
-            do
-                echo -n "Which would you like? [1] "
-                if [ -z "$1" ] ; then
-                    read ANSWER
-                else
-                    echo $1
-                    ANSWER=$1
-                fi
-                case $ANSWER in
-                "")
-                    export TARGET_SIMULATOR=false
-                    ;;
-                1)
-                    export TARGET_SIMULATOR=false
-                    ;;
-                Device)
-                    export TARGET_SIMULATOR=false
-                    ;;
-                2)
-                    export TARGET_SIMULATOR=true
-                    ;;
-                Simulator)
-                    export TARGET_SIMULATOR=true
-                    ;;
-                *)
-                    echo
-                    echo "I didn't understand your response.  Please try again."
-                    echo
-                    ;;
-                esac
-                if [ -n "$1" ] ; then
-                    break
-                fi
-            done
-
-            set_stuff_for_environment
-        }
-        ;;
-    *)
-        function choosesim()
-        {
-            echo "Only device builds are supported for" `uname -s`
-            echo "     Forcing TARGET_SIMULATOR=false"
-            echo
-            if [ -z "$1" ]
-            then
-                echo -n "Press enter: "
-                read
-            fi
-
-            export TARGET_SIMULATOR=false
-            set_stuff_for_environment
-        }
-        ;;
-esac
-
 function choosetype()
 {
     echo "Build type choices are:"
@@ -290,13 +221,8 @@ function choosetype()
     echo
 
     local DEFAULT_NUM DEFAULT_VALUE
-    if [ $TARGET_SIMULATOR = "false" ] ; then
-        DEFAULT_NUM=1
-        DEFAULT_VALUE=release
-    else
-        DEFAULT_NUM=2
-        DEFAULT_VALUE=debug
-    fi
+    DEFAULT_NUM=1
+    DEFAULT_VALUE=release
 
     export TARGET_BUILD_TYPE=
     local ANSWER
@@ -350,11 +276,7 @@ function chooseproduct()
     if [ "x$TARGET_PRODUCT" != x ] ; then
         default_value=$TARGET_PRODUCT
     else
-        if [ "$TARGET_SIMULATOR" = true ] ; then
-            default_value=sim
-        else
-            default_value=full
-        fi
+        default_value=full
     fi
 
     export TARGET_PRODUCT=
@@ -436,19 +358,15 @@ function choosevariant()
 
 function choosecombo()
 {
-    choosesim $1
-
-    echo
-    echo
-    choosetype $2
+    choosetype $1
 
     echo
     echo
-    chooseproduct $3
+    chooseproduct $2
 
     echo
     echo
-    choosevariant $4
+    choosevariant $3
 
     echo
     set_stuff_for_environment
@@ -511,9 +429,6 @@ function lunch()
     if [ -z "$answer" ]
     then
         selection=full-eng
-    elif [ "$answer" = "simulator" ]
-    then
-        selection=simulator
     elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
     then
         if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
@@ -534,45 +449,35 @@ function lunch()
 
     export TARGET_BUILD_APPS=
 
-    # special case the simulator
-    if [ "$selection" = "simulator" ]
+    local product=$(echo -n $selection | sed -e "s/-.*$//")
+    check_product $product
+    if [ $? -ne 0 ]
     then
-        export TARGET_PRODUCT=sim
-        export TARGET_BUILD_VARIANT=eng
-        export TARGET_SIMULATOR=true
-        export TARGET_BUILD_TYPE=debug
-    else
-        local product=$(echo -n $selection | sed -e "s/-.*$//")
-        check_product $product
-        if [ $? -ne 0 ]
-        then
-            echo
-            echo "** Don't have a product spec for: '$product'"
-            echo "** Do you have the right repo manifest?"
-            product=
-        fi
+        echo
+        echo "** Don't have a product spec for: '$product'"
+        echo "** Do you have the right repo manifest?"
+        product=
+    fi
 
-        local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
-        check_variant $variant
-        if [ $? -ne 0 ]
-        then
-            echo
-            echo "** Invalid variant: '$variant'"
-            echo "** Must be one of ${VARIANT_CHOICES[@]}"
-            variant=
-        fi
+    local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
+    check_variant $variant
+    if [ $? -ne 0 ]
+    then
+        echo
+        echo "** Invalid variant: '$variant'"
+        echo "** Must be one of ${VARIANT_CHOICES[@]}"
+        variant=
+    fi
 
-        if [ -z "$product" -o -z "$variant" ]
-        then
-            echo
-            return 1
-        fi
+    if [ -z "$product" -o -z "$variant" ]
+    then
+        echo
+        return 1
+    fi
 
-        export TARGET_PRODUCT=$product
-        export TARGET_BUILD_VARIANT=$variant
-        export TARGET_SIMULATOR=false
-        export TARGET_BUILD_TYPE=release
-    fi # !simulator
+    export TARGET_PRODUCT=$product
+    export TARGET_BUILD_VARIANT=$variant
+    export TARGET_BUILD_TYPE=release
 
     echo
 
@@ -613,7 +518,6 @@ function tapas()
 
     export TARGET_PRODUCT=full
     export TARGET_BUILD_VARIANT=$variant
-    export TARGET_SIMULATOR=false
     export TARGET_BUILD_TYPE=release
     export TARGET_BUILD_APPS=$apps
 
@@ -818,7 +722,11 @@ function gdbclient()
        local PID
        local PROG="$3"
        if [ "$PROG" ] ; then
-           PID=`pid $3`
+           if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
+               PID="$3"
+           else
+               PID=`pid $3`
+           fi
            adb forward "tcp$PORT" "tcp$PORT"
            adb shell gdbserver $PORT --attach $PID &
            sleep 2
@@ -847,55 +755,55 @@ case `uname -s` in
     Darwin)
         function sgrep()
         {
-            find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
         }
 
         ;;
     *)
         function sgrep()
         {
-            find . -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
+            find . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
         }
         ;;
 esac
 
 function jgrep()
 {
-    find . -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
+    find . -name .repo -prune -o -name .git -prune -o  -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
 }
 
 function cgrep()
 {
-    find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
+    find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
 }
 
 function resgrep()
 {
-    for dir in `find . -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
+    for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
 }
 
 case `uname -s` in
     Darwin)
         function mgrep()
         {
-            find -E . -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
         }
 
         function treegrep()
         {
-            find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
         }
 
         ;;
     *)
         function mgrep()
         {
-            find . -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
+            find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
         }
 
         function treegrep()
         {
-            find . -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
+            find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
         }
 
         ;;
@@ -1099,7 +1007,7 @@ function godir () {
         echo ""
     fi
     local lines
-    lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq)) 
+    lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
     if [[ ${#lines[@]} = 0 ]]; then
         echo "Not found"
         return
@@ -1112,7 +1020,7 @@ function godir () {
             local line
             for line in ${lines[@]}; do
                 printf "%6s %s\n" "[$index]" $line
-                index=$(($index + 1)) 
+                index=$(($index + 1))
             done
             echo
             echo -n "Select one: "