Allow compiling aapt for the device

Changes:

- The static device version of libandroidfw now includes
  the extra functions needed by aapt. I could only find
  a few host tools that use the static library, so this is
  hopefully not a problem.

- The pseudolocalization code is moved into aapt.
  It was previously in libhost, but only used by aapt.

Change-Id: Ib393ebb7dcebee8abbb628cbe5255ea1679674ac
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index 9b1658a..7934757 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -7,10 +7,8 @@
 # This tool is prebuilt if we're doing an app-only build.
 ifeq ($(TARGET_BUILD_APPS),)
 
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := \
+aapt_src_files := \
 	AaptAssets.cpp \
 	Command.cpp \
 	CrunchCache.cpp \
@@ -24,23 +22,27 @@
 	ResourceTable.cpp \
 	Images.cpp \
 	Resource.cpp \
+    pseudolocalize.cpp \
     SourcePos.cpp \
     ZipEntry.cpp \
     ZipFile.cpp
 
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(aapt_src_files)
 
 LOCAL_CFLAGS += -Wno-format-y2k
 ifeq (darwin,$(HOST_OS))
 LOCAL_CFLAGS += -D_DARWIN_UNLIMITED_STREAMS
 endif
 
+LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS
 
 LOCAL_C_INCLUDES += external/libpng
 LOCAL_C_INCLUDES += external/zlib
-LOCAL_C_INCLUDES += build/libs/host/include
 
 LOCAL_STATIC_LIBRARIES := \
-	libhost \
 	libandroidfw \
 	libutils \
 	libcutils \
@@ -64,4 +66,35 @@
 
 include $(BUILD_HOST_EXECUTABLE)
 
+# aapt for running on the device
+# =========================================================
+ifneq ($(SDK_ONLY),true)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(aapt_src_files)
+
+LOCAL_MODULE := aapt
+
+LOCAL_C_INCLUDES += bionic
+LOCAL_C_INCLUDES += bionic/libstdc++/include
+LOCAL_C_INCLUDES += external/stlport/stlport
+LOCAL_C_INCLUDES += external/libpng
+LOCAL_C_INCLUDES += external/zlib
+
+LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS
+LOCAL_CFLAGS += -Wno-non-virtual-dtor
+
+LOCAL_STATIC_LIBRARIES := \
+        libstlport_static \
+        libandroidfw \
+        libutils \
+        libcutils \
+        libexpat_static \
+        libpng \
+        liblog \
+        libz
+
+include $(BUILD_EXECUTABLE)
+endif
+
 endif # TARGET_BUILD_APPS