Remove libdvm support from the core build system.

Now libart is the only supported runtime and
we don't need the build variables PRODUCT_RUNTIMES and
DALVIK_VM_LIB.

Bug: 18465297
Change-Id: Ibfda931cde0649163d79b584fb5ccad927a9bc2b
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 231a04e..8b555e0 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -3,8 +3,6 @@
 #
 ####################################
 
-ifneq ($(DALVIK_VM_LIB),)
-
 # list of boot classpath jars for dexpreopt
 DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
 DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
@@ -18,6 +16,9 @@
 DEXPREOPT_BOOT_JAR_DIR := system/framework
 DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
 
+# The default value for LOCAL_DEX_PREOPT
+DEX_PREOPT_DEFAULT ?= true
+
 # $(1): the .jar or .apk to remove classes.dex
 define dexpreopt-remove-classes.dex
 $(hide) zip --quiet --delete $(1) classes.dex; \
@@ -60,7 +61,3 @@
 ifdef TARGET_2ND_ARCH
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
 endif  # TARGET_2ND_ARCH
-else
-$(warning No DALVIK_VM_LIB, disable dexpreopt.)
-WITH_DEXPREOPT := false
-endif  # DALVIK_VM_LIB is defined.
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index cb38261..f8f7723 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -50,26 +50,12 @@
 ifdef LOCAL_DEX_PREOPT
 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
 ifdef dexpreopt_boot_jar_module
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
-built_installed_odex := $(built_odex):$(installed_odex)
-else # libdvm.so
 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
 # We use this installed_odex trick to get boot.art installed.
 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
 # Append the odex for the 2nd arch if we have one.
 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
-endif # libdvm.so
 else  # boot jar
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
-built_installed_odex := $(built_odex):$(installed_odex)
-
-$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
-                $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-else # libart
 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
 # For a Java library, we build odex for both 1st arch and 2nd arch, if we have one.
 # #################################################
@@ -95,7 +81,6 @@
 endif  # LOCAL_MULTILIB is both
 endif  # TARGET_2ND_ARCH
 endif  # LOCAL_MODULE_CLASS
-endif  # libart
 endif  # boot jar
 
 ifdef built_odex
diff --git a/core/java_library.mk b/core/java_library.mk
index dffc7d9..5f7c784 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -85,12 +85,6 @@
 	$(call copy-file-to-target)
 
 # For libart boot jars, we don't have .odex files.
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex
-$(built_odex) : $(dexpreopted_boot_odex) | $(ACP)
-	$(call copy-file-to-target)
-endif
-
 else # ! boot jar
 $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
 # Use pattern rule - we may have multiple built odex files.
diff --git a/core/main.mk b/core/main.mk
index 7f4b217..8ed46ac 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -307,6 +307,7 @@
 
 # Add build properties for ART. These define system properties used by installd
 # to pass flags to dex2oat.
+ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart
 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT)
 ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
   ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
@@ -336,15 +337,14 @@
     enable_target_debugging :=
   endif
 
-  # Turn on Dalvik preoptimization for libdvm.so user builds, but only if not
+  # Turn on Dalvik preoptimization for user builds, but only if not
   # explicitly disabled and the build is running on Linux (since host
   # Dalvik isn't built for non-Linux hosts).
   ifeq (,$(WITH_DEXPREOPT))
-    ifeq ($(DALVIK_VM_LIB),libdvm.so)
-      ifeq ($(user_variant),user)
-        ifeq ($(HOST_OS),linux)
-          WITH_DEXPREOPT := true
-        endif
+    ifeq ($(user_variant),user)
+      ifeq ($(HOST_OS),linux)
+        # TODO: turn on WITH_DEXPREOPT for libart user builds.
+        # WITH_DEXPREOPT := true
       endif
     endif
   endif
diff --git a/core/product.mk b/core/product.mk
index a7a1fb2..f901a38 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -98,7 +98,6 @@
     PRODUCT_VENDOR_KERNEL_HEADERS \
     PRODUCT_FACTORY_RAMDISK_MODULES \
     PRODUCT_FACTORY_BUNDLE_MODULES \
-    PRODUCT_RUNTIMES \
     PRODUCT_BOOT_JARS \
     PRODUCT_SUPPORTS_VERITY \
     PRODUCT_OEM_PROPERTIES \
diff --git a/core/product_config.mk b/core/product_config.mk
index d4ba364..2e82381 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -248,36 +248,6 @@
 
 
 #############################################################################
