Merge "Build IDE script."
diff --git a/eclipse/scripts/build_ide.sh b/eclipse/scripts/build_ide.sh
new file mode 100755
index 0000000..0b080d8
--- /dev/null
+++ b/eclipse/scripts/build_ide.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Expected arguments:
+# $1 = out_dir
+# $2 = ide qualifier
+# $3 = zip qualifier
+
+PROG_DIR=$(dirname "$0")
+
+DEST_DIR="$1"
+IDE_QUALIFIER="$2"
+ZIP_QUALIFIER="$3"
+
+function die() {
+  echo "$*" > /dev/stderr
+  echo "Usage: $0 dest_dir ide_qualifier zip_qualifier" > /dev/stderr
+  exit 1
+}
+
+if [[ -z "$DEST_DIR" ]]; then die "## Error: Missing dest_dir"; fi
+if [[ -z "$IDE_QUALIFIER" ]]; then die "## Error: Missing ide qualifier"; fi
+if [[ -z "$ZIP_QUALIFIER" ]]; then die "## Error: Missing zip qualifier"; fi
+
+ADT_IDE_DEST_DIR="$DEST_DIR" \
+ADT_IDE_QUALIFIER="$IDE_QUALIFIER" \
+ADT_IDE_ZIP_QUALIFIER="$ZIP_QUALIFIER" \
+    make PRODUCT-sdk-adt_eclipse_ide
+
diff --git a/eclipse/scripts/build_server.sh b/eclipse/scripts/build_server.sh
index bfb50a2..da7184a 100755
--- a/eclipse/scripts/build_server.sh
+++ b/eclipse/scripts/build_server.sh
@@ -18,6 +18,8 @@
 
 set -e  # Fail this script as soon as a command fails -- fail early, fail fast
 
+PROG_DIR=$(dirname "$0")
+
 DEST_DIR=""
 BUILD_NUMBER=""
 CREATE_ZIP="1"
@@ -48,7 +50,7 @@
 function check_params() {
   # This needs to run from the top android directory
   # Automatically CD to the top android directory, whatever its name
-  D=`dirname "$0"`
+  D="$PROG_DIR"
   cd "$D/../../../" && echo "Switched to directory $PWD"
 
   # The current Eclipse build has some Linux dependency in its config files
@@ -112,10 +114,17 @@
   # Build the ADT IDE if this runs on Linux.
   # Qualifier for the zip files is just the build number if available.
   if [[ -z $INTERNAL_BUILD && "Linux" == $(uname) ]]; then
-    ADT_IDE_DEST_DIR="$DEST_DIR" \
-    ADT_IDE_QUALIFIER="$QUALIFIER" \
-    ADT_IDE_ZIP_QUALIFIER="${BUILD_NUMBER:-$QUALIFIER}" \
-    make PRODUCT-sdk-adt_eclipse_ide
+    # This needs to run from the top android directory
+    D="$PROG_DIR"
+    cd "$D/../../../" && echo "Switched to directory $PWD"
+    for sc in */*/*/build_ide*.sh; do
+      if [[ -x $sc ]]; then
+        echo "RUNNING $sc from $PWD"
+        $sc "$DEST_DIR" "$QUALIFIER" "${BUILD_NUMBER:-$QUALIFIER}"
+      else
+        echo "WARNING: skipping non-exec $sc script"
+      fi
+    done
   fi
 }