Convert more of art to Android.bp

Relanding I1b10f140e17dd5e12a9d7f6a29d47cf61f5bf6ef, with fixes to
compile dalvikvm32 and dalvikvm64, and add them as dependencies of
tests.  Also fixes HOST_PREFER_32_BIT by moving the override from the
defaults, which are not used by everything in art, to the art_cc_binary
module type.

Test: rm -rf out/host; m -j HOST_PREFER_32_BIT test-art-host; m -j test-art-host
Change-Id: I64d3eef5080e128103d052497760c3521cc253c6
diff --git a/build/Android.bp b/build/Android.bp
index ed9f308..ec374f2 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -108,6 +108,11 @@
                 // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
                 "-fno-omit-frame-pointer",
             ],
+            host_ldlibs: [
+                "-ldl",
+                "-lpthread",
+                "-lrt",
+            ],
         },
     },
 
diff --git a/build/Android.common_path.mk b/build/Android.common_path.mk
index 3f25ae1..e88d027 100644
--- a/build/Android.common_path.mk
+++ b/build/Android.common_path.mk
@@ -123,7 +123,7 @@
 
 # Depend on the -target or -host phony targets generated by the build system
 # for each module
-ART_TARGET_EXECUTABLES :=
+ART_TARGET_EXECUTABLES := dalvikvm-target
 ifneq ($(ART_BUILD_TARGET_NDEBUG),false)
 ART_TARGET_EXECUTABLES += $(foreach name,$(ART_CORE_EXECUTABLES),$(name)-target)
 endif
@@ -131,7 +131,7 @@
 ART_TARGET_EXECUTABLES += $(foreach name,$(ART_CORE_EXECUTABLES),$(name)d-target)
 endif
 
-ART_HOST_EXECUTABLES :=
+ART_HOST_EXECUTABLES := dalvikvm-host
 ifneq ($(ART_BUILD_HOST_NDEBUG),false)
 ART_HOST_EXECUTABLES += $(foreach name,$(ART_CORE_EXECUTABLES),$(name)-host)
 endif
diff --git a/build/art.go b/build/art.go
index d41b407..9cab3b9 100644
--- a/build/art.go
+++ b/build/art.go
@@ -137,7 +137,26 @@
 	p.Target.Android.Cflags = deviceFlags(ctx)
 	p.Target.Host.Cflags = hostFlags(ctx)
 	ctx.AppendProperties(p)
+}
 
+type artGlobalDefaults struct{}
+
+func (a *artCustomLinkerCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) {
+	linker := envDefault(ctx, "CUSTOM_TARGET_LINKER", "")
+	if linker != "" {
+		type props struct {
+			DynamicLinker string
+		}
+
+		p := &props{}
+		p.DynamicLinker = linker
+		ctx.AppendProperties(p)
+	}
+}
+
+type artCustomLinkerCustomizer struct{}
+
+func (a *artPrefer32BitCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) {
 	if envTrue(ctx, "HOST_PREFER_32_BIT") {
 		type props struct {
 			Target struct {
@@ -153,22 +172,7 @@
 	}
 }
 
-type artGlobalDefaults struct{}
-
-func (a *artLinkerCustomizer) CustomizeProperties(ctx android.CustomizePropertiesContext) {
-	linker := envDefault(ctx, "CUSTOM_TARGET_LINKER", "")
-	if linker != "" {
-		type props struct {
-			DynamicLinker string
-		}
-
-		p := &props{}
-		p.DynamicLinker = linker
-		ctx.AppendProperties(p)
-	}
-}
-
-type artLinkerCustomizer struct{}
+type artPrefer32BitCustomizer struct{}
 
 func init() {
 	soong.RegisterModuleType("art_cc_library", artLibrary)
@@ -200,6 +204,7 @@
 	c := &codegenCustomizer{}
 	android.AddCustomizer(library, c)
 	props = append(props, &c.codegenProperties)
+
 	return module, props
 }
 
@@ -207,7 +212,8 @@
 	binary, _ := cc.NewBinary(android.HostAndDeviceSupported)
 	module, props := binary.Init()
 
-	android.AddCustomizer(binary, &artLinkerCustomizer{})
+	android.AddCustomizer(binary, &artCustomLinkerCustomizer{})
+	android.AddCustomizer(binary, &artPrefer32BitCustomizer{})
 	return module, props
 }