Merge "Package breakpad symbols in target files zip"
diff --git a/core/binary.mk b/core/binary.mk
index 093cc38..403cff5 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -254,9 +254,10 @@
     my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
     my_fdo_build := true
   endif
-  # Disable ccache (or other compiler wrapper).
-  my_cc_wrapper :=
-  my_cxx_wrapper :=
+  # Disable ccache (or other compiler wrapper) except gomacc, which
+  # can handle -fprofile-use properly.
+  my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper))
+  my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper))
 endif
 
 ###########################################################
diff --git a/core/clang/config.mk b/core/clang/config.mk
index ae5df08..e15586f 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -47,6 +47,11 @@
 CLANG_CONFIG_EXTRA_CPPFLAGS += \
   -Wno-inconsistent-missing-override
 
+# Force clang to always output color diagnostics.  Ninja will strip the ANSI
+# color codes if it is not running in a terminal.
+CLANG_CONFIG_EXTRA_CFLAGS += \
+  -fcolor-diagnostics
+
 CLANG_CONFIG_UNKNOWN_CFLAGS := \
   -finline-functions \
   -finline-limit=64 \
@@ -70,7 +75,8 @@
   -Wno-unused-but-set-variable \
   -Wno-unused-local-typedefs \
   -Wunused-but-set-parameter \
-  -Wunused-but-set-variable
+  -Wunused-but-set-variable \
+  -fdiagnostics-color
 
 # Clang flags for all host rules
 CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index d0d4ff9..f4f96d8 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -133,7 +133,6 @@
 LOCAL_RENDERSCRIPT_CC:=
 LOCAL_RENDERSCRIPT_COMPATIBILITY:=
 LOCAL_RENDERSCRIPT_FLAGS:=
-LOCAL_RENDERSCRIPT_SKIP_INSTALL:=
 LOCAL_RENDERSCRIPT_TARGET_API:=
 LOCAL_DEX_PREOPT:= # '',true,false,nostripping
 LOCAL_DEX_PREOPT_IMAGE_LOCATION:=
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index 99f17aa..5dc1fec 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -24,7 +24,7 @@
 	arch_variant_ldflags := \
 		-Wl,--fix-cortex-a8
 else
-ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a7)
+ifneq (,$(filter cortex-a7 cortex-a53 cortex-a53.a57,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
 	arch_variant_cflags := -mcpu=cortex-a7
 	arch_variant_ldflags := \
 		-Wl,--no-fix-cortex-a8
diff --git a/core/config.mk b/core/config.mk
index 12308fd..0a01f41 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -120,6 +120,13 @@
 COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
 COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
 
+# Force gcc to always output color diagnostics.  Ninja will strip the ANSI
+# color codes if it is not running in a terminal.
+# Use host and target GLOBAL_CFLAGS so it doesn't apply to HOST_CROSS, the windows
+# toolchain is still 4.8 and doesn't support color.
+HOST_GLOBAL_CFLAGS += -fdiagnostics-color
+TARGET_GLOBAL_CFLAGS += -fdiagnostics-color
+
 COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
 COMMON_RELEASE_CPPFLAGS:=
 
diff --git a/core/goma.mk b/core/goma.mk
index 7fc6c46..ddd7d80 100644
--- a/core/goma.mk
+++ b/core/goma.mk
@@ -16,13 +16,14 @@
 
 # Notice: this works only with Google's Goma build infrastructure.
 ifneq ($(USE_GOMA),)
-  # Check if USE_NINJA is defined because GNU make won't work well
-  # with goma. Note this file is evaluated twice, once with
-  # USE_NINJA=true by GNU make and once with USE_NINJA=false by kati
-  # which is invoked by GNU make. So, we cannot test the value of
-  # USE_NINJA.
-  ifndef USE_NINJA
-    $(error USE_GOMA=true works only with USE_NINJA=true)
+  # Check if USE_NINJA is not false because GNU make won't work well
+  # with goma. Note this file is evaluated twice, once by GNU make and
+  # once by kati with USE_NINJA=false. We do this check in the former
+  # pass.
+  ifndef KATI
+    ifeq ($(USE_NINJA),false)
+      $(error USE_GOMA=true is not compatible with USE_NINJA=false)
+    endif
   endif
 
   # Goma requires a lot of processes and file descriptors.
@@ -41,7 +42,7 @@
     goma_dir := $(HOME)/goma
   endif
   goma_ctl := $(goma_dir)/goma_ctl.py
-  goma_cc := $(goma_dir)/gomacc
+  GOMA_CC := $(goma_dir)/gomacc
 
   $(if $(wildcard $(goma_ctl)),, \
    $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \
@@ -49,20 +50,14 @@
 
   # Append gomacc to existing *_WRAPPER variables so it's possible to
   # use both ccache and gomacc.
-  CC_WRAPPER := $(strip $(CC_WRAPPER) $(goma_cc))
-  CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(goma_cc))
-
-  # Ninja file generated by kati uses this for remote jobs (i.e.,
-  # commands which contain gomacc). Note the parallelism of all other
-  # jobs will be limited the number of cores.
-  KATI_REMOTE_NUM_JOBS_FLAG := --remote_num_jobs=500
+  CC_WRAPPER := $(strip $(CC_WRAPPER) $(GOMA_CC))
+  CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(GOMA_CC))
 
   # gomacc can start goma client's daemon process automatically, but
   # it is safer and faster to start up it beforehand. We run this as a
   # background process so this won't slow down the build.
   $(shell $(goma_ctl) ensure_start &> /dev/null &)
 
-  goma_cc :=
   goma_ctl :=
   goma_dir :=
 endif
diff --git a/core/host_test_internal.mk b/core/host_test_internal.mk
index 06949ed..7f6aff0 100644
--- a/core/host_test_internal.mk
+++ b/core/host_test_internal.mk
@@ -11,4 +11,4 @@
 LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g
 LOCAL_C_INCLUDES +=  external/gtest/include
 
-LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host
+LOCAL_STATIC_LIBRARIES += libgtest_main_host libgtest_host
diff --git a/core/java.mk b/core/java.mk
index f3b57b8..66825d1 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -353,28 +353,6 @@
 endif
 endif
 
-# Install the RS compatibility libraries to /system/lib/ if necessary
-ifdef rs_compatibility_jni_libs
-installed_rs_compatibility_jni_libs := $(addprefix $(TARGET_OUT_SHARED_LIBRARIES)/,\
-    $(notdir $(rs_compatibility_jni_libs)))
-# Provide a way to skip sources included in multiple projects.
-ifdef LOCAL_RENDERSCRIPT_SKIP_INSTALL
-skip_install_rs_libs := $(patsubst %.rs,%.so, \
-    $(addprefix $(TARGET_OUT_SHARED_LIBRARIES)/librs., \
-    $(notdir $(LOCAL_RENDERSCRIPT_SKIP_INSTALL))))
-installed_rs_compatibility_jni_libs := \
-    $(filter-out $(skip_install_rs_libs),$(installed_rs_compatibility_jni_libs))
-endif
-ifneq (,$(strip $(installed_rs_compatibility_jni_libs)))
-$(installed_rs_compatibility_jni_libs) : $(TARGET_OUT_SHARED_LIBRARIES)/lib%.so : \
-    $(renderscript_intermediate)/lib%.so
-	$(hide) mkdir -p $(dir $@) && cp -f $< $@
-
-# Install them only if the current module is installed.
-$(LOCAL_INSTALLED_MODULE) : $(installed_rs_compatibility_jni_libs)
-endif
-endif
-
 # Since we're using intermediates.COMMON, make sure that it gets cleaned
 # properly.
 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
diff --git a/core/main.mk b/core/main.mk
index f860f54..760a054 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -60,7 +60,10 @@
 # This is the default target.  It must be the first declared target.
 .PHONY: droid
 DEFAULT_GOAL := droid
-$(DEFAULT_GOAL):
+$(DEFAULT_GOAL): droid_targets
+
+.PHONY: droid_targets
+droid_targets:
 
 # Used to force goals to build.  Only use for conditionally defined goals.
 .PHONY: FORCE
@@ -836,12 +839,9 @@
 # -------------------------------------------------------------------
 
 .PHONY: checkbuild
-checkbuild: $(modules_to_check)
-ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild))
+checkbuild: $(modules_to_check) droid_targets
+ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
 droid: checkbuild
-else
-# ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals.
-checkbuild: droid
 endif
 
 .PHONY: ramdisk
@@ -937,7 +937,7 @@
 .PHONY: apps_only
 apps_only: $(unbundled_build_modules)
 
