Merge "Pass -m32 or -m64 to llvm-rs-cc when reflecting C++." into lmp-dev
diff --git a/core/Makefile b/core/Makefile
index 5064886..d39ac9c 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1416,7 +1416,7 @@
 	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
 	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
 	$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
-	$(hide) ./build/tools/releasetools/add_img_to_target_files $@
+	$(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
 
 .PHONY: target-files-package
 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 0bb218f..0af3948 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -82,18 +82,15 @@
 			-Werror=format-security \
 			-D_FORTIFY_SOURCE=2 \
 			-Wstrict-aliasing=2 \
-			-fPIC \
 			-ffunction-sections \
 			-finline-functions \
 			-finline-limit=300 \
-			-fno-inline-functions-called-once \
 			-fno-short-enums \
 			-fstrict-aliasing \
 			-funswitch-loops \
 			-funwind-tables \
 			-fstack-protector \
 			-m32 \
-			-msse2 \
 			-no-canonical-prefixes \
 			-fno-canonical-system-headers \
 			-include $(android_config_h) \
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 14fa5ed..33d6a56 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -80,11 +80,9 @@
 			-Werror=format-security \
 			-D_FORTIFY_SOURCE=2 \
 			-Wstrict-aliasing=2 \
-			-fPIC \
 			-ffunction-sections \
 			-finline-functions \
 			-finline-limit=300 \
-			-fno-inline-functions-called-once \
 			-fno-short-enums \
 			-fstrict-aliasing \
 			-funswitch-loops \
diff --git a/core/java.mk b/core/java.mk
index 52d31d0..debdf53 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -386,7 +386,7 @@
 
 # Run proguard if necessary, otherwise just copy the file.
 ifdef LOCAL_PROGUARD_ENABLED
-ifneq ($(filter-out full custom nosystem obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),)
+ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
     $(warning while processing: $(LOCAL_MODULE))
     $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
 endif
@@ -403,6 +403,9 @@
 # If this is a test package, add proguard keep flags for tests.
 ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
 proguard_flags += -include $(BUILD_SYSTEM)/proguard_tests.flags
+ifeq ($(filter shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
+proguard_flags += -dontshrink # don't shrink tests by default
+endif # shrinktests
 endif # test package
 ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
 # By default no obfuscation
diff --git a/core/proguard_tests.flags b/core/proguard_tests.flags
index 4481a1b..1f840bc 100644
--- a/core/proguard_tests.flags
+++ b/core/proguard_tests.flags
@@ -1,5 +1,6 @@
 # Keep everything for tests
--dontshrink
+# This flag has been moved to the makefiles and is set for tests by default.
+#-dontshrink
 
 # But we may want to obfuscate if the main app gets obfuscated.
 # This flag has been moved to the makefiles.
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index bcadea2..92d912b 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -42,7 +42,13 @@
 
 class Options(object): pass
 OPTIONS = Options()
-OPTIONS.search_path = "out/host/linux-x86"
+
+DEFAULT_SEARCH_PATH_BY_PLATFORM = {
+    "linux2": "out/host/linux-x86",
+    "darwin": "out/host/darwin-x86",
+    }
+OPTIONS.search_path = DEFAULT_SEARCH_PATH_BY_PLATFORM.get(sys.platform, None)
+
 OPTIONS.signapk_path = "framework/signapk.jar"  # Relative to search_path
 OPTIONS.extra_signapk_args = []
 OPTIONS.java_path = "java"  # Use the one on the path by default.
@@ -651,8 +657,9 @@
       if extra_option_handler is None or not extra_option_handler(o, a):
         assert False, "unknown option \"%s\"" % (o,)
 
-  os.environ["PATH"] = (os.path.join(OPTIONS.search_path, "bin") +
-                        os.pathsep + os.environ["PATH"])
+  if OPTIONS.search_path:
+    os.environ["PATH"] = (os.path.join(OPTIONS.search_path, "bin") +
+                          os.pathsep + os.environ["PATH"])
 
   return args