libart-compiler cleanup

- Move compile-time code to src/compiler and libart-compiler
  OatWriter, ImageWriter, ElfWriter, ElfFixup, ElfStripper, stub generation
- Move ClassReference and MethodReference to remove MethodVerifier dependency on CompilerDriver
- Move runtime_support_llvm.cc out of src/compiler and next to runtime_support.cc
- Change dex2oat and gtests to directly depend on libart-compiler
- Move non-common definitions from Android.common.mk to more specific makefiles
- Add LOCAL_ADDITIONAL_DEPENDENCIES on appropriate makefiles

Change-Id: I897027e69945914128f21f317a92caf9255bc600
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
index 83a1706..e74645c 100644
--- a/build/Android.executable.mk
+++ b/build/Android.executable.mk
@@ -14,6 +14,12 @@
 # limitations under the License.
 #
 
+DEX2OAT_SRC_FILES := \
+	src/dex2oat.cc
+
+OATDUMP_SRC_FILES := \
+	src/oatdump.cc
+
 ART_HOST_EXECUTABLES :=
 ART_TARGET_EXECUTABLES :=
 
@@ -24,24 +30,26 @@
 
 # $(1): executable ("d" will be appended for debug version)
 # $(2): source
-# $(3): target or host
-# $(4): ndebug or debug
+# $(3): shared libraries
+# $(4): target or host
+# $(5): ndebug or debug
 define build-art-executable
-  ifneq ($(3),target)
-    ifneq ($(3),host)
-      $$(error expected target or host for argument 3, received $(3))
+  ifneq ($(4),target)
+    ifneq ($(4),host)
+      $$(error expected target or host for argument 4, received $(4))
     endif
   endif
-  ifneq ($(4),ndebug)
-    ifneq ($(4),debug)
-      $$(error expected ndebug or debug for argument 4, received $(4))
+  ifneq ($(5),ndebug)
+    ifneq ($(5),debug)
+      $$(error expected ndebug or debug for argument 5, received $(5))
     endif
   endif
 
   art_executable := $(1)
   art_source := $(2)
-  art_target_or_host := $(3)
-  art_ndebug_or_debug := $(4)
+  art_shared_libraries := $(3)
+  art_target_or_host := $(4)
+  art_ndebug_or_debug := $(5)
 
   include $(CLEAR_VARS)
   ifeq ($$(art_target_or_host),target)
@@ -52,7 +60,7 @@
   LOCAL_MODULE_TAGS := optional
   LOCAL_SRC_FILES := $$(art_source)
   LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
-  LOCAL_SHARED_LIBRARIES := libnativehelper
+  LOCAL_SHARED_LIBRARIES := $$(art_shared_libraries) # libnativehelper
 
   ifeq ($$(art_ndebug_or_debug),ndebug)
     LOCAL_MODULE := $$(art_executable)
@@ -89,7 +97,8 @@
     LOCAL_SHARED_LIBRARIES += libstlport
   endif
 
-  LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.executable.mk
+  LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk
+  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.executable.mk
 
   ifeq ($$(art_target_or_host),target)
     include $(BUILD_EXECUTABLE)
@@ -102,25 +111,25 @@
 endef
 
 ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
-  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),target,ndebug))
-  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),target,ndebug))
+  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler,target,ndebug))
+  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,target,ndebug))
 endif
 ifeq ($(ART_BUILD_TARGET_DEBUG),true)
-  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),target,debug))
-  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),target,debug))
+  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler,target,debug))
+  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,target,debug))
 endif
 
 # We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
 ifeq ($(ART_BUILD_NDEBUG),true)
-  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),host,ndebug))
+  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler,host,ndebug))
 endif
 ifeq ($(ART_BUILD_NDEBUG),true)
-  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),host,debug))
+  $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler,host,debug))
 endif
 
 ifeq ($(ART_BUILD_HOST_NDEBUG),true)
-  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),host,ndebug))
+  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,host,ndebug))
 endif
 ifeq ($(ART_BUILD_HOST_DEBUG),true)
-  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),host,debug))
+  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,host,debug))
 endif