Merge "Add support for TARGET_RECOVERY_BRICK."
diff --git a/core/base_rules.mk b/core/base_rules.mk
index c4fbe11..30b6c1c 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -261,7 +261,7 @@
 ## logtags: Add .logtags files to global list
 ###########################################################
 
-logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
+logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES)
 
 ifneq ($(strip $(logtags_sources)),)
 event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index bc1eefb..9ca880b 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -197,6 +197,7 @@
 # to avoid installing the presigned apks with classes.dex unstripped.
 LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=
 LOCAL_NDK_VERSION:=current
+LOCAL_LOGTAGS_FILES:=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(TARGET_ARCH):=
diff --git a/core/definitions.mk b/core/definitions.mk
index 7409e37..7572070 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -137,17 +137,33 @@
  )
 endef
 
+
+define _filter-soong-makefile
+$(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(1))),\
+  $(info skipping $(1) ...)\
+    $(call _filter-soong-bpfile $(patsubst %/Android.mk,%/Android.bp,$(1))),\
+  $(1))
+endef
+
+define _filter-soong-bpfile
+$(if $(wildcard $(patsubst %/Android.bp,%/Android.soong.mk,$(1))),\
+  $(patsubst %/Android.bp,%/Android.soong.mk,$(1)))
+endef
+
 ###########################################################
 ## Remove any makefiles that are being handled by soong
+##
+## If passed an Android.mk file, returns the Android.mk file
+## if no Android.bp file exists and the same path.  If an
+## Android.bp file exists, or if passed an Android.bp file,
+## returns the Android.soong.mk file at the same path if it
+## exists, or nothing if it does not.
 ###########################################################
 define filter-soong-makefiles
-$(foreach mk,$(1),\
-  $(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(mk))),\
-    $(if $(wildcard $(patsubst %/Android.mk,%/Android.soong.mk,$(mk))),\
-      $(info skipping $(mk), but including Android.soong.mk ...)\
-        $(patsubst %/Android.mk,%/Android.soong.mk,$(mk)),\
-      $(info skipping $(mk) ...)),\
-    $(mk)))
+$(sort $(foreach mk,$(1),\
+  $(if $(filter %/Android.bp,$(mk)),\
+    $(call _filter-soong-bpfile,$(mk)),\
+    $(call _filter-soong-makefile,$(mk)))))
 endef
 
 ###########################################################
@@ -155,7 +171,7 @@
 ###########################################################
 
 define all-makefiles-under
-$(sort $(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk)))
+$(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk $(1)/*/Android.bp))
 endef
 
 ###########################################################
@@ -168,7 +184,7 @@
 define first-makefiles-under
 $(call filter-soong-makefiles,\
   $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
-        --mindepth=2 $(1) Android.mk))
+        --mindepth=2 $(addprefix --dir=,$(1)) Android.bp Android.mk))
 endef
 
 ###########################################################
@@ -188,8 +204,9 @@
 
 # $(1): List of directories to look for under this directory
 define all-named-subdir-makefiles
-$(sort $(call filter-soong-makefiles,\
-  $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))))
+$(call filter-soong-makefiles,\
+  $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))\
+  $(wildcard $(addsuffix /Android.bp, $(addprefix $(call my-dir)/,$(1)))))
 endef
 
 ###########################################################
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 1bd4777..4b3486a 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -35,10 +35,15 @@
 # what to add to the path given the config we have chosen.
 ifeq ($(CALLED_FROM_SETUP),true)
 
-ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),)
-ABP:=$(HOST_OUT_EXECUTABLES)
+ifneq ($(filter /%,$(SOONG_HOST_OUT_EXECUTABLES)),)
+ABP := $(SOONG_HOST_OUT_EXECUTABLES)
 else
-ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
+ABP := $(PWD)/$(SOONG_HOST_OUT_EXECUTABLES)
+endif
+ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),)
+ABP := $(ABP):$(HOST_OUT_EXECUTABLES)
+else
+ABP := $(ABP):$(PWD)/$(HOST_OUT_EXECUTABLES)
 endif
 
 ANDROID_BUILD_PATHS := $(ABP)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index f1c37c8..4b48b27 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -204,6 +204,8 @@
 endif
 endif
 
+SOONG_OUT_DIR := $(OUT_DIR)/soong
+
 DEBUG_OUT_DIR := $(OUT_DIR)/debug
 
 # Move the host or target under the debug/ directory
@@ -220,6 +222,7 @@
 HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
+SOONG_HOST_OUT := $(SOONG_OUT_DIR)/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 # TODO: remove
 BUILD_OUT := $(HOST_OUT)
 
@@ -237,6 +240,7 @@
 OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
 
 BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
+SOONG_HOST_OUT_EXECUTABLES := $(SOONG_HOST_OUT)/bin
 
 HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
 HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
diff --git a/core/main.mk b/core/main.mk
index 9866dff..2c97fcf 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -376,6 +376,7 @@
 ifneq (,$(user_variant))
   # Target is secure in user builds.
   ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
+  ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1
 
   ifeq ($(user_variant),user)
     ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
@@ -501,7 +502,6 @@
 #
 # Typical build; include any Android.mk files we can find.
 #
-subdirs := $(TOP)
 
 FULL_BUILD := true
 
@@ -542,14 +542,9 @@
 # Include all of the makefiles in the system
 #
 
-# Can't use first-makefiles-under here because
-# --mindepth=2 makes the prunes not work.
-subdir_makefiles := \
-	$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) $(subdirs) Android.mk)
+subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
 
-subdir_makefiles := $(SOONG_ANDROID_MK) $(call filter-soong-makefiles,$(subdir_makefiles))
-
-$(foreach mk, $(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
+$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
 
 ifdef PDK_FUSION_PLATFORM_ZIP
 # Bring in the PDK platform.zip modules.
diff --git a/core/ninja.mk b/core/ninja.mk
index 589affe..bbd5863 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -101,7 +101,7 @@
 endif
 
 ifeq (,$(NINJA_STATUS))
-NINJA_STATUS := [%p %s/%t]$(space)
+NINJA_STATUS := [%p %f/%t]$(space)
 endif
 
 NINJA_EXTRA_ARGS :=
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index f1edc8a..7b83467 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -13,7 +13,10 @@
   my_prefix := TARGET_
 
   ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
-    LOCAL_MULTILIB := first
+    # Only support prebuilt shared and static libraries for translated arch
+    ifeq ($(filter SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+      LOCAL_MULTILIB := first
+    endif
   endif
 endif
 
diff --git a/core/soong.mk b/core/soong.mk
index 2f36be9..c2c9e6c 100644
--- a/core/soong.mk
+++ b/core/soong.mk
@@ -1,4 +1,3 @@
-SOONG_OUT_DIR := $(OUT_DIR)/soong
 SOONG := $(SOONG_OUT_DIR)/soong
 SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
 SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja