am 282cb814: am 10a1d761: am 20228de2: Flesh out dex-preopt a bit more.

Merge commit '282cb814c1324273098adb496cc15d4f007b54d2' into dalvik-dev

* commit '282cb814c1324273098adb496cc15d4f007b54d2':
  Flesh out dex-preopt a bit more.
diff --git a/tools/dex-preopt b/tools/dex-preopt
index 3936eec..1a889d6 100755
--- a/tools/dex-preopt
+++ b/tools/dex-preopt
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 #
-# Usage: dex-preopt [options] path/to/input.jar path/to/output.dex
+# Usage: dex-preopt [options] path/to/input.jar path/to/output.odex
 #
 # This tool runs a host build of dalvikvm in order to preoptimize dex
 # files that will be run on a device.
@@ -40,12 +40,17 @@
 #     should be a directory with this name under build-dir/product. If
 #     not specified, then there must only be one such directory, and that
 #     one will be used.
+#   --boot-jars=list:of:jar:base:names -- Specify the list of base names
+#     of bootstrap classpath elements, colon-separated. This defaults to
+#     "core".
 #
 
 buildDir="."
 product=""
 bootstrap="no"
 bogus="no"
+bootJars="core:ext:framework:android.policy:services"
+# eventually, just bootJars="core"
 
 # Iterate over the arguments looking for options.
 while true; do
@@ -82,6 +87,8 @@
         buildDir="${value}"
     elif [ "${option}" = 'product' -a "${hasValue}" = 'yes' ]; then
         product="${value}"
+    elif [ "${option}" = 'boot-jars' -a "${hasValue}" = 'yes' ]; then
+        bootJars="${value}"
     elif [ "${option}" = 'bootstrap' -a "${hasValue}" = 'no' ]; then
         bootstrap="yes"
     else
@@ -106,6 +113,12 @@
     exit 1
 fi
 
+# Sanity-check the specified boot jar list.
+if [ "x${bootJars}" = 'x' ]; then
+    echo "must specify non-empty boot-jars list" 1>&2
+    exit 1
+fi
+
 # Cd to the build directory, un-symlinkifying it for clarity.
 cd "${buildDir}"
 cd "`/bin/pwd`"
@@ -142,6 +155,37 @@
     exit 1
 fi
 
+# Transform the bootJars into full paths, maintaining the colon separator.
+BOOTCLASSPATH=`echo ":${bootJars}" | \
+    sed "s!:\([^:]*\)!:${product}/system/framework/\1.jar!g" | \
+    sed 's/^://'`
+export BOOTCLASSPATH
+
+if [ "${bootstrap}" = "yes" ]; then
+    echo "Processing boot class path..."
+
+    # Split the boot classpath into separate elements and iterate over them,
+    # processing each, in order.
+    elements=`echo "${BOOTCLASSPATH}" | sed 's/:/ /g'`
+
+    for inputFile in $elements; do
+        outputFile="`dirname ${inputFile}`/`basename ${inputFile} .jar`.odex"
+        echo "TODO: We would process ${inputFile} into ${outputFile}"
+    done
+else
+    inputFile=$1
+    outputFile=$2
+
+    if [ "x$inputFile" = 'x' ]; then
+        echo "must specify input and output files" 1>&2
+        exit 1
+    elif [ "x$outputFile" = 'x' ]; then
+        echo "must specify output file" 1>&2
+        exit 1
+    fi
+
+    echo "TODO: We would process ${inputFile} into ${outputFile}"
+fi
 
 ##
 ## TODO: The rest of this is unmodified from fadden's original prototype.