Build SDK using prebuilts/devtools.

Change-Id: I4c1979f8f07d24573b3ff7d7a1fa22d6ea87e5e3
diff --git a/build/product_sdk.mk b/build/product_sdk.mk
index cf4879e..6e937ed 100644
--- a/build/product_sdk.mk
+++ b/build/product_sdk.mk
@@ -28,35 +28,9 @@
 # Host tools and java libraries that are parts of the SDK.
 PRODUCT_PACKAGES += \
 	ant-glob \
-	android \
 	annotations \
-	anttasks \
-	archquery \
-	assetstudio \
-	ddmlib \
-	ddms \
-	ddmuilib \
-	draw9patch \
-	dvlib \
-	hierarchyviewer \
-	sdk_common \
-	layoutlib_api \
-	lint \
-	manifmerger \
 	mksdcard \
 	monitor \
-	monkeyrunner \
-	ninepatch-tests \
-	rule_api \
-	sdklib \
-	sdkmanager \
-	sdkstats \
-	sdkuilib \
-	swtmenubar \
-	traceview \
-	uiautomatorviewer \
 	fastboot \
-	hierarchyviewer2 \
-	emugen \
-	jobb \
-	fat32lib
+	emugen
+
diff --git a/build/tools.atree b/build/tools.atree
index 6772d69..b9ae5c9 100644
--- a/build/tools.atree
+++ b/build/tools.atree
@@ -18,6 +18,21 @@
 # These are the files that comprise the tools component of the SDK.
 #
 
+prebuilts/devtools/tools/lib                  tools/lib
+
+prebuilts/devtools/tools/android              tools/android
+prebuilts/devtools/tools/draw9patch           tools/draw9patch
+prebuilts/devtools/tools/ddms                 tools/ddms
+prebuilts/devtools/tools/hierarchyviewer      tools/hierarchyviewer
+prebuilts/devtools/tools/jobb                 tools/jobb
+prebuilts/devtools/tools/lint                 tools/lint
+prebuilts/devtools/tools/monkeyrunner         tools/monkeyrunner
+prebuilts/devtools/tools/traceview            tools/traceview
+prebuilts/devtools/tools/uiautomatorviewer    tools/uiautomatorviewer
+
+prebuilts/devtools/notices/NOTICE.txt         tols/NOTICE.txt
+
+
 ##############################################################################
 # Tools Component
 ##############################################################################
@@ -62,16 +77,6 @@
 lib/lib64GLES_V2_translator${DLL_EXTENSION}   strip tools/lib/lib64GLES_V2_translator${DLL_EXTENSION}
 lib/lib64EGL_translator${DLL_EXTENSION}       strip tools/lib/lib64EGL_translator${DLL_EXTENSION}
 
-# Java-Based SDK Tools
-bin/ddms                                            tools/ddms
-bin/hierarchyviewer                                 tools/hierarchyviewer
-bin/draw9patch                                      tools/draw9patch
-bin/traceview                                       tools/traceview
-bin/android                                         tools/android
-bin/monkeyrunner                                    tools/monkeyrunner
-bin/uiautomatorviewer                               tools/uiautomatorviewer
-prebuilts/devtools/tools/jobb                       tools/jobb
-prebuilts/devtools/tools/lint                       tools/lint
 
 # sdk.git Ant templates for project build files
 sdk/templates/build.template                        tools/lib/build.template
@@ -94,60 +99,12 @@
 sdk/files/android.el tools/lib/android.el
 
 # Java Libraries for the tools
-prebuilts/devtools/tools/lib/common.jar             tools/lib/common.jar
-prebuilts/devtools/tools/lib/swtmenubar.jar         tools/lib/swtmenubar.jar
 sdk/apkbuilder/etc/apkbuilder                       tools/apkbuilder