-droid: apps_only
+droid_targets: apps_only
 
 # Combine the NOTICE files for a apps_only build
 $(eval $(call combine-notice-files, \
@@ -983,7 +983,7 @@
   endif
 
 # Building a full system-- the default is to build droidcore
-droid: droidcore dist_files
+droid_targets: droidcore dist_files
 
 endif # TARGET_BUILD_APPS
 
diff --git a/core/ninja.mk b/core/ninja.mk
index b9a0cec..2d0af34 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -7,7 +7,6 @@
 PARSE_TIME_MAKE_GOALS := \
 	$(PARSE_TIME_MAKE_GOALS) \
 	$(dont_bother_goals) \
-	tests \
 	APP-% \
 	DUMP_% \
 	ECLIPSE-% \
@@ -16,7 +15,6 @@
 	btnod \
 	build-art% \
 	build_kernel-nodeps \
-	checkbuild \
 	clean-oat% \
 	continuous_instrumentation_tests \
 	continuous_native_tests \
@@ -105,8 +103,13 @@
 showcommands: droid
 endif
 
-ifdef KATI_REMOTE_NUM_JOBS_FLAG
+ifdef USE_GOMA
 KATI_MAKEPARALLEL := $(MAKEPARALLEL)
+# Ninja runs remote jobs (i.e., commands which contain gomacc) with
+# this parallelism. Note the parallelism of all other jobs is still
+# limited by the -j flag passed to GNU make.
+NINJA_REMOTE_NUM_JOBS ?= 500
+NINJA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
 else
 NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
 endif
@@ -133,7 +136,7 @@
 .INTERMEDIATE: kati.intermediate
 kati.intermediate: $(KATI) $(MAKEPARALLEL)
 	@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
-	+$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator $(KATI_REMOTE_NUM_JOBS_FLAG) -f build/core/main.mk $(or $(KATI_TARGETS),--gen_all_phony_targets) USE_NINJA=false
+	+$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator -f build/core/main.mk $(or $(KATI_TARGETS),--gen_all_phony_targets) USE_NINJA=false
 
 KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
 KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
index f8a9f04..4715fe8 100644
--- a/core/target_test_internal.mk
+++ b/core/target_test_internal.mk
@@ -7,9 +7,9 @@
 LOCAL_C_INCLUDES += external/gtest/include
 
 ifndef LOCAL_SDK_VERSION
-LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
+LOCAL_STATIC_LIBRARIES += libgtest_main libgtest
 else
-LOCAL_STATIC_LIBRARIES += libgtest_ndk libgtest_main_ndk
+LOCAL_STATIC_LIBRARIES += libgtest_main_ndk libgtest_ndk
 endif
 
 ifdef LOCAL_MODULE_PATH
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index 3a8a4aa..3be6e80 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -26,6 +26,7 @@
 PRODUCT_PACKAGES += \
     egl.cfg \
     gralloc.goldfish \
+    gralloc.ranchu \
     libGLESv1_CM_emulation \
     lib_renderControl_enc \
     libEGL_emulation \
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index e98eb8f..cbf78a1 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -208,11 +208,13 @@
         common.ZipWriteStr(output_tf_zip, out_info, data)
     elif info.filename in ("SYSTEM/build.prop",
                            "VENDOR/build.prop",
+                           "BOOT/RAMDISK/default.prop",
                            "RECOVERY/RAMDISK/default.prop"):
       print "rewriting %s:" % (info.filename,)
       new_data = RewriteProps(data, misc_info)
       common.ZipWriteStr(output_tf_zip, out_info, new_data)
-      if info.filename == "RECOVERY/RAMDISK/default.prop":
+      if info.filename in ("BOOT/RAMDISK/default.prop",
+                           "RECOVERY/RAMDISK/default.prop"):
         write_to_temp(info.filename, info.external_attr, new_data)
     elif info.filename.endswith("mac_permissions.xml"):
       print "rewriting %s with new keys." % (info.filename,)
@@ -317,6 +319,10 @@
         pieces = value.split("/")
         pieces[-1] = EditTags(pieces[-1])
         value = "/".join(pieces)
+      elif key == "ro.bootimage.build.fingerprint":
+        pieces = value.split("/")
+        pieces[-1] = EditTags(pieces[-1])
+        value = "/".join(pieces)
       elif key == "ro.build.description":
         pieces = value.split(" ")
         assert len(pieces) == 5