Merge "Support `LOCAL_SDK_VERSION := current` for NDK."
diff --git a/core/binary.mk b/core/binary.mk
index f339fee..765ab36 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -788,8 +788,8 @@
 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
 	$(transform-renderscripts-to-cpp-and-bc)
 
-# include the dependency files (.d/.P) generated by llvm-rs-cc.
-$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp))
+# include the dependency files (.d) generated by llvm-rs-cc.
+$(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp))
 
 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
 
@@ -965,7 +965,7 @@
 $(foreach s,$(aidl_src),\
     $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
 $(foreach cpp,$(aidl_gen_cpp), \
-    $(call include-depfile,$(addsuffix .aidl.P,$(basename $(cpp))),$(cpp)))
+    $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp)))
 $(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
 
 $(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
@@ -1163,7 +1163,7 @@
 ifneq ($(strip $(gen_s_objects)),)
 $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
     $(my_additional_dependencies)
-	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+	$(transform-$(PRIVATE_HOST)s-to-o)
 endif
 
 gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
@@ -1313,7 +1313,7 @@
 ifneq ($(strip $(asm_objects_s)),)
 $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
     $(my_additional_dependencies)
-	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+	$(transform-$(PRIVATE_HOST)s-to-o)
 endif
 
 asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
diff --git a/core/config.mk b/core/config.mk
index 93a2d34..2fcf1fe 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -31,6 +31,37 @@
 backslash := \a
 backslash := $(patsubst %a,%,$(backslash))
 
+# this turns off the suffix rules built into make
+.SUFFIXES:
+
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
+# If a rule fails, delete $@.
+.DELETE_ON_ERROR:
+
+# Check for broken versions of make.
+ifndef KATI
+ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
+$(warning ********************************************************************************)
+$(warning *  You are using version $(MAKE_VERSION) of make.)
+$(warning *  Android can only be built by versions 3.81 and higher.)
+$(warning *  see https://source.android.com/source/download.html)
+$(warning ********************************************************************************)
+$(error stopping)
+endif
+endif
+
+# Used to force goals to build.  Only use for conditionally defined goals.
+.PHONY: FORCE
+FORCE:
+
+ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+
 # Tell python not to spam the source tree with .pyc files.  This
 # only has an effect on python 2.6 and above.
 export PYTHONDONTWRITEBYTECODE := 1
@@ -810,4 +841,25 @@
     $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
 endef
 
+# These goals don't need to collect and include Android.mks/CleanSpec.mks
+# in the source tree.
+dont_bother_goals := clean clobber dataclean installclean \
+    help out \
+    snod systemimage-nodeps \
+    stnod systemtarball-nodeps \
+    userdataimage-nodeps userdatatarball-nodeps \
+    cacheimage-nodeps \
+    bptimage-nodeps \
+    vendorimage-nodeps \
+    ramdisk-nodeps \
+    bootimage-nodeps \
+    recoveryimage-nodeps \
+    vbmetaimage-nodeps \
+    product-graph dump-products
+
+ifndef KATI
+include $(BUILD_SYSTEM)/ninja_config.mk
+include $(BUILD_SYSTEM)/soong_config.mk
+endif
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/definitions.mk b/core/definitions.mk
index 39c6604..7a42ad8 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -898,22 +898,6 @@
 endif
 
 ###########################################################
-## Commands for munging the dependency files the compiler generates
-###########################################################
-# $(1): the input .d file
-# $(2): the output .P file
-define transform-d-to-p-args
-$(hide) cp $(1) $(2); \
-	sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-		-e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \
-	rm -f $(1)
-endef
-
-define transform-d-to-p
-$(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P))
-endef
-
-###########################################################
 ## Commands for including the dependency files the compiler generates
 ###########################################################
 # $(1): the .P file
@@ -924,7 +908,7 @@
 
 # $(1): object files
 define include-depfiles-for-objs
-$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.P), $(obj)))
+$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.d), $(obj)))
 endef
 
 ###########################################################
