Move from WITH_ART to PRODUCT_RUNTIMES

Change-Id: I3a9217b4aafc1f59d095169deb9eaeae17320505
diff --git a/core/config.mk b/core/config.mk
index e7ee49f..beb4b31 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -123,7 +123,7 @@
 
 # ---------------------------------------------------------------
 # Try to include buildspec.mk, which will try to set stuff up.
-# If this file doesn't exist, the environemnt variables will
+# If this file doesn't exist, the environment variables will
 # be used, and if that doesn't work, then the default is an
 # arm build
 ifndef ANDROID_BUILDSPEC
diff --git a/core/product.mk b/core/product.mk
index bbd0c31..89bce1d 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -95,7 +95,8 @@
     PRODUCT_RESTRICT_VENDOR_FILES \
     PRODUCT_VENDOR_KERNEL_HEADERS \
     PRODUCT_FACTORY_RAMDISK_MODULES \
-    PRODUCT_FACTORY_BUNDLE_MODULES
+    PRODUCT_FACTORY_BUNDLE_MODULES \
+    PRODUCT_RUNTIMES
 
 
 define dump-product
diff --git a/core/product_config.mk b/core/product_config.mk
index c8955f6..5c6975e 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -170,10 +170,6 @@
 endif
 endif
 
-ifeq ($(WITH_ART),)
-  WITH_ART := false
-endif
-
 # ---------------------------------------------------------------
 # Include the product definitions.
 # We need to do this to translate TARGET_PRODUCT into its
@@ -356,11 +352,6 @@
 PRODUCT_VENDOR_KERNEL_HEADERS := \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_KERNEL_HEADERS)
 
-# Add the product-defined properties to the build properties.
-ADDITIONAL_BUILD_PROPERTIES := \
-    $(ADDITIONAL_BUILD_PROPERTIES) \
-    $(PRODUCT_PROPERTY_OVERRIDES)
-
 # The OTA key(s) specified by the product config, if any.  The names
 # of these keys are stored in the target-files zip so that post-build
 # signing tools can substitute them for the test key embedded by
@@ -370,3 +361,29 @@
 
 PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
+
+# Set PRODUCT_RUNTIME, allowing buildspec to override using OVERRIDE_RUNTIMES
+PRODUCT_RUNTIMES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RUNTIMES))
+ifneq ($(OVERRIDE_RUNTIMES),)
+    $(info Overriding PRODUCT_RUNTIMES=$(PRODUCT_RUNTIMES) with $(OVERRIDE_RUNTIMES))
+    PRODUCT_RUNTIMES := $(OVERRIDE_RUNTIMES)
+endif
+$(foreach runtime, $(PRODUCT_RUNTIMES), $(eval include $(SRC_TARGET_DIR)/product/$(runtime).mk))
+PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES += $(PRODUCT_PACKAGES)
+PRODUCT_PACKAGES :=
+
+# Add the product-defined properties to the build properties.
+#
+# Note that PRODUCT_PROPERTY_OVERRIDES can be extended by processing
+# the PRODUCT_PACKAGES which is why this is below that.
+#
+ADDITIONAL_BUILD_PROPERTIES := \
+    $(ADDITIONAL_BUILD_PROPERTIES) \
+    $(PRODUCT_PROPERTY_OVERRIDES)
+
+# ************************************************************************ 
+# ADD NEW PRODUCT_* VARIABLES ABOVE PRODUCT_RUNTIMES
+#
+# This is because including the PRODUCT_RUNTIMES can add to other
+# PRODUCT_* variables.
+# ************************************************************************