OSDN Git Service

Clean-up and make the art script usable on target.
authorNicolas Geoffray <ngeoffray@google.com>
Tue, 2 Sep 2014 14:24:25 +0000 (15:24 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Mon, 8 Sep 2014 14:26:05 +0000 (15:26 +0100)
Also add a phony target to build what's needed to use it.

Change-Id: I0bca6b0cbe921653de05fec0ae0cbbff63df580e

Android.mk
tools/Android.mk
tools/art

index 15e8308..669939b 100644 (file)
@@ -355,7 +355,7 @@ build-art-host:   $(ART_HOST_EXECUTABLES)   $(ART_HOST_GTEST_EXECUTABLES)   $(HO
 build-art-target: $(ART_TARGET_EXECUTABLES) $(ART_TARGET_GTEST_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
 
 ########################################################################
-# "m art-host" for just building the files needed to run the art script
+# "m art-host" for just building the files needed to run the art script on the host.
 .PHONY: art-host
 ifeq ($(HOST_PREFER_32_BIT),true)
 art-host:   $(HOST_OUT_EXECUTABLES)/art $(HOST_OUT)/bin/dalvikvm32 $(HOST_OUT)/lib/libart.so $(HOST_OUT)/bin/dex2oat $(HOST_OUT)/bin/patchoat $(HOST_CORE_IMG_OUT) $(HOST_OUT)/lib/libjavacore.so $(HOST_OUT)/bin/dalvikvm
@@ -363,6 +363,11 @@ else
 art-host:   $(HOST_OUT_EXECUTABLES)/art $(HOST_OUT)/bin/dalvikvm64 $(HOST_OUT)/bin/dalvikvm32 $(HOST_OUT)/lib/libart.so $(HOST_OUT)/bin/dex2oat $(HOST_OUT)/bin/patchoat $(HOST_CORE_IMG_OUT) $(HOST_OUT)/lib/libjavacore.so $(HOST_OUT)/lib64/libjavacore.so $(HOST_OUT)/bin/dalvikvm
 endif
 
+# "m art-target" for just building the files needed to run the art script on the target.
+# Note that the script can run a dalvikvm executable that is not necessarily /system/bin/dalvikvm.
+.PHONY: art-target
+art-target: adb build-art-target art libnativehelper libjavacore
+
 .PHONY: art-host-debug
 art-host-debug:   art-host $(HOST_OUT)/lib/libartd.so $(HOST_OUT)/bin/dex2oatd $(HOST_OUT)/bin/patchoatd
 
index d3be17f..9a96f7a 100644 (file)
@@ -27,3 +27,13 @@ $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/art $(ACP)
        @echo "Copy: $(PRIVATE_MODULE) ($@)"
        $(copy-file-to-new-target)
        $(hide) chmod 755 $@
+
+# Copy the art shell script to the target's bin directory
+include $(CLEAR_VARS)
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE := art
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/art $(ACP)
+       @echo "Copy: $(PRIVATE_MODULE) ($@)"
+       $(copy-file-to-new-target)
+       $(hide) chmod 755 $@
index 85517d3..1afcc38 100644 (file)
--- a/tools/art
+++ b/tools/art
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-lib=-XXlib:libart.so
-invoke_with=
-
-while true; do
-  if [ "$1" = "--invoke-with" ]; then
-    shift
-    invoke_with="$1"
-    shift
-  elif [ "$1" = "-d" ]; then
-    lib="-XXlib:libartd.so"
-    shift
-  elif expr "$1" : "--" >/dev/null 2>&1; then
-    echo "unknown option: $1" 1>&2
-    exit 1
+function follow_links() {
+  if [ z"$BASH_SOURCE" != z ]; then
+    file="$BASH_SOURCE"
   else
-    break
+    file="$0"
   fi
-done
-
-function follow_links() {
-  file="$1"
   while [ -h "$file" ]; do
     # On Mac OS, readlink -f doesn't work.
     file="$(readlink "$file")"
@@ -42,13 +27,6 @@ function follow_links() {
   echo "$file"
 }
 
-PROG_NAME="$(follow_links "$BASH_SOURCE")"
-PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
-ANDROID_BUILD_TOP="$(cd "${PROG_DIR}/../../../../" ; pwd -P)/"
-ANDROID_HOST_OUT=$PROG_DIR/..
-ANDROID_DATA=$PWD/android-data$$
-DALVIKVM_EXECUTABLE=$ANDROID_HOST_OUT/bin/dalvikvm
-
 function find_libdir() {
   if [ "$(readlink "$DALVIKVM_EXECUTABLE")" = "dalvikvm64" ]; then
     echo "lib64"
@@ -57,14 +35,39 @@ function find_libdir() {
   fi
 }
 
-LD_LIBRARY_PATH=$ANDROID_HOST_OUT/"$(find_libdir)"
+PROG_NAME="$(follow_links)"
+PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
+ANDROID_ROOT=$PROG_DIR/..
+ANDROID_DATA=$PWD/android-data$$
+DALVIKVM_EXECUTABLE=$ANDROID_ROOT/bin/dalvikvm
+LIBDIR=$(find_libdir)
+LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR
+
+lib=-XXlib:$ANDROID_ROOT/$LIBDIR/libart.so
+invoke_with=
+
+while true; do
+  if [ "$1" = "--invoke-with" ]; then
+    shift
+    invoke_with="$1"
+    shift
+  elif [ "$1" = "-d" ]; then
+    lib="-XXlib:$LIBDIR/libartd.so"
+    shift
+  elif expr "$1" : "--" >/dev/null 2>&1; then
+    echo "unknown option: $1" 1>&2
+    exit 1
+  else
+    break
+  fi
+done
 
-mkdir -p $ANDROID_DATA/dalvik-cache/{x86,x86_64}
+mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64}
 ANDROID_DATA=$ANDROID_DATA \
-  ANDROID_ROOT=$ANDROID_HOST_OUT \
+  ANDROID_ROOT=$ANDROID_ROOT \
   LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
   $invoke_with $DALVIKVM_EXECUTABLE $lib \
-    -Ximage:$ANDROID_HOST_OUT/framework/core.art \
+    -Ximage:$ANDROID_ROOT/framework/core.art \
      "$@"
 EXIT_STATUS=$?
 rm -rf $ANDROID_DATA