From c5a89e256cd0ed486d72b23c2309d189bd923051 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Wed, 3 Jun 2009 16:07:36 -0700 Subject: [PATCH] Change the SDK, DDMS and Traceview to work with the new SWT libraries. The SDK now contains 32 and 64 bit version of SWT. DDMS and Traceview use the archquery java app to check the architecture of the VM to decide which version of SWT should be used to run the apps. --- build/sdk-darwin-x86.atree | 8 +-- build/sdk-linux-x86.atree | 10 +-- build/sdk.atree | 9 +++ tools/archquery/.classpath | 6 ++ tools/archquery/.gitignore | 1 + tools/archquery/.project | 17 +++++ tools/archquery/Android.mk | 17 +++++ tools/archquery/etc/manifest.txt | 1 + tools/archquery/src/Android.mk | 25 +++++++ .../src/com/android/archquery/Main.java | 65 +++++++++++++++++++ tools/ddms/app/etc/ddms | 51 ++++++++------- tools/ddms/app/src/Android.mk | 6 +- tools/ddms/libs/ddmuilib/src/Android.mk | 6 +- tools/screenshot/.gitignore | 1 + tools/sdkmanager/app/etc/android | 28 +++++++- tools/sdkmanager/app/src/Android.mk | 7 +- tools/sdkmanager/libs/sdkuilib/src/Android.mk | 6 +- tools/sdkstats/src/Android.mk | 6 +- tools/traceview/etc/traceview | 27 +++++++- tools/traceview/src/Android.mk | 6 +- 20 files changed, 245 insertions(+), 58 deletions(-) create mode 100644 tools/archquery/.classpath create mode 100644 tools/archquery/.gitignore create mode 100644 tools/archquery/.project create mode 100644 tools/archquery/Android.mk create mode 100644 tools/archquery/etc/manifest.txt create mode 100644 tools/archquery/src/Android.mk create mode 100644 tools/archquery/src/com/android/archquery/Main.java create mode 100644 tools/screenshot/.gitignore diff --git a/build/sdk-darwin-x86.atree b/build/sdk-darwin-x86.atree index 13ed5921b..19be137b7 100644 --- a/build/sdk-darwin-x86.atree +++ b/build/sdk-darwin-x86.atree @@ -2,12 +2,8 @@ # # swt -lib/libswt-carbon-3236.jnilib tools/lib/libswt-carbon-3236.jnilib -lib/libswt-pi-carbon-3236.jnilib tools/lib/libswt-pi-carbon-3236.jnilib -framework/swt.jar tools/lib/swt.jar -framework/org.eclipse.core.commands_3.2.0.I20060605-1400.jar tools/lib/org.eclipse.core.commands_3.2.0.I20060605-1400.jar -framework/org.eclipse.equinox.common_3.2.0.v20060603.jar tools/lib/org.eclipse.equinox.common_3.2.0.v20060603.jar -framework/org.eclipse.jface_3.2.0.I20060605-1400.jar tools/lib/org.eclipse.jface_3.2.0.I20060605-1400.jar +prebuilt/darwin-x86/swt/swt.jar tools/lib/x86/swt.jar + # JetCreator (only available on mac/windows) external/sonivox/jet_tools/JetCreator tools/Jet/JetCreator diff --git a/build/sdk-linux-x86.atree b/build/sdk-linux-x86.atree index 1324f55de..c580353c9 100644 --- a/build/sdk-linux-x86.atree +++ b/build/sdk-linux-x86.atree @@ -2,11 +2,5 @@ # # swt -lib/libswt-atk-gtk-3236.so tools/lib/libswt-atk-gtk-3236.so -lib/libswt-gtk-3236.so tools/lib/libswt-gtk-3236.so -lib/libswt-pi-gtk-3236.so tools/lib/libswt-pi-gtk-3236.so -lib/libswt-cairo-gtk-3236.so tools/lib/libswt-cairo-gtk-3236.so -framework/swt.jar tools/lib/swt.jar -framework/org.eclipse.core.commands_3.2.0.I20060605-1400.jar tools/lib/org.eclipse.core.commands_3.2.0.I20060605-1400.jar -framework/org.eclipse.equinox.common_3.2.0.v20060603.jar tools/lib/org.eclipse.equinox.common_3.2.0.v20060603.jar -framework/org.eclipse.jface_3.2.0.I20060605-1400.jar tools/lib/org.eclipse.jface_3.2.0.I20060605-1400.jar +prebuilt/linux-x86/swt/swt.jar tools/lib/x86/swt.jar +prebuilt/linux-x86_64/swt/swt.jar tools/lib/x86_64/swt.jar \ No newline at end of file diff --git a/build/sdk.atree b/build/sdk.atree index bd5fabeb4..fe2a17f74 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -30,6 +30,12 @@ bin/mksdcard tools/mksdcard # the uper-jar file that apps link against out/target/common/obj/PACKAGING/android_jar_intermediates/android.jar platforms/${PLATFORM_NAME}/android.jar +# eclipse files for SWT +framework/org.eclipse.core.commands_3.4.0.I20080509-2000.jar tools/lib/org.eclipse.core.commands_3.4.0.I20080509-2000.jar +framework/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar tools/lib/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar +framework/org.eclipse.jface_3.4.2.M20090107-0800.jar tools/lib/org.eclipse.jface_3.4.2.M20090107-0800.jar + + sdk/sdk-build.prop platforms/${PLATFORM_NAME}/build.prop development/tools/scripts/plugin.prop tools/lib/plugin.prop @@ -90,6 +96,9 @@ framework/jcommon-1.0.12.jar tools/lib/jcommon-1.0.12.jar framework/jfreechart-1.0.9.jar tools/lib/jfreechart-1.0.9.jar framework/jfreechart-1.0.9-swt.jar tools/lib/jfreechart-1.0.9-swt.jar +# archquery to test VM architecture +framework/archquery.jar tools/lib/archquery.jar + # ddms bin/ddms tools/ddms framework/ddms.jar tools/lib/ddms.jar diff --git a/tools/archquery/.classpath b/tools/archquery/.classpath new file mode 100644 index 000000000..fb5011632 --- /dev/null +++ b/tools/archquery/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/tools/archquery/.gitignore b/tools/archquery/.gitignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/tools/archquery/.gitignore @@ -0,0 +1 @@ +bin diff --git a/tools/archquery/.project b/tools/archquery/.project new file mode 100644 index 000000000..98860915d --- /dev/null +++ b/tools/archquery/.project @@ -0,0 +1,17 @@ + + + archquery + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/tools/archquery/Android.mk b/tools/archquery/Android.mk new file mode 100644 index 000000000..53cad467f --- /dev/null +++ b/tools/archquery/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +ARCHQUERY_LOCAL_DIR := $(call my-dir) +include $(ARCHQUERY_LOCAL_DIR)/src/Android.mk diff --git a/tools/archquery/etc/manifest.txt b/tools/archquery/etc/manifest.txt new file mode 100644 index 000000000..a362e885b --- /dev/null +++ b/tools/archquery/etc/manifest.txt @@ -0,0 +1 @@ +Main-Class: com.android.archquery.Main diff --git a/tools/archquery/src/Android.mk b/tools/archquery/src/Android.mk new file mode 100644 index 000000000..980f0026a --- /dev/null +++ b/tools/archquery/src/Android.mk @@ -0,0 +1,25 @@ +# +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_JAR_MANIFEST := ../etc/manifest.txt +LOCAL_JAVA_LIBRARIES := \ + +LOCAL_MODULE := archquery + +include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/archquery/src/com/android/archquery/Main.java b/tools/archquery/src/com/android/archquery/Main.java new file mode 100644 index 000000000..5e65ff289 --- /dev/null +++ b/tools/archquery/src/com/android/archquery/Main.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.archquery; + +/** + * Java command line tool to return the CPU architecture of the host java VM. + * + * The goal is to be able to launch SWT based applications (DDMS, Traceview, Android) on any + * type of OS. + * + * Because a 64 bit OS can run a 32 bit Virtual Machine, we need to query the VM itself to know + * whether it's 32 or 64 bit to detect which swt.jar it should use (it contains native libraries). + * Simply querying the OS is not enough. + * + * The other problem is that once a VM is launched it is impossible to change its classpath to + * point the VM to the correct version of swt.jar. + * + * The solution is this small command line tool, running in the VM, and returning the value of + * the 'os.arch' property. Based on the returned value, the script launching the SWT based + * applications will configure the Java VM with the path to the correct swt.jar + * + * Because different VMs return different values for 32 and 64 bit version of x86 CPUs, the program + * handles all the possible values and normalize the returned value. + * + * At this time, the normalized values are: + * x86: 32 bit x86 + * x86_64: 64 bit x86 + * ppc: PowerPC (WARNING: the SDK doesn't actually support this architecture). + * + * + */ +public final class Main { + public static void main(String[] args) { + // Values listed from http://lopica.sourceforge.net/os.html + String arch = System.getProperty("os.arch"); + + if (arch.equalsIgnoreCase("x86_64") || arch.equalsIgnoreCase("amd64")) { + System.out.print("x86_64"); + + } else if (arch.equalsIgnoreCase("x86") + || arch.equalsIgnoreCase("i386") + || arch.equalsIgnoreCase("i686")) { + System.out.print("x86"); + + } else if (arch.equalsIgnoreCase("ppc") || arch.equalsIgnoreCase("PowerPC")) { + System.out.print("ppc"); + } else { + System.out.print(arch); + } + } +} \ No newline at end of file diff --git a/tools/ddms/app/etc/ddms b/tools/ddms/app/etc/ddms index c63930b2d..e9ee6a03e 100755 --- a/tools/ddms/app/etc/ddms +++ b/tools/ddms/app/etc/ddms @@ -67,29 +67,6 @@ if [ `uname` = "Darwin" ]; then os_opts="-XstartOnFirstThread" #because Java 1.6 is 64 bits only and SWT doesn't support this, we force the usage of java 1.5 java_cmd="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/java" -elif [[ `uname -s` = 'Linux' ]]; then - # We need a 32-bit Java on Linux, because our JNI libraries are 32-bit. - java_cmd=`which java` - - if [ -x "$java_cmd" ]; then - if [[ ! `file -L "$java_cmd"` =~ "ELF 32-bit LSB executable" ]]; then - java_cmd="" - fi - fi - - if [ ! -x "$java_cmd" ]; then - # The default JVM is not suitable. - # See if we can find a particular known-good JVM - java_cmd="/usr/lib/jvm/ia32-java-6-sun/jre/bin/java" - if [ ! -x "$java_cmd" ]; then - PREFIX=`basename "$prog"` - echo "$PREFIX: The default Java VM is not an ELF 32-bit LSB executable." - echo "$PREFIX: Please do one of the following:" - echo "$PREFIX: 1) Arrange for the default Java VM to be an ELF 32-bit LSB executable." - echo "$PREFIX: 2) Install the ia32-sun-java6-bin package." - exit 1 - fi - fi else os_opts= java_cmd="java" @@ -102,6 +79,32 @@ else jarpath="$frameworkdir/$jarfile" fi +# Figure out the path to the swt.jar for the current architecture. +# if ANDROID_SWT is defined, then just use this. +# else, if running in the Android source tree, then look for the correct swt folder in prebuilt +# else, look for the correct swt folder in the SDK under tools/lib/ +swtpath="" +if [ -n "$ANDROID_SWT" ]; then + swtpath="$ANDROID_SWT" +else + vmarch=`java -jar "${frameworkdir}"/archquery.jar` + if [ -n "$ANDROID_BUILD_TOP" ]; then + osname=`uname -s | tr A-Z a-z` + swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt" + else + swtpath="${frameworkdir}/${vmarch}" + fi +fi + +# Combine the swtpath and the framework dir path. +if [ -d "$swtpath" ]; then + frameworkdir="${swtpath}:${frameworkdir}" +else + echo "SWT folder '${swtpath}' does not exist." + echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform." + exit 1 +fi + # need to use "java.ext.dirs" because "-jar" causes classpath to be ignored # might need more memory, e.g. -Xmx128M -exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Djava.library.path="$libdir" -Dcom.android.ddms.bindir="$progdir" -jar "$jarpath" "$@" +exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Dcom.android.ddms.bindir="$progdir" -jar "$jarpath" "$@" diff --git a/tools/ddms/app/src/Android.mk b/tools/ddms/app/src/Android.mk index a013fa6cd..c62b67808 100644 --- a/tools/ddms/app/src/Android.mk +++ b/tools/ddms/app/src/Android.mk @@ -13,9 +13,9 @@ LOCAL_JAVA_LIBRARIES := \ ddmlib \ ddmuilib \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 LOCAL_MODULE := ddms include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/ddms/libs/ddmuilib/src/Android.mk b/tools/ddms/libs/ddmuilib/src/Android.mk index acbda449f..68ceac1c9 100644 --- a/tools/ddms/libs/ddmuilib/src/Android.mk +++ b/tools/ddms/libs/ddmuilib/src/Android.mk @@ -9,9 +9,9 @@ LOCAL_JAVA_RESOURCE_DIRS := resources LOCAL_JAVA_LIBRARIES := \ ddmlib \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 \ + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 \ jcommon-1.0.12 \ jfreechart-1.0.9 \ jfreechart-1.0.9-swt diff --git a/tools/screenshot/.gitignore b/tools/screenshot/.gitignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/tools/screenshot/.gitignore @@ -0,0 +1 @@ +bin diff --git a/tools/sdkmanager/app/etc/android b/tools/sdkmanager/app/etc/android index af4042b06..ee21b0ef3 100755 --- a/tools/sdkmanager/app/etc/android +++ b/tools/sdkmanager/app/etc/android @@ -79,6 +79,32 @@ else jarpath="$frameworkdir/$jarfile" fi +# Figure out the path to the swt.jar for the current architecture. +# if ANDROID_SWT is defined, then just use this. +# else, if running in the Android source tree, then look for the correct swt folder in prebuilt +# else, look for the correct swt folder in the SDK under tools/lib/ +swtpath="" +if [ -n "$ANDROID_SWT" ]; then + swtpath="$ANDROID_SWT" +else + vmarch=`java -jar "${frameworkdir}"/archquery.jar` + if [ -n "$ANDROID_BUILD_TOP" ]; then + osname=`uname -s | tr A-Z a-z` + swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt" + else + swtpath="${frameworkdir}/${vmarch}" + fi +fi + +# Combine the swtpath and the framework dir path. +if [ -d "$swtpath" ]; then + frameworkdir="${swtpath}:${frameworkdir}" +else + echo "SWT folder '${swtpath}' does not exist." + echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform." + exit 1 +fi + # need to use "java.ext.dirs" because "-jar" causes classpath to be ignored # might need more memory, e.g. -Xmx128M -exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Djava.library.path="$libdir" -Dcom.android.sdkmanager.toolsdir="$progdir" -jar "$jarpath" "$@" +exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Dcom.android.sdkmanager.toolsdir="$progdir" -jar "$jarpath" "$@" diff --git a/tools/sdkmanager/app/src/Android.mk b/tools/sdkmanager/app/src/Android.mk index 634634902..b67bf6a9c 100644 --- a/tools/sdkmanager/app/src/Android.mk +++ b/tools/sdkmanager/app/src/Android.mk @@ -11,9 +11,10 @@ LOCAL_JAVA_LIBRARIES := \ sdklib \ sdkuilib \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 + LOCAL_MODULE := sdkmanager include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/sdkmanager/libs/sdkuilib/src/Android.mk b/tools/sdkmanager/libs/sdkuilib/src/Android.mk index 2d3c7749c..357a60dae 100644 --- a/tools/sdkmanager/libs/sdkuilib/src/Android.mk +++ b/tools/sdkmanager/libs/sdkuilib/src/Android.mk @@ -11,9 +11,9 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_JAVA_LIBRARIES := \ sdklib \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 LOCAL_MODULE := sdkuilib diff --git a/tools/sdkstats/src/Android.mk b/tools/sdkstats/src/Android.mk index bff43f3ae..e95e67ad7 100644 --- a/tools/sdkstats/src/Android.mk +++ b/tools/sdkstats/src/Android.mk @@ -7,9 +7,9 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_JAVA_LIBRARIES := \ androidprefs \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 LOCAL_MODULE := sdkstats include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/traceview/etc/traceview b/tools/traceview/etc/traceview index 1cc913d8f..fc7d8c025 100755 --- a/tools/traceview/etc/traceview +++ b/tools/traceview/etc/traceview @@ -97,5 +97,30 @@ else jarpath="$frameworkdir/$jarfile" fi +# Figure out the path to the swt.jar for the current architecture. +# if ANDROID_SWT is defined, then just use this. +# else, if running in the Android source tree, then look for the correct swt folder in prebuilt +# else, look for the correct swt folder in the SDK under tools/lib/ +swtpath="" +if [ -n "$ANDROID_SWT" ]; then + swtpath="$ANDROID_SWT" +else + vmarch=`java -jar "${frameworkdir}"/archquery.jar` + if [ -n "$ANDROID_BUILD_TOP" ]; then + osname=`uname -s | tr A-Z a-z` + swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt" + else + swtpath="${frameworkdir}/${vmarch}" + fi +fi -exec "$javaCmd" $javaOpts -Djava.ext.dirs="$frameworkdir" -Djava.library.path="$libdir" -jar "$jarpath" "$@" +# Combine the swtpath and the framework dir path. +if [ -d "$swtpath" ]; then + frameworkdir="${swtpath}:${frameworkdir}" +else + echo "SWT folder '${swtpath}' does not exist." + echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform." + exit 1 +fi + +exec "$javaCmd" $javaOpts -Djava.ext.dirs="$frameworkdir" -jar "$jarpath" "$@" diff --git a/tools/traceview/src/Android.mk b/tools/traceview/src/Android.mk index 7a006de4c..fd901f133 100644 --- a/tools/traceview/src/Android.mk +++ b/tools/traceview/src/Android.mk @@ -11,9 +11,9 @@ LOCAL_JAVA_LIBRARIES := \ androidprefs \ sdkstats \ swt \ - org.eclipse.jface_3.2.0.I20060605-1400 \ - org.eclipse.equinox.common_3.2.0.v20060603 \ - org.eclipse.core.commands_3.2.0.I20060605-1400 + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.equinox.common_3.4.0.v20080421-2006 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 LOCAL_MODULE := traceview include $(BUILD_HOST_JAVA_LIBRARY)