HACK: add 64-bit directory blacklist

Change-Id: I431e8b220db81d51930dc0b3d95995df120c179a
diff --git a/core/64_bit_blacklist.mk b/core/64_bit_blacklist.mk
new file mode 100644
index 0000000..71a5cf3
--- /dev/null
+++ b/core/64_bit_blacklist.mk
@@ -0,0 +1,53 @@
+ifneq ($(TARGET_2ND_ARCH),)
+
+# JNI - needs 64-bit VM
+_64_bit_directory_blacklist += \
+	external/conscrypt \
+	external/neven \
+	external/svox \
+	libcore \
+	packages \
+
+# Chromium/V8: needs 64-bit support
+_64_bit_directory_blacklist += \
+	external/chromium \
+	external/chromium-libpac \
+	external/chromium_org \
+	external/skia \
+	external/v8 \
+	frameworks/webview \
+
+# misc build errors
+_64_bit_directory_blacklist += \
+	external/bluetooth/bluedroid \
+	external/oprofile/opcontrol \
+	external/tcpdump \
+	frameworks/av \
+	frameworks/base \
+	frameworks/ex \
+	frameworks/ml \
+	frameworks/opt \
+	frameworks/wilhelm \
+	device/generic/goldfish/opengl \
+	device/generic/goldfish/camera \
+
+# depends on libnl_2
+_64_bit_directory_blacklist += \
+	external/android-clat \
+	external/wpa_suplicant_8
+
+# depends on frameworks/av
+_64_bit_directory_blacklist += \
+	external/srec \
+	hardware/libhardware_legacy/audio \
+	hardware/libhardware/modules/audio_remote_submix \
+
+_64_bit_directory_blacklist_pattern := $(addsuffix %,$(_64_bit_directory_blacklist))
+
+define directory_is_64_bit_blacklisted
+$(if $(filter $(_64_bit_directory_blacklist_pattern),$(1)),true)
+endef
+else
+define directory_is_64_bit_blacklisted
+endef
+endif
diff --git a/core/Makefile b/core/Makefile
index 2bcf0cf..d76aca6 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -644,6 +644,10 @@
 
 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
 
+# HACK: clear LOCAL_PATH from including last build target before calling
+# intermedites-dir-for
+LOCAL_PATH := $(call my-dir)
+
 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
diff --git a/core/definitions.mk b/core/definitions.mk
index e0e9608..cb324dd 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -450,11 +450,13 @@
     $(if $(_idfName),, \
         $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
     $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \
-    $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
+    $(eval _idf2ndArchPrefix := $(if $(call directory_is_64_bit_blacklisted,$(LOCAL_PATH))$(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
     $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
         $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
-      , \
-        $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
+      ,$(if $(filter $(_idfPrefix)-$(_idfClass),TARGET-SHARED_LIBRARIES TARGET-STATIC_LIBRARIES TARGET-EXECUTABLES),\
+          $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
+       ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
+       ) \
      ) \
     $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
 )
diff --git a/core/main.mk b/core/main.mk
index 871f51b..ee22a91 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -92,6 +92,8 @@
 # and host information.
 include $(BUILD_SYSTEM)/config.mk
 
+include $(BUILD_SYSTEM)/64_bit_blacklist.mk
+
 # This allows us to force a clean build - included after the config.mk
 # environment setup is done, but before we generate any dependencies.  This
 # file does the rm -rf inline so the deps which are all done below will
diff --git a/core/module_arch_supported.mk b/core/module_arch_supported.mk
index 49cf8dd..ddfd67d 100644
--- a/core/module_arch_supported.mk
+++ b/core/module_arch_supported.mk
@@ -22,6 +22,8 @@
 ifeq ($(LOCAL_2ND_ARCH_VAR_PREFIX),)
 ifeq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
 my_module_arch_supported := false
+else ifeq ($(call directory_is_64_bit_blacklisted,$(LOCAL_PATH)),true)
+my_module_arch_supported := false
 endif
 else # LOCAL_2ND_ARCH_VAR_PREFIX
 ifeq ($(LOCAL_NO_2ND_ARCH),true)
diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk
index c51a40c..96557e3 100644
--- a/core/tasks/vendor_module_check.mk
+++ b/core/tasks/vendor_module_check.mk
@@ -71,11 +71,12 @@
 
 $(foreach m, $(_vendor_check_modules), \
   $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
-    $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
-      $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
-        "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
-    $(if $(ALL_MODULES.$(m).INSTALLED),\
-      $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER)))))
+    $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
+      $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
+        $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
+          "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
+      $(if $(ALL_MODULES.$(m).INSTALLED),\
+        $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER))))))
 
 endif