OSDN Git Service

Merge "merge from open-source froyo" into froyo
[android-x86/build.git] / envsetup.sh
index a32d0b2..21a66c1 100644 (file)
@@ -56,6 +56,7 @@ function check_product()
     CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
         TARGET_PRODUCT=$1 TARGET_BUILD_VARIANT= \
         TARGET_SIMULATOR= TARGET_BUILD_TYPE= \
+        TARGET_BUILD_APPS= \
         get_build_var TARGET_DEVICE > /dev/null
     # hide successful answers, but allow the errors to show
 }
@@ -150,9 +151,14 @@ function set_sequence_number()
 function settitle()
 {
     if [ "$STAY_OFF_MY_LAWN" = "" ]; then
-        local product=$(get_build_var TARGET_PRODUCT)
-        local variant=$(get_build_var TARGET_BUILD_VARIANT)
-        export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
+        local product=$TARGET_PRODUCT
+        local variant=$TARGET_BUILD_VARIANT
+        local apps=$TARGET_BUILD_APPS
+        if [ -z "$apps" ]; then
+            export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
+        else
+            export PROMPT_COMMAND="echo -ne \"\033]0;[$apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
+        fi
     fi
 }
 
@@ -376,11 +382,6 @@ function choosevariant()
     done
 }
 
-function tapas()
-{
-    choosecombo
-}
-
 function choosecombo()
 {
     choosesim $1
@@ -432,7 +433,6 @@ function print_lunch_menu()
     echo
     echo "You're building on" $uname
     echo
-    echo ${LUNCH_MENU_CHOICES[@]}
     echo "Lunch menu... pick a combo:"
 
     local i=1
@@ -484,6 +484,8 @@ function lunch()
         return 1
     fi
 
+    export TARGET_BUILD_APPS=
+
     # special case the simulator
     if [ "$selection" = "simulator" ]
     then
@@ -530,6 +532,34 @@ function lunch()
     printconfig
 }
 
+# Configures the build to build unbundled apps.
+# Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
+function tapas()
+{
+    local variant=$(echo -n $(echo $* | xargs -n 1 echo | grep -E '^(user|userdebug|eng)$'))
+    local apps=$(echo -n $(echo $* | xargs -n 1 echo | grep -E -v '^(user|userdebug|eng)$'))
+
+    if [ $(echo $variant | wc -w) -gt 1 ]; then
+        echo "tapas: Error: Multiple build variants supplied: $variant"
+        return
+    fi
+    if [ -z "$variant" ]; then
+        variant=eng
+    fi
+    if [ -z "$apps" ]; then
+        apps=all
+    fi
+
+    export TARGET_PRODUCT=generic
+    export TARGET_BUILD_VARIANT=$variant
+    export TARGET_SIMULATOR=false
+    export TARGET_BUILD_TYPE=release
+    export TARGET_BUILD_APPS=$apps
+
+    set_stuff_for_environment
+    printconfig
+}
+
 function gettop
 {
     local TOPFILE=build/core/envsetup.mk
@@ -537,7 +567,10 @@ function gettop
         echo $TOP
     else
         if [ -f $TOPFILE ] ; then
-            echo $PWD
+            # The following circumlocution (repeated below as well) ensures
+            # that we record the true directory name and not one that is
+            # faked up with symlink names.
+            PWD= /bin/pwd
         else
             # We redirect cd to /dev/null in case it's aliased to
             # a command that prints something as a side-effect
@@ -546,7 +579,7 @@ function gettop
             T=
             while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
                 cd .. > /dev/null
-                T=$PWD
+                T=`PWD= /bin/pwd`
             done
             cd $HERE > /dev/null
             if [ -f "$T/$TOPFILE" ]; then
@@ -622,7 +655,8 @@ function mmm()
             if [ -f $DIR/Android.mk ]; then
                 TO_CHOP=`echo $T | wc -c | tr -d ' '`
                 TO_CHOP=`expr $TO_CHOP + 1`
-                MFILE=`echo $PWD | cut -c${TO_CHOP}-`
+                START=`PWD= /bin/pwd`
+                MFILE=`echo $START | cut -c${TO_CHOP}-`
                 if [ "$MFILE" = "" ] ; then
                     MFILE=$DIR/Android.mk
                 else
@@ -687,6 +721,13 @@ function pid()
    fi
 }
 
+# systemstack - dump the current stack trace of all threads in the system process
+# to the usual ANR traces file
+function systemstack()
+{
+    adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server)
+}
+
 function gdbclient()
 {
    local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
@@ -760,7 +801,7 @@ function jgrep()
 
 function cgrep()
 {
-    find . -type f -name "*\.c*" -print0 | xargs -0 grep --color -n "$@"
+    find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
 }
 
 function resgrep()
@@ -975,9 +1016,10 @@ function godir () {
         echo "Usage: godir <regex>"
         return
     fi
+    T=$(gettop)
     if [[ ! -f $T/filelist ]]; then
         echo -n "Creating index..."
-        (cd $T; find . -wholename ./out -prune -o -type f > filelist)
+        (cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
         echo " Done"
         echo ""
     fi
@@ -1014,6 +1056,20 @@ function godir () {
     cd $T/$pathname
 }
 
+# Force JAVA_HOME to point to java 1.5 if it isn't already set
+if [ "$STAY_OFF_MY_LAWN" = "" ]; then
+    if [ ! "$JAVA_HOME" ]; then
+        case `uname -s` in
+            Darwin)
+                export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
+                ;;
+            *)
+                export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
+                ;;
+        esac
+    fi
+fi
+
 # determine whether arrays are zero-based (bash) or one-based (zsh)
 _xarray=(a b c)
 if [ -z "${_xarray[${#_xarray[@]}]}" ]
@@ -1025,7 +1081,7 @@ fi
 unset _xarray
 
 # Execute the contents of any vendorsetup.sh files we can find.
-for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh 2> /dev/null`
+for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
 do
     echo "including $f"
     . $f