-framework/sdkstats.jar                              tools/lib/sdkstats.jar
-framework/archquery.jar                             tools/lib/archquery.jar
-framework/ddms.jar                                  tools/lib/ddms.jar
-prebuilts/devtools/tools/lib/ddmlib.jar             tools/lib/ddmlib.jar
-framework/ddmuilib.jar                              tools/lib/ddmuilib.jar
-framework/hierarchyviewer2.jar                      tools/lib/hierarchyviewer2.jar
-framework/hierarchyviewerlib.jar                    tools/lib/hierarchyviewerlib.jar
-framework/draw9patch.jar                            tools/lib/draw9patch.jar
-framework/traceview.jar                             tools/lib/traceview.jar
-framework/anttasks.jar                              tools/lib/anttasks.jar
-prebuilts/devtools/tools/lib/sdklib.jar             tools/lib/sdklib.jar
-prebuilts/devtools/tools/lib/sdkuilib.jar           tools/lib/sdkuilib.jar
-framework/sdkmanager.jar                            tools/lib/sdkmanager.jar
-framework/monkeyrunner.jar                          tools/lib/monkeyrunner.jar
-framework/chimpchat.jar                             tools/lib/chimpchat.jar
-framework/guava-tools.jar                           tools/lib/guava-tools.jar
-framework/jsilver.jar                               tools/lib/jsilver.jar
-framework/jython.jar                                tools/lib/jython.jar
-prebuilts/devtools/tools/lib/lint.jar               tools/lib/lint.jar
-prebuilts/devtools/tools/lib/lint_api.jar           tools/lib/lint_api.jar
-prebuilts/devtools/tools/lib/lint_checks.jar        tools/lib/lint_checks.jar
-prebuilts/devtools/tools/lib/manifmerger.jar        tools/lib/manifmerger.jar
-prebuilts/devtools/tools/lib/dvlib.jar              tools/lib/dvlib.jar
-prebuilts/devtools/tools/lib/layoutlib_api.jar      tools/lib/layoutlib_api.jar
-framework/uiautomatorviewer.jar                     tools/lib/uiautomatorviewer.jar
-prebuilts/devtools/tools/lib/jobb.jar               tools/lib/jobb.jar
-framework/fat32lib.jar                              tools/lib/fat32lib.jar
-prebuilts/tools/common/mkidentity/mkidentity-prebuilt.jar tools/lib/mkidentity.jar
 
 # 3rd Party java libraries
-prebuilts/tools/common/commons-compress/commons-compress-1.0.jar                    tools/lib/commons-compress-1.0.jar
-prebuilts/tools/common/http-client/httpclient-4.1.1.jar                             tools/lib/httpclient-4.1.1.jar
-prebuilts/tools/common/http-client/httpcore-4.1.jar                                 tools/lib/httpcore-4.1.jar
-prebuilts/tools/common/http-client/httpmime-4.1.1.jar                               tools/lib/httpmime-4.1.1.jar
-prebuilts/tools/common/http-client/commons-logging-1.1.1.jar                        tools/lib/commons-logging-1.1.1.jar
-prebuilts/tools/common/http-client/commons-codec-1.4.jar                            tools/lib/commons-codec-1.4.jar
 framework/emmalib.jar                                                               tools/lib/emma_device.jar
 external/emma/lib/emma.jar                                                          tools/lib/emma.jar
 external/emma/lib/emma_ant.jar                                                      tools/lib/emma_ant.jar
-prebuilts/tools/common/jfreechart/jcommon-1.0.12.jar                                tools/lib/jcommon-1.0.12.jar
-prebuilts/tools/common/jfreechart/jfreechart-1.0.9.jar                              tools/lib/jfreechart-1.0.9.jar
-prebuilts/tools/common/jfreechart/jfreechart-1.0.9-swt.jar                          tools/lib/jfreechart-1.0.9-swt.jar
-prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar   tools/lib/org.eclipse.core.commands_3.6.0.I20100512-1500.jar
-prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar       tools/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar
-prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar           tools/lib/org.eclipse.jface_3.6.2.M20110210-1200.jar
-prebuilts/tools/common/osgi/osgi.jar                                                tools/lib/osgi.jar
-prebuilts/tools/common/asm-tools/asm-4.0.jar                                        tools/lib/asm-4.0.jar
-prebuilts/tools/common/asm-tools/asm-tree-4.0.jar                                   tools/lib/asm-tree-4.0.jar
-prebuilts/tools/common/asm-tools/asm-analysis-4.0.jar                               tools/lib/asm-analysis-4.0.jar
-prebuilts/tools/common/guava-tools/guava-13.0.1.jar                                 tools/lib/guava-13.0.1.jar
-prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar                                tools/lib/lombok-ast-0.2.jar
 
 # Proguard
 # We're skipping the build and src/ trees (except for src/proguard/ant/task.properties)