-# TODO: Remove this hack once only 1 runtime is left.
-# Include the runtime product makefile based on the product's PRODUCT_RUNTIMES
-$(call clear-var-list, $(_product_var_list))
-
-# Set PRODUCT_RUNTIMES, allowing buildspec to override using OVERRIDE_RUNTIMES
-product_runtimes := $(sort $(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))
-$(foreach v, $(_product_var_list), $(if $($(v)),\
-    $(eval PRODUCTS.$(INTERNAL_PRODUCT).$(v) += $(sort $($(v))))))
-
-$(call clear-var-list, $(_product_var_list))
-# Now we can assign to PRODUCT_RUNTIMES
-PRODUCT_RUNTIMES := $(product_runtimes)
-product_runtimes :=
-
-PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES += persist.sys.dalvik.vm.lib.2=$(DALVIK_VM_LIB)
-
-ifeq ($(words $(PRODUCT_RUNTIMES)),1)
-  # If we only have one runtime, we can strip classes.dex by default during dex_preopt
-  DEX_PREOPT_DEFAULT := true
-else
-  # If we have more than one, we leave the classes.dex alone for post-boot analysis
-  DEX_PREOPT_DEFAULT := nostripping
-endif
-
-#############################################################################
 
 # A list of module names of BOOTCLASSPATH (jar files)
 PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS))
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 4c08cb0..9c5a13b 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -100,11 +100,10 @@
     ethernet-service \
     wifi-service
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.zygote=zygote32
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.zygote32.rc:root/init.zygote32.rc
 
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index d6dbe98..4f948f1 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -100,8 +100,6 @@
     services \
     wifi-service
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.zygote=zygote32
 PRODUCT_COPY_FILES += \
@@ -110,6 +108,7 @@
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.carrier=unknown
 
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
 $(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
 
diff --git a/target/product/full_mips64.mk b/target/product/full_mips64.mk
index 408e81c..e813e41 100644
--- a/target/product/full_mips64.mk
+++ b/target/product/full_mips64.mk
@@ -23,8 +23,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips64/device.mk)
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 include $(SRC_TARGET_DIR)/product/emulator.mk
 
 # Overrides
diff --git a/target/product/full_x86_64.mk b/target/product/full_x86_64.mk
index d9c0c1e..051a86e 100755
--- a/target/product/full_x86_64.mk
+++ b/target/product/full_x86_64.mk
@@ -27,8 +27,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86_64/device.mk)
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 include $(SRC_TARGET_DIR)/product/emulator.mk
 
 ifdef NET_ETH0_STARTONBOOT
diff --git a/target/product/runtime_common.mk b/target/product/runtime_common.mk
deleted file mode 100644
index 9ae182a..0000000
--- a/target/product/runtime_common.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Common runtime modules for both Dalvik and ART
-
-PRODUCT_PACKAGES += \
-    apache-xml \
-    bouncycastle \
-    cacerts \
-    conscrypt \
-    core-junit \
-    dalvikvm \
-    dexdeps \
-    dexdump \
-    dexlist \
-    dmtracedump \
-    dx \
-    ext \
-    hprof-conv \
-    libcrypto \
-    libexpat \
-    libicui18n \
-    libicuuc \
-    libjavacore \
-    libnativehelper \
-    libssl \
-    libz \
-    okhttp
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index e4200b3..a35122b 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -17,11 +17,33 @@
 # Provides a functioning ART environment without Android frameworks
 
 PRODUCT_PACKAGES += \
-        core-libart \
-        libart \
-        dex2oat \
-        oatdump \
-        patchoat
+    apache-xml \
+    bouncycastle \
+    cacerts \
+    conscrypt \
+    core-junit \
+    core-libart \
+    dalvikvm \
+    dex2oat \
+    dexdeps \
+    dexdump \
+    dexlist \
+    dmtracedump \
+    dx \
+    ext \
+    hprof-conv \
+    libart \
+    libcrypto \
+    libexpat \
+    libicui18n \
+    libicuuc \
+    libjavacore \
+    libnativehelper \
+    libssl \
+    libz \
+    oatdump \
+    okhttp \
+    patchoat
 
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     dalvik.vm.image-dex2oat-Xms=64m \
@@ -29,5 +51,3 @@
     dalvik.vm.dex2oat-Xms=64m \
     dalvik.vm.dex2oat-Xmx=512m \
     ro.dalvik.vm.native.bridge=0 \
-
-include $(SRC_TARGET_DIR)/product/runtime_common.mk
diff --git a/target/product/runtime_libart_default.mk b/target/product/runtime_libart_default.mk
deleted file mode 100644
index 2d4c793..0000000
--- a/target/product/runtime_libart_default.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Set ART as the default runtime environment
-
-DALVIK_VM_LIB := libart.so
-
-include $(SRC_TARGET_DIR)/product/runtime_libart.mk
diff --git a/target/product/runtime_libdvm.mk b/target/product/runtime_libdvm.mk
deleted file mode 100644
index 638d7d7..0000000
--- a/target/product/runtime_libdvm.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Provides a functioning Dalvik environment without Android frameworks
-
-PRODUCT_PACKAGES += \
-    core \
-    libdvm \
-    dexopt
-
-include $(SRC_TARGET_DIR)/product/runtime_common.mk
diff --git a/target/product/runtime_libdvm_default.mk b/target/product/runtime_libdvm_default.mk
deleted file mode 100644
index b581ce5..0000000
--- a/target/product/runtime_libdvm_default.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Set Dalvik as the default runtime environment
-
-DALVIK_VM_LIB := libdvm.so
-
-include $(SRC_TARGET_DIR)/product/runtime_libdvm.mk