Merge "Add layoutlib-tests to sdk build."
diff --git a/core/Makefile b/core/Makefile
index 237245b..351dd15 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -16,17 +16,16 @@
 # e.g., "system/etc/file.xml".
 # The filter part means "only eval the copy-one-file rule if this
 # src:dest pair is the first one to match the same dest"
-unique_product_copy_files_destinations := $(sort \
-    $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
+unique_product_copy_files_destinations :=
 $(foreach cf,$(PRODUCT_COPY_FILES), \
     $(eval _src := $(call word-colon,1,$(cf))) \
     $(eval _dest := $(call word-colon,2,$(cf))) \
-    $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
+    $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
         $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
         $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
         $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
-        $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
-            $(unique_product_copy_files_destinations)))))
+        $(eval unique_product_copy_files_destinations += $(_dest))))
+unique_product_copy_files_destinations :=
 
 # -----------------------------------------------------------------
 # docs/index.html
@@ -41,9 +40,11 @@
 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
 ADDITIONAL_DEFAULT_PROPERTIES := \
-	$(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+    $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
 ADDITIONAL_DEFAULT_PROPERTIES += \
-	$(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+    $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(ADDITIONAL_DEFAULT_PROPERTIES),=)
 
 $(INSTALLED_DEFAULT_PROP_TARGET):
 	@echo Target buildinfo: $@
@@ -60,7 +61,9 @@
 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
 ADDITIONAL_BUILD_PROPERTIES := \
-	$(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+    $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(ADDITIONAL_BUILD_PROPERTIES),=)
 
 # A list of arbitrary tags describing the build configuration.
 # Force ":=" so we can use +=
diff --git a/core/definitions.mk b/core/definitions.mk
index 9251017..4c499ad 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -600,6 +600,21 @@
 endef
 
 ###########################################################
+## Given a list of pairs, if multiple pairs have the same
+## first components, keep only the first pair.
+##
+## $(1): list of pairs
+## $(2): the separator word, such as ":", "=", etc.
+define uniq-pairs-by-first-component
+$(eval _upbfc_fc_set :=)\
+$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
+    $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
+        $(eval _upbfc_fc_set += $(_first)))))\
+$(eval _upbfc_fc_set :=)\
+$(eval _first:=)
+endef
+
+###########################################################
 ## MODULE_TAG set operations
 ###########################################################
 
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 800a9bf..b02d8c6 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -36,18 +36,6 @@
 TARGET_BUILD_VARIANT := eng
 endif
 
-# Read the product specs so we an get TARGET_DEVICE and other
-# variables that we need in order to locate the output files.
-include $(BUILD_SYSTEM)/product_config.mk
-
-build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
-ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
-$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
-$(error must be empty or one of: eng user userdebug tests)
-endif
-
-
-
 # ---------------------------------------------------------------
 # Set up configuration for host machine.  We don't do cross-
 # compiles except for arm, so the HOST is whatever we are
@@ -119,17 +107,15 @@
   HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
 endif
 
-# Default to building dalvikvm on hosts that support it...
-ifeq ($(HOST_OS),linux)
-# ... but not if we're building the sim...
-ifneq ($(TARGET_SIMULATOR),true)
-# ... or if the if the option is already set
-ifeq ($(WITH_HOST_DALVIK),)
-	WITH_HOST_DALVIK := true
-endif
-endif
-endif
+# Read the product specs so we an get TARGET_DEVICE and other
+# variables that we need in order to locate the output files.
+include $(BUILD_SYSTEM)/product_config.mk
 
+build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
+ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
+$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
+$(error must be empty or one of: eng user userdebug tests)
+endif
 
 # ---------------------------------------------------------------
 # Set up configuration for target machine.
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 428594f..78dee49 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -48,7 +48,8 @@
     libthread_db:bionic/libthread_db/include \
     mkbootimg:system/core/mkbootimg \
     recovery:bootable/recovery \
-    system-core:system/core/include
+    system-core:system/core/include \
+    speex:external/speex/include
 
 #
 # Returns the path to the requested module's include directory,
diff --git a/core/product_config.mk b/core/product_config.mk
index 6dc8221..d766ba7 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -164,6 +164,27 @@
 endif # unbundled_goals
 
 # ---------------------------------------------------------------
+# Simulator overrides
+ifeq ($(TARGET_PRODUCT),sim)
+  # Tell the build system to turn on some special cases
+  # to deal with the simulator product.
+  TARGET_SIMULATOR := true
+  # dexpreopt doesn't work when building the simulator
+  DISABLE_DEXPREOPT := true
+endif
+
+# Default to building dalvikvm on hosts that support it...
+ifeq ($(HOST_OS),linux)
+# ... but not if we're building the sim...
+ifneq ($(TARGET_SIMULATOR),true)
+# ... or if the if the option is already set
+ifeq ($(WITH_HOST_DALVIK),)
+  WITH_HOST_DALVIK := true
+endif
+endif
+endif
+
+# ---------------------------------------------------------------
 # Include the product definitions.
 # We need to do this to translate TARGET_PRODUCT into its
 # underlying TARGET_DEVICE before we start defining any rules.
@@ -303,14 +324,3 @@
 
 PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
-
-
-# ---------------------------------------------------------------
-# Simulator overrides
-ifeq ($(TARGET_PRODUCT),sim)
-  # Tell the build system to turn on some special cases
-  # to deal with the simulator product.
-  TARGET_SIMULATOR := true
-  # dexpreopt doesn't work when building the simulator
-  DISABLE_DEXPREOPT := true
-endif
diff --git a/target/product/core.mk b/target/product/core.mk
index 604b87c..6c8e21f 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -94,11 +94,13 @@
     Bugreport \
     ip \
     screencap \
-    sensorservice
+    sensorservice \
+    libspeexresampler
 
 # host-only dependencies
 ifeq ($(WITH_HOST_DALVIK),true)
     PRODUCT_PACKAGES += \
+        apache-xml-hostdex \
         bouncycastle-hostdex \
         core-hostdex \
         libjavacore-host \
diff --git a/target/product/languages_full.mk b/target/product/languages_full.mk
index 236dfa2..b18f78f 100644
--- a/target/product/languages_full.mk
+++ b/target/product/languages_full.mk
@@ -21,7 +21,5 @@
 
 # Those are all the locales that have translations and are displayable
 # by TextView in this branch.
-PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH
-
-# Not currently usable:
-# ar, fa, th
+PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA
+# We don't have the fonts to display am_ET yet