@@ -189,5 +146,4 @@
 ##############################################################################
 
 sdk/testapps                            tests/testapps
-framework/ninepatch-tests.jar           tests/libtests/ninepatch-tests.jar
 
diff --git a/build/tools.windows.atree b/build/tools.windows.atree
index f64b374..421ac10 100755
--- a/build/tools.windows.atree
+++ b/build/tools.windows.atree
@@ -22,19 +22,19 @@
 #
 
 rm tools/android
-sdk/sdkmanager/app/etc/android.bat                tools/android.bat
+prebuilts/devtools/tools/android.bat              tools/android.bat
 
 rm tools/apkbuilder
 sdk/apkbuilder/etc/apkbuilder.bat                 tools/apkbuilder.bat
 
 rm tools/ddms
-sdk/ddms/app/etc/ddms.bat                         tools/ddms.bat
+prebuilts/devtools/tools/ddms.bat                 tools/ddms.bat
 
 rm tools/dmtracedump
 bin/dmtracedump.exe                         strip tools/dmtracedump.exe
 
 rm tools/draw9patch
-sdk/draw9patch/etc/draw9patch.bat                 tools/draw9patch.bat
+prebuilts/devtools/tools/draw9patch.bat           tools/draw9patch.bat
 
 rm tools/lint
 prebuilts/devtools/tools/lint.bat                 tools/lint.bat
@@ -67,7 +67,7 @@
 bin/etc1tool.exe                            strip tools/etc1tool.exe
 
 rm tools/hierarchyviewer
-sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat  tools/hierarchyviewer.bat
+prebuilts/devtools/tools/hierarchyviewer.bat      tools/hierarchyviewer.bat
 
 rm tools/hprof-conv
 bin/hprof-conv.exe                          strip tools/hprof-conv.exe
@@ -76,7 +76,7 @@
 bin/mksdcard.exe                            strip tools/mksdcard.exe
 
 rm tools/monkeyrunner
-sdk/monkeyrunner/etc/monkeyrunner.bat             tools/monkeyrunner.bat
+prebuilts/devtools/tools/monkeyrunner.bat         tools/monkeyrunner.bat
 
 rm tools/proguard/bin
 prebuilts/tools/common/proguard/proguard4.7/bin/proguard.bat    tools/proguard/bin/proguard.bat
@@ -87,10 +87,10 @@
 bin/sqlite3.exe                             strip tools/sqlite3.exe
 
 rm tools/traceview
-sdk/traceview/etc/traceview.bat                   tools/traceview.bat
+prebuilts/devtools/tools/traceview.bat            tools/traceview.bat
 
 rm tools/uiautomatorviewer
-sdk/uiautomatorviewer/etc/uiautomatorviewer.bat   tools/uiautomatorviewer.bat
+prebuilts/devtools/tools/uiautomatorviewer.bat    tools/uiautomatorviewer.bat
 
 rm tools/zipalign
 bin/zipalign.exe                            strip tools/zipalign.exe
diff --git a/build/windows_sdk_whitelist.mk b/build/windows_sdk_whitelist.mk
new file mode 100644
index 0000000..f10545e
--- /dev/null
+++ b/build/windows_sdk_whitelist.mk
@@ -0,0 +1,55 @@
+# Whitelist of SDK projects that can be built for the SDK on Windows
+
+# The Windows SDK cannot build all the projects from the SDK tree, typically
+# due to obvious compiler/architectures differences. When building the Windows
+# SDK, we only care about a subset of projects (e.g. generally the SDK tools
+# and a few platform-specific binaries.)
+#
+# This file defines a whitelist of projects that can be built in the Windows
+# SDK case. Note that whitelisting a project directory will NOT actually build
+# it -- it will only allow one to reference it as a make dependency.
+#
+# This file is included by build/core/main.mk.
+
+# Note that there are 2 flavors of this file:
+#
+# - This file: sdk/build/windows_sdk_whitelist.mk
+#   must list all projects that are that are NOT specific to a given platform.
+#   These binaries are the ones typically found in the SDK/tools directory.
+#
+# - The other file: development/build/windows_sdk_whitelist.mk
+#   must list all projects that are specific to a given platform. These
+#   projects generate files that are generally locates in SDK/platform-tools,
+#   or SDK/platforms/, etc.
+
+# -----
+# Whitelist of SDK specific projects that do NOT need Java (e.g. C libraries)
+
+subdirs += \
+	external/openssl \
+	external/qemu \
+	prebuilts/tools \
+	sdk/avdlauncher \
+	sdk/emulator/mksdcard \
+	sdk/emulator/opengl \
+	sdk/find_java \
+	sdk/find_lock \
+	sdk/sdklauncher
+
+# -----
+# Whitelist of SDK specific projects that DO require Java
+
+ifneq (,$(shell which javac 2>/dev/null))
+subdirs += \
+	external/ant-glob \
+	external/eclipse-windowbuilder/propertysheet \
+	external/hamcrest \
+	external/junit \
+	sdk/apkbuilder \
+	sdk/eclipse/scripts/rcp \
+	sdk/monitor \
+	sdk/testutils
+
+else
+$(warning SDK_ONLY: javac not available.)
+endif
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
index 439f785..7dccd1f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
@@ -3,7 +3,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="lib" path="libs/hierarchyviewerlib.jar" sourcepath="/hierarchyviewerlib"/>
+	<classpathentry kind="lib" path="libs/hierarchyviewer2lib.jar" sourcepath="/hierarchyviewer2lib"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
 	<classpathentry kind="output" path="bin"/>
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
index d4e8b7d..b7566ba 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
@@ -13,6 +13,6 @@
  com.android.ide.eclipse.ddms,
  com.android.ide.eclipse.base
 Bundle-ClassPath: .,
- libs/hierarchyviewerlib.jar
+ libs/hierarchyviewer2lib.jar
 Export-Package: com.android.ide.eclipse.hierarchyviewer
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh
index ec738dc..281159d 100755
--- a/eclipse/scripts/create_all_symlinks.sh
+++ b/eclipse/scripts/create_all_symlinks.sh
@@ -176,7 +176,7 @@
 ### HIERARCHYVIEWER ###
 
 HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs"
-HV_LIBS="hierarchyviewerlib swtmenubar"
+HV_LIBS="hierarchyviewer2lib swtmenubar"
 
 LIBS="$LIBS $HV_LIBS"
 CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS"
@@ -226,6 +226,9 @@
 LIBS2=""
 for LIB in $LIBS; do
   J="prebuilts/devtools/tools/lib/$LIB.jar"
+  if [[ ! -f $J ]]; then
+    J="prebuilts/devtools/adt/lib/$LIB.jar"
+  fi
   if [[ -f $J ]]; then
     warn "## Using existing $J"
   else
@@ -273,6 +276,9 @@
     # Take a prebuilts/devtools instead of a framework one if possible.
     SRC="prebuilts/devtools/tools/lib/$SRC.jar"
     if [[ ! -f "$SRC" ]]; then
+      SRC="prebuilts/devtools/adt/lib/$ORIG_SRC.jar"
+    fi
+    if [[ ! -f "$SRC" ]]; then
       SRC="out/host/$PLATFORM/framework/$ORIG_SRC.jar"
     fi
   fi
diff --git a/hierarchyviewer/Android.mk b/hierarchyviewer/Android.mk
index 110e2ed..0940457 100644
--- a/hierarchyviewer/Android.mk
+++ b/hierarchyviewer/Android.mk
@@ -12,6 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-HIERARCHYVIEWER_LOCAL_DIR := $(call my-dir)
-include $(HIERARCHYVIEWER_LOCAL_DIR)/etc/Android.mk
-include $(HIERARCHYVIEWER_LOCAL_DIR)/src/Android.mk
+#HIERARCHYVIEWER_LOCAL_DIR := $(call my-dir)
+#include $(HIERARCHYVIEWER_LOCAL_DIR)/etc/Android.mk
+#include $(HIERARCHYVIEWER_LOCAL_DIR)/src/Android.mk