@@ -1023,7 +1007,6 @@
   $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
   $(PRIVATE_RS_SOURCE_FILES)
 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
-$(call transform-d-to-p-args,$@.d,$@.P)
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -1060,7 +1043,6 @@
   $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
   $(PRIVATE_RS_SOURCE_FILES)
 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
-$(call transform-d-to-p-args,$@.d,$@.P)
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -1081,7 +1063,7 @@
 @mkdir -p $(dir $@)
 @mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
 @echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
-$(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \
+$(hide) $(AIDL_CPP) -d$(basename $@).aidl.d -ninja $(PRIVATE_AIDL_FLAGS) \
     $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
 endef
 
@@ -1261,7 +1243,6 @@
 $(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
   $(transform-cpp-to-o-compiler-args) \
   -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(hide) $(transform-d-to-p)
 endef
 endif
 
@@ -1310,11 +1291,10 @@
 $(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
   $(transform-c-to-o-compiler-args) \
   -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(hide) $(transform-d-to-p)
 endef
 endif
 
-define transform-s-to-o-no-deps
+define transform-s-to-o
 @echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
 @mkdir -p $(dir $@)
 $(RELATIVE_PWD) $(PRIVATE_CC) \
@@ -1322,11 +1302,6 @@
   -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
 endef
 
-define transform-s-to-o
-$(transform-s-to-o-no-deps)
-$(transform-d-to-p)
-endef
-
 # YASM compilation
 define transform-asm-to-o
 @mkdir -p $(dir $@)
@@ -1343,14 +1318,9 @@
 ## will error at build time.
 ###########################################################
 
-define transform-m-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
-$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
-endef
-
 define transform-m-to-o
-$(transform-m-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
 endef
 
 ###########################################################
@@ -1391,7 +1361,6 @@
 $(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
   $(transform-host-cpp-to-o-compiler-args) \
   -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(hide) $(transform-d-to-p)
 endef
 endif
 
@@ -1410,7 +1379,7 @@
 endef
 
 # $(1): extra flags
-define transform-host-c-or-s-to-o-no-deps
+define transform-host-c-or-s-to-o
 @mkdir -p $(dir $@)
 $(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
   $(transform-host-c-or-s-to-o-common-args) \
@@ -1444,32 +1413,21 @@
 $(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
   $(transform-host-c-to-o-compiler-args) \
   -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(hide) $(transform-d-to-p)
 endef
 endif
 
-define transform-host-s-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
-$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
-endef
-
 define transform-host-s-to-o
-$(transform-host-s-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o, $(PRIVATE_ASFLAGS))
 endef
 
 ###########################################################
 ## Commands for running gcc to compile a host Objective-C file
 ###########################################################
 
-define transform-host-m-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
-$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
-endef
-
 define transform-host-m-to-o
-$(transform-host-m-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
 endef
 
 ###########################################################
@@ -1534,7 +1492,7 @@
 define compile-dotdot-s-file-no-deps
 o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
 $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
-	$$(transform-$$(PRIVATE_HOST)s-to-o-no-deps)
+	$$(transform-$$(PRIVATE_HOST)s-to-o)
 $(3) += $$(o)
 endef
 
diff --git a/core/main.mk b/core/main.mk
index 48a39d0..6f198d5 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -9,44 +9,6 @@
 SHELL := /bin/bash
 endif
 
-# this turns off the suffix rules built into make
-.SUFFIXES:
-
-# this turns off the RCS / SCCS implicit rules of GNU Make
-% : RCS/%,v
-% : RCS/%
-% : %,v
-% : s.%
-% : SCCS/s.%
-
-# If a rule fails, delete $@.
-.DELETE_ON_ERROR:
-
-# Figure out where we are.
-#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-#TOP := $(patsubst %/,%,$(TOP))
-
-# TOPDIR is the normal variable you should use, because
-# if we are executing relative to the current directory
-# it can be "", whereas TOP must be "." which causes
-# pattern matching problems when make strips off the
-# trailing "./" from paths in various places.
-#ifeq ($(TOP),.)
-#TOPDIR :=
-#else
-#TOPDIR := $(TOP)/
-#endif
-
-# Check for broken versions of make.
-ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
-$(warning ********************************************************************************)
-$(warning *  You are using version $(MAKE_VERSION) of make.)
-$(warning *  Android can only be built by versions 3.81 and higher.)
-$(warning *  see https://source.android.com/source/download.html)
-$(warning ********************************************************************************)
-$(error stopping)
-endif
-
 # Absolute path of the present working direcotry.
 # This overrides the shell variable $PWD, which does not necessarily points to
 # the top of the source tree, for example when "make -C" is used in m/mm/mmm.
@@ -65,32 +27,6 @@
 .PHONY: droid_targets
 droid_targets:
 
-# Used to force goals to build.  Only use for conditionally defined goals.
-.PHONY: FORCE
-FORCE:
-
-# These goals don't need to collect and include Android.mks/CleanSpec.mks
-# in the source tree.
-dont_bother_goals := clean clobber dataclean installclean \
-    help out \
-    snod systemimage-nodeps \
-    stnod systemtarball-nodeps \
-    userdataimage-nodeps userdatatarball-nodeps \
-    cacheimage-nodeps \
-    bptimage-nodeps \
-    vendorimage-nodeps \
-    ramdisk-nodeps \
-    bootimage-nodeps \
-    recoveryimage-nodeps \
-    vbmetaimage-nodeps \
-    product-graph dump-products
-
-ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
-dont_bother := true
-endif
-
-ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
-
 # Targets that provide quick help on the build system.
 include $(BUILD_SYSTEM)/help.mk
 
@@ -108,6 +44,10 @@
 include build/core/ninja.mk
 else # KATI
 
+ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
+dont_bother := true
+endif
+
 include $(SOONG_MAKEVARS_MK)
 
 # Write the build number to a file so it can be read back in
diff --git a/core/ninja.mk b/core/ninja.mk
index b865a79..8a5a904 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -1,78 +1,8 @@
-ifeq ($(filter address,$(SANITIZE_HOST)),)
-NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja
-else
-NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja
-endif
-
 include $(BUILD_SYSTEM)/soong.mk
 
-KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
-
 # Modifier goals we don't need to pass to Ninja.
-NINJA_EXCLUDE_GOALS := showcommands all dist
 .PHONY : $(NINJA_EXCLUDE_GOALS)
 
-# A list of goals which affect parsing of makefiles and we need to pass to Kati.
-PARSE_TIME_MAKE_GOALS := \
-	$(PARSE_TIME_MAKE_GOALS) \
-	$(dont_bother_goals) \
-	all \
-	APP-% \
-	DUMP_% \
-	ECLIPSE-% \
-	PRODUCT-% \
-	AUX-% \
-	boottarball-nodeps \
-	brillo_tests \
-	btnod \
-	build-art% \
-	build_kernel-nodeps \
-	clean-oat% \
-	continuous_instrumentation_tests \
-	continuous_native_tests \
-	cts \
-	custom_images \
-	deps-license \
-	dicttool_aosp \
-	dist \
-	dump-products \
-	dumpvar-% \
-	eng \
-	fusion \
-	oem_image \
-	online-system-api-sdk-docs \
-	pdk \
-	platform \
-	platform-java \
-	product-graph \
-	samplecode \
-	sdk \
-	sdk_addon \
-	sdk_repo \
-	snod \
-	stnod \
-	systemimage-nodeps \
-	systemtarball-nodeps \
-	target-files-package \
-	test-art% \
-	user \
-	userdataimage \
-	userdebug \
-	valgrind-test-art% \
-	vts \
-	win_sdk \
-	winsdk-tools
-
--include vendor/google/build/ninja_config.mk
-
-# Any Android goals that need to be built.
-ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(MAKEPARALLEL),\
-    $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
-# Goals we need to pass to Ninja.
-NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
-# Goals we need to pass to Kati.
-KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS),  $(ANDROID_GOALS))
-
 define replace_space_and_slash
 $(subst /,_,$(subst $(space),_,$(sort $1)))
 endef
diff --git a/core/ninja_config.mk b/core/ninja_config.mk
new file mode 100644
index 0000000..f456b8b
--- /dev/null
+++ b/core/ninja_config.mk
@@ -0,0 +1,71 @@
+ifeq ($(filter address,$(SANITIZE_HOST)),)
+NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja
+else
+NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja
+endif
+
+KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
+
+# Modifier goals we don't need to pass to Ninja.
+NINJA_EXCLUDE_GOALS := showcommands all dist
+.PHONY : $(NINJA_EXCLUDE_GOALS)
+
+# A list of goals which affect parsing of makefiles and we need to pass to Kati.
+PARSE_TIME_MAKE_GOALS := \
+	$(PARSE_TIME_MAKE_GOALS) \
+	$(dont_bother_goals) \
+	all \
+	APP-% \
+	DUMP_% \
+	ECLIPSE-% \
+	PRODUCT-% \
+	AUX-% \
+	boottarball-nodeps \
+	brillo_tests \
+	btnod \
+	build-art% \
+	build_kernel-nodeps \
+	clean-oat% \
+	continuous_instrumentation_tests \
+	continuous_native_tests \
+	cts \
+	custom_images \
+	deps-license \
+	dicttool_aosp \
+	dist \
+	dump-products \
+	eng \
+	fusion \
+	oem_image \
+	online-system-api-sdk-docs \
+	pdk \
+	platform \
+	platform-java \
+	product-graph \
+	samplecode \
+	sdk \
+	sdk_addon \
+	sdk_repo \
+	snod \
+	stnod \
+	systemimage-nodeps \
+	systemtarball-nodeps \
+	target-files-package \
+	test-art% \
+	user \
+	userdataimage \
+	userdebug \
+	valgrind-test-art% \
+	vts \
+	win_sdk \
+	winsdk-tools
+
+include $(wildcard vendor/*/build/ninja_config.mk)
+
+# Any Android goals that need to be built.
+ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(MAKEPARALLEL),\
+    $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
+# Goals we need to pass to Ninja.
+NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
+# Goals we need to pass to Kati.
+KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS),  $(ANDROID_GOALS))
diff --git a/core/soong.mk b/core/soong.mk
index 73622a2..4a74f2e 100644
--- a/core/soong.mk
+++ b/core/soong.mk
@@ -1,11 +1,3 @@
-SOONG := $(SOONG_OUT_DIR)/soong
-SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
-SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
-SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
-SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
-SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
-SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
-
 # We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from
 # SOONG_OUT_DIR to TOP changes
 SOONG_NEEDS_REBOOTSTRAP :=
@@ -25,67 +17,6 @@
 	$(hide) mkdir -p $(dir $@)
 	$(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash
 
-BINDER32BIT :=
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-BINDER32BIT := true
-endif
-endif
-
-# Create soong.variables with copies of makefile settings.  Runs every build,
-# but only updates soong.variables if it changes
-SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
-$(SOONG_VARIABLES): FORCE
-	$(hide) mkdir -p $(dir $@)
-	$(hide) (\
-	echo '{'; \
-	echo '    "Make_suffix": "-$(TARGET_PRODUCT)",'; \
-	echo ''; \
-	echo '    "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
-	echo '    "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
-	echo '    "Brillo": $(if $(BRILLO),true,false),'; \
-	echo '    "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
-	echo '    "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \
-	echo '    "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(space),"$(comma)",$(SANITIZE_HOST))")],'; \
-	echo '    "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET))")],'; \
-	echo '    "SanitizeDeviceArch": [$(if $(SANITIZE_TARGET_ARCH),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET_ARCH))")],'; \
-	echo '    "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \
-	echo '    "Cpusets": $(if $(strip $(ENABLE_CPUSETS)),true,false),'; \
-	echo '    "Schedboost": $(if $(strip $(ENABLE_SCHEDBOOST)),true,false),'; \
-	echo '    "Binder32bit": $(if $(BINDER32BIT),true,false),'; \
-	echo '    "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \
-	echo '    "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \
-	echo '    "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \
-	echo ''; \
-	echo '    "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \
-	echo '    "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \
-	echo ''; \
-	echo '    "DeviceName": "$(TARGET_DEVICE)",'; \
-	echo '    "DeviceArch": "$(TARGET_ARCH)",'; \
-	echo '    "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
-	echo '    "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
-	echo '    "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
-	echo '    "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
-	echo ''; \
-	echo '    "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
-	echo '    "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
-	echo '    "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
-	echo '    "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
-	echo ''; \
-	echo '    "HostArch": "$(HOST_ARCH)",'; \
-	echo '    "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
-	echo ''; \
-	echo '    "CrossHost": "$(HOST_CROSS_OS)",'; \
-	echo '    "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
-	echo '    "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \
-	echo '    "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \
-	echo '}') > $(SOONG_VARIABLES_TMP); \
-	if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
-	  mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
-	else \
-	  rm $(SOONG_VARIABLES_TMP); \
-	fi
-
 # Tell soong that it is embedded in make
 $(SOONG_IN_MAKE):
 	$(hide) mkdir -p $(dir $@)
diff --git a/core/soong_config.mk b/core/soong_config.mk
new file mode 100644
index 0000000..995d9ed
--- /dev/null
+++ b/core/soong_config.mk
@@ -0,0 +1,68 @@
+SOONG := $(SOONG_OUT_DIR)/soong
+SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
+SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
+SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
+SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
+SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
+SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
+
+BINDER32BIT :=
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+BINDER32BIT := true
+endif
+endif
+
+# Create soong.variables with copies of makefile settings.  Runs every build,
+# but only updates soong.variables if it changes
+SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
+$(SOONG_VARIABLES): FORCE
+	$(hide) mkdir -p $(dir $@)
+	$(hide) (\
+	echo '{'; \
+	echo '    "Make_suffix": "-$(TARGET_PRODUCT)",'; \
+	echo ''; \
+	echo '    "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
+	echo '    "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
+	echo '    "Brillo": $(if $(BRILLO),true,false),'; \
+	echo '    "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
+	echo '    "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \
+	echo '    "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(space),"$(comma)",$(SANITIZE_HOST))")],'; \
+	echo '    "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET))")],'; \
+	echo '    "SanitizeDeviceArch": [$(if $(SANITIZE_TARGET_ARCH),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET_ARCH))")],'; \
+	echo '    "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \
+	echo '    "Cpusets": $(if $(strip $(ENABLE_CPUSETS)),true,false),'; \
+	echo '    "Schedboost": $(if $(strip $(ENABLE_SCHEDBOOST)),true,false),'; \
+	echo '    "Binder32bit": $(if $(BINDER32BIT),true,false),'; \
+	echo '    "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \
+	echo '    "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \
+	echo '    "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \
+	echo ''; \
+	echo '    "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \
+	echo '    "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \
+	echo ''; \
+	echo '    "DeviceName": "$(TARGET_DEVICE)",'; \
+	echo '    "DeviceArch": "$(TARGET_ARCH)",'; \
+	echo '    "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
+	echo '    "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
+	echo '    "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
+	echo '    "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
+	echo ''; \
+	echo '    "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
+	echo '    "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
+	echo '    "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
+	echo '    "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
+	echo ''; \
+	echo '    "HostArch": "$(HOST_ARCH)",'; \
+	echo '    "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
+	echo ''; \
+	echo '    "CrossHost": "$(HOST_CROSS_OS)",'; \
+	echo '    "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
+	echo '    "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \
+	echo '    "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \
+	echo '}') > $(SOONG_VARIABLES_TMP); \
+	if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
+	  mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
+	else \
+	  rm $(SOONG_VARIABLES_TMP); \
+	fi
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index e008640..04dc015 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -83,6 +83,7 @@
     uncrypt \
     voip-common \
     webview \
+    webview_zygote \
     wifi-service
 
 PRODUCT_COPY_FILES += \
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index 5fd4d7e..0bbcdc6 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -16,41 +16,67 @@
 
 # Provides a functioning ART environment without Android frameworks
 
+# Minimal boot classpath. This should be a subset of PRODUCT_BOOT_JARS, and equivalent to
+# TARGET_CORE_JARS.
 PRODUCT_PACKAGES += \
     apache-xml \
-    ahat \
     bouncycastle \
-    cacerts \
-    conscrypt \
     core-oj \
-    core-junit \
     core-libart \
-    dalvikvm \
-    dex2oat \
-    dexdeps \
-    dexdump \
-    dexlist \
-    dmtracedump \
-    dx \
+    conscrypt \
+    okhttp \
+
+# Additional mixins to the boot classpath.
+PRODUCT_PACKAGES += \
+    core-junit \
+
+# Why are we pulling in ext, which is frameworks/base, depending on tagsoup and nist-sip?
+PRODUCT_PACKAGES += \
     ext \
-    hprof-conv \
-    libart \
-    libart_fake \
-    libcrypto \
+
+# Why are we pulling in expat, which is used in frameworks, only, it seem?
+PRODUCT_PACKAGES += \
     libexpat \
-    libicui18n \
-    libicuuc \
+
+# Libcore.
+PRODUCT_PACKAGES += \
     libjavacore \
     libopenjdk \
     libopenjdkjvm \
-    libnativehelper \
-    libssl \
-    libz \
-    oatdump \
-    okhttp \
+
+# Libcore ICU. TODO: Try to figure out if/why we need them explicitly.
+PRODUCT_PACKAGES += \
+    libicui18n \
+    libicuuc \
+
+# ART.
+PRODUCT_PACKAGES += \
+    dalvikvm \
+    dex2oat \
+    libart \
+    libart_fake \
+    libopenjdkjvmti \
     patchoat \
     profman
 
+# ART/dex helpers.
+PRODUCT_PACKAGES += \
+    ahat \
+    dexdump \
+    dexlist \
+    oatdump \
+
+# Certificates.
+PRODUCT_PACKAGES += \
+    cacerts \
+
+# SDK dependencies. WHY ARE THEY HERE?!?!
+PRODUCT_PACKAGES += \
+    hprof-conv \
+    dexdeps \
+    dmtracedump \
+    dx \
+
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     dalvik.vm.image-dex2oat-Xms=64m \
     dalvik.vm.image-dex2oat-Xmx=64m \
diff --git a/tools/droiddoc/templates-sac/assets/css/default.css b/tools/droiddoc/templates-sac/assets/css/default.css
index 9b1fe5a..4eafa25 100644
--- a/tools/droiddoc/templates-sac/assets/css/default.css
+++ b/tools/droiddoc/templates-sac/assets/css/default.css
@@ -122,6 +122,10 @@
   padding-right:16px;
 }
 
+.nowrap {
+  white-space: nowrap;
+}
+
 img {
   border: none; }
 #jd-content img {
diff --git a/tools/fs_config/README b/tools/fs_config/README
index 7eca4a3..0258687 100644
--- a/tools/fs_config/README
+++ b/tools/fs_config/README
@@ -67,8 +67,9 @@
    * hex (0xFF)
   For multiple caps, just separate by whitespace.
 
-It is an error to specify multiple sections with the same [path]. Per the ini
-specifications enforced by Pythons ConfigParser.
+It is an error to specify multiple sections with the same [path] in different
+files. Note that the same file may contain sections that override the previous
+section in Python versions <= 3.2. In Python 3.2 it's set to strict mode.
 
 
 The next section type is the "AID" section, for specifying OEM specific AIDS.
@@ -84,13 +85,13 @@
   The <name> can be any valid character for a #define identifier in C.
 
 value:
-  A valid C style number string. Hex, octal, binary and decimal are supported. See "caps"
-  above for more details on number formatting.
+  A valid C style number string. Hex, octal, binary and decimal are supported.
+  See "caps" above for more details on number formatting.
 
-It is an error to specify multiple sections with the same [AID_<name>]. Per the ini
-specifications enforced by Pythons ConfigParser. It is also an error to specify
-multiple sections with the same value option. It is also an error to specify a value
-that is outside of the inclusive OEM ranges:
+It is an error to specify multiple sections with the same [AID_<name>]. With
+the same constraints as [path] described above. It is also an error to specify
+multiple sections with the same value option. It is also an error to specify a
+value that is outside of the inclusive OEM ranges:
  * AID_OEM_RESERVED_START(2900) - AID_OEM_RESERVED_END(2999)
  * AID_OEM_RESERVED_2_START(5000) - AID_OEM_RESERVED_2_END(5999)
 
diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py
index 482c2bc..6a16fea 100755
--- a/tools/fs_config/fs_config_generator.py
+++ b/tools/fs_config/fs_config_generator.py
@@ -183,8 +183,6 @@
     are_aids = len(aids) > 0
 
     if are_aids:
-        # sort on value of (file_name, name, value, strvalue)
-        aids.sort(key=lambda x: x[2])
         for a in aids:
             # use the preserved str value
             print FILE_COMMENT % a[0]
@@ -272,7 +270,24 @@
     for x in sys.argv[1:]:
         parse(x, files, dirs, aids, seen_paths, seen_aids)
 
+    # sort entries:
+    # * specified path before prefix match
+    # ** ie foo before f*
+    # * lexicographical less than before other
+    # ** ie boo before foo
+    # Given these paths:
+    # paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*']
+    # The sort order would be:
+    # paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*']
+    # Thus the fs_config tools will match on specified paths before attempting
+    # prefix, and match on the longest matching prefix.
     files.sort(key= lambda x: file_key(x[1]))
+
+    # sort on value of (file_name, name, value, strvalue)
+    # This is only cosmetic so AIDS are arranged in ascending order
+    # within the generated file.
+    aids.sort(key=lambda x: x[2])
+
     generate(files, dirs, aids)
 
 if __name__ == '__main__':
diff --git a/tools/warn.py b/tools/warn.py
index 355d120..5c49cd3 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -84,6 +84,8 @@
 import multiprocessing
 import os
 import re
+import signal
+import sys
 
 parser = argparse.ArgumentParser(description='Convert a build log into HTML')
 parser.add_argument('--gencsv',
@@ -2090,11 +2092,16 @@
   results = []
   for line in lines:
     classify_one_warning(line, results)
+  # After the main work, ignore all other signals to a child process,
+  # to avoid bad warning/error messages from the exit clean-up process.
+  if args.processes > 1:
+    signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
   return results
 
 
 def parallel_classify_warnings(warning_lines):
   """Classify all warning lines with num_cpu parallel processes."""
+  compile_patterns()
   num_cpu = args.processes
   if num_cpu > 1:
     groups = [[] for x in range(num_cpu)]
@@ -2177,17 +2184,15 @@
     return line
 
 
-def parse_input_file():
+def parse_input_file(infile):
   """Parse input file, match warning lines."""
   global platform_version
   global target_product
   global target_variant
-  infile = open(args.buildlog, 'r')
   line_counter = 0
 
   # handle only warning messages with a file path
   warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
-  compile_patterns()
 
   # Collect all warnings into the warning_lines set.
   warning_lines = set()
@@ -2207,7 +2212,7 @@
       m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
       if m is not None:
         target_variant = m.group(0)
-  parallel_classify_warnings(warning_lines)
+  return warning_lines
 
 
 # Return s with escaped backslash and quotation characters.
@@ -2503,7 +2508,8 @@
 
 
 def main():
-  parse_input_file()
+  warning_lines = parse_input_file(open(args.buildlog, 'r'))
+  parallel_classify_warnings(warning_lines)
   if args.gencsv:
     dump_csv()
   else: