aboutsummaryrefslogtreecommitdiffstats
path: root/archquery
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2009-06-03 16:07:36 -0700
committerXavier Ducrohet <xav@android.com>2009-06-04 14:50:43 -0700
commitf5e1cc8856d792d71f1455ae70316fc37cff4e7c (patch)
tree13e8768d92dcdc37fd8f8f5012895e43890a5fd5 /archquery
parent0d8ba9e1b1a3db2773453844b8d129b5f97fe102 (diff)
downloadsdk-f5e1cc8856d792d71f1455ae70316fc37cff4e7c.zip
sdk-f5e1cc8856d792d71f1455ae70316fc37cff4e7c.tar.gz
sdk-f5e1cc8856d792d71f1455ae70316fc37cff4e7c.tar.bz2
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.
Diffstat (limited to 'archquery')
-rw-r--r--archquery/.classpath6
-rw-r--r--archquery/.gitignore1
-rw-r--r--archquery/.project17
-rw-r--r--archquery/Android.mk17
-rw-r--r--archquery/etc/manifest.txt1
-rw-r--r--archquery/src/Android.mk25
-rw-r--r--archquery/src/com/android/archquery/Main.java65
7 files changed, 132 insertions, 0 deletions
diff --git a/archquery/.classpath b/archquery/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/archquery/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/archquery/.gitignore b/archquery/.gitignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/archquery/.gitignore
@@ -0,0 +1 @@
+bin
diff --git a/archquery/.project b/archquery/.project
new file mode 100644
index 0000000..9886091
--- /dev/null
+++ b/archquery/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>archquery</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/archquery/Android.mk b/archquery/Android.mk
new file mode 100644
index 0000000..53cad46
--- /dev/null
+++ b/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/archquery/etc/manifest.txt b/archquery/etc/manifest.txt
new file mode 100644
index 0000000..a362e88
--- /dev/null
+++ b/archquery/etc/manifest.txt
@@ -0,0 +1 @@
+Main-Class: com.android.archquery.Main
diff --git a/archquery/src/Android.mk b/archquery/src/Android.mk
new file mode 100644
index 0000000..980f002
--- /dev/null
+++ b/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/archquery/src/com/android/archquery/Main.java b/archquery/src/com/android/archquery/Main.java
new file mode 100644
index 0000000..5e65ff2
--- /dev/null
+++ b/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