am 202c962b: am 8f73aeea: am 183f90f4: am 3ffcf184: Merge "Remove -Bsymbolic from builds."
* commit '202c962b0500be38014904c96e740b3e63ce8ece':
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 6f436ce..7175b0e 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -276,6 +276,11 @@
# Change ro.zygote for core_64_bit.mk from zygote32_64 to zygote64_32
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Adding dalvik.vm.dex2oat-Xms, dalvik.vm.dex2oat-Xmx
+# dalvik.vm.image-dex2oat-Xms, and dalvik.vm.image-dex2oat-Xmx
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/core/Makefile b/core/Makefile
index 12d4915..bc33495 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -472,7 +472,22 @@
@echo "make $@: ignoring dependencies"
$(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
-else # TARGET_BOOTIMAGE_USE_EXT2 != true
+else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
+ $(call pretty,"Target boot image: $@")
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
+ $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@
+ $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+.PHONY: bootimage-nodeps
+bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
+ @echo "make $@: ignoring dependencies"
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
+ $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $(INSTALLED_BOOTIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+else # PRODUCT_SUPPORTS_VERITY != true
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
@@ -1191,7 +1206,8 @@
$(HOST_OUT_EXECUTABLES)/syspatch_host \
$(HOST_OUT_EXECUTABLES)/build_verity_tree \
$(HOST_OUT_EXECUTABLES)/verity_signer \
- $(HOST_OUT_EXECUTABLES)/append2simg
+ $(HOST_OUT_EXECUTABLES)/append2simg \
+ $(HOST_OUT_EXECUTABLES)/boot_signer
OTATOOLS := $(DISTTOOLS) \
$(HOST_OUT_EXECUTABLES)/aapt
diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk
index 8ad3ba7..0bc0227 100644
--- a/core/combo/HOST_darwin-x86_64.mk
+++ b/core/combo/HOST_darwin-x86_64.mk
@@ -17,8 +17,6 @@
# Configuration for Darwin (Mac OS X) on x86_64.
# Included by combo/select.mk
-HOST_IS_64_BIT := true
-
HOST_GLOBAL_CFLAGS += -m64
HOST_GLOBAL_LDFLAGS += -m64
diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk
index 8f3a311..53a3ae8 100644
--- a/core/combo/HOST_linux-x86_64.mk
+++ b/core/combo/HOST_linux-x86_64.mk
@@ -17,8 +17,6 @@
# Configuration for builds hosted on linux-x86_64.
# Included by combo/select.mk
-HOST_IS_64_BIT := true
-
ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),)
HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-
endif
diff --git a/core/combo/HOST_windows-x86_64.mk b/core/combo/HOST_windows-x86_64.mk
index 9edc619..c77d82c 100644
--- a/core/combo/HOST_windows-x86_64.mk
+++ b/core/combo/HOST_windows-x86_64.mk
@@ -22,8 +22,6 @@
TOOLS_PREFIX := #prebuilt/windows/host/bin/
TOOLS_EXE_SUFFIX := .exe
-HOST_IS_64_BIT := true
-
# Settings to use MinGW has a cross-compiler under Linux
ifneq ($(findstring Linux,$(UNAME)),)
ifneq ($(strip $(USE_MINGW)),)
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index bca69a5..02c4b99 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -43,8 +43,6 @@
TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
endif
-TARGET_IS_64_BIT := true
-
TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
$(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT))
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index c53cf4b..aa456ef 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -43,8 +43,6 @@
TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
endif
-TARGET_IS_64_BIT := true
-
TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
$(error Unknown MIPS architecture variant: $(TARGET_ARCH_VARIANT))
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 2933e54..f6a9fc8 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -31,8 +31,6 @@
TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
endif
-TARGET_IS_64_BIT := true
-
# Include the arch-variant-specific configuration file.
# Its role is to define various ARCH_X86_HAVE_XXX feature macros,
# plus initial values for TARGET_GLOBAL_CFLAGS
diff --git a/core/config.mk b/core/config.mk
index c4d088d..0e612a7 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -405,6 +405,7 @@
APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
+BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
# ACP is always for the build OS, not for the host OS
ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 411af75..8fc0c67 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -27,6 +27,15 @@
LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
endif
+define get-product-default-property
+$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
+endef
+
+DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
+DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
+DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
+DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
+
########################################################################
# The full system boot classpath
@@ -68,7 +77,7 @@
$(hide) rm -f $(2)
$(hide) mkdir -p $(dir $(2))
$(hide) $(DEX2OATD) \
- --runtime-arg -Xms64m --runtime-arg -Xmx64m \
+ --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
--dex-file=$(1) \
--dex-location=$(PRIVATE_DEX_LOCATION) \
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 70130b6..7eefc0b 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -43,7 +43,8 @@
@echo "target dex2oat: $@ ($?)"
@mkdir -p $(dir $@)
@mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
- $(hide) $(DEX2OATD) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) \
+ $(hide) $(DEX2OATD) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
+ --image-classes=$(PRELOADED_CLASSES) \
$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
--oat-symbols=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED) \
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index caaa16d..613b058 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -9,11 +9,13 @@
else # WITH_DEXPREOPT=true
ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty
ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
- ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
- LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
- else # LOCAL_APK_LIBRARIES not empty
- LOCAL_DEX_PREOPT := nostripping
- endif # LOCAL_APK_LIBRARIES not empty
+ ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img.
+ ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
+ LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
+ else # LOCAL_APK_LIBRARIES not empty
+ LOCAL_DEX_PREOPT := nostripping
+ endif # LOCAL_APK_LIBRARIES not empty
+ endif # Installed to system.img.
endif # LOCAL_DEX_PREOPT undefined
endif # TARGET_BUILD_APPS empty
endif # WITH_DEXPREOPT=true
diff --git a/core/envsetup.mk b/core/envsetup.mk
index e968fef..fcbc91f 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -72,19 +72,13 @@
ifeq (,$(BUILD_HOST_64bit))
# Default to 32-bit-by-default multilib host build.
HOST_PREFER_32_BIT := true
-ifeq ($(HOST_PREFER_32_BIT),true)
-BUILD_HOST_64bit := true
-endif
endif
# HOST_ARCH
ifneq (,$(findstring x86_64,$(UNAME)))
HOST_ARCH := x86_64
HOST_2ND_ARCH := x86
-else ifneq (,$(findstring 86,$(UNAME)))
- # It's not officially supported!
- HOST_ARCH := x86
- HOST_2ND_ARCH :=
+ HOST_IS_64_BIT := true
endif
ifeq ($(HOST_PREFER_32_BIT),true)
@@ -171,6 +165,9 @@
TARGET_OS := linux
# TARGET_ARCH should be set by BoardConfig.mk and will be checked later
+ifneq ($(filter %64,$(TARGET_ARCH)),)
+TARGET_IS_64_BIT := true
+endif
# the target build type defaults to release
ifneq ($(TARGET_BUILD_TYPE),debug)
@@ -219,11 +216,7 @@
BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
-ifeq (x86_64,$(HOST_ARCH))
HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
-else
-HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
-endif
HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
@@ -260,7 +253,7 @@
TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin
TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin
-ifneq ($(filter %64,$(TARGET_ARCH)),)
+ifeq ($(TARGET_IS_64_BIT),true)
# /system/lib always contains 32-bit libraries,
# and /system/lib64 (if present) always contains 64-bit libraries.
TARGET_OUT_SHARED_LIBRARIES := $(TARGET_OUT)/lib64
@@ -294,19 +287,24 @@
TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
+ifeq ($(TARGET_IS_64_BIT),true)
+TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64
+else
TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
+endif
TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR)/bin
TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES := $(TARGET_OUT_VENDOR)/xbin
-ifneq ($(filter %64,$(TARGET_ARCH)),)
+ifeq ($(TARGET_IS_64_BIT),true)
TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib64
else
TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib
diff --git a/core/post_clean.mk b/core/post_clean.mk
index 746ec2f..9f15b6d 100644
--- a/core/post_clean.mk
+++ b/core/post_clean.mk
@@ -59,12 +59,16 @@
previous_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_aidl_config.mk
current_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_aidl_config.mk
-$(shell rm -rf $(current_aidl_config) && mkdir -p $(dir $(current_aidl_config)))
+$(shell rm -rf $(current_aidl_config) \
+ && mkdir -p $(dir $(current_aidl_config))\
+ && touch $(current_aidl_config))
-include $(previous_aidl_config)
intermediates_to_clean :=
+modules_with_aidl_files :=
$(foreach p, $(ALL_MODULES), \
$(if $(ALL_MODULES.$(p).AIDL_FILES),\
+ $(eval modules_with_aidl_files += $(p))\
$(shell echo 'AIDL_FILES.$(p) := $(ALL_MODULES.$(p).AIDL_FILES)' >> $(current_aidl_config)))\
$(if $(filter-out $(ALL_MODULES.$(p).AIDL_FILES),$(AIDL_FILES.$(p))),\
$(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR))))
@@ -75,8 +79,17 @@
intermediates_to_clean :=
endif
+# For modules not loaded by the current build (e.g. you are running mm/mmm),
+# we copy the info from the previous bulid.
+$(foreach p, $(filter-out $(modules_with_aidl_files),$(MODULES_WITH_AIDL_FILES)),\
+ $(shell echo 'AIDL_FILES.$(p) := $(AIDL_FILES.$(p))' >> $(current_aidl_config)))
+MODULES_WITH_AIDL_FILES := $(sort $(MODULES_WITH_AIDL_FILES) $(modules_with_aidl_files))
+$(shell echo 'MODULES_WITH_AIDL_FILES := $(MODULES_WITH_AIDL_FILES)' >> $(current_aidl_config))
+
# Now current becomes previous.
$(shell mv -f $(current_aidl_config) $(previous_aidl_config))
+MODULES_WITH_AIDL_FILES :=
+modules_with_aidl_files :=
previous_aidl_config :=
current_aidl_config :=
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
index 87503ea..95d4159 100644
--- a/core/target_test_internal.mk
+++ b/core/target_test_internal.mk
@@ -31,5 +31,5 @@
$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
endif
-LOCAL_MODULE_PATH_32 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)64/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
diff --git a/envsetup.sh b/envsetup.sh
index b63182f..36c6896 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1517,8 +1517,8 @@
fi
# Execute the contents of any vendorsetup.sh files we can find.
-for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
- `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
+for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
+ `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
do
echo "including $f"
. $f
diff --git a/target/product/core.mk b/target/product/core.mk
index 875d08c..c0a24d3 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -25,6 +25,7 @@
Calculator \
Calendar \
CalendarProvider \
+ CaptivePortalLogin \
CertInstaller \
Contacts \
DeskClock \
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index a6b0984..48abfa5 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -75,7 +75,8 @@
telephony-common \
voip-common \
logd \
- mms-common
+ mms-common \
+ wifi-service
# The order matters
PRODUCT_BOOT_JARS := \
@@ -94,7 +95,8 @@
android.policy \
services \
apache-xml \
- nullwebview
+ nullwebview \
+ wifi-service
PRODUCT_RUNTIMES := runtime_libart_default
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index de4cf17..6cb8818 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -22,4 +22,10 @@
dex2oat \
oatdump
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ dalvik.vm.image-dex2oat-Xms=64m \
+ dalvik.vm.image-dex2oat-Xmx=64m \
+ dalvik.vm.dex2oat-Xms=64m \
+ dalvik.vm.dex2oat-Xmx=512m \
+
include $(SRC_TARGET_DIR)/product/runtime_common.mk
diff --git a/tools/adbs b/tools/adbs
index a9bc7c2..a8f06c0 100755
--- a/tools/adbs
+++ b/tools/adbs
@@ -15,206 +15,30 @@
# limitations under the License.
import os
+import os.path
import re
import string
import sys
-###############################################################################
-# match "#00 pc 0003f52e /system/lib/libdvm.so" for example
-###############################################################################
-trace_line = re.compile("(.*)(\#[0-9]+) {1,2}(..) ([0-9a-f]{8}) ([^\r\n \t]*)")
-
-# returns a list containing the function name and the file/lineno
-def CallAddr2Line(lib, addr):
- global symbols_dir
- global addr2line_cmd
- global cppfilt_cmd
-
- if lib != "":
- cmd = addr2line_cmd + \
- " -f -e " + symbols_dir + lib + " 0x" + addr
- stream = os.popen(cmd)
- lines = stream.readlines()
- list = map(string.strip, lines)
- else:
- list = []
- if list != []:
- # Name like "move_forward_type<JavaVMOption>" causes troubles
- mangled_name = re.sub('<', '\<', list[0]);
- mangled_name = re.sub('>', '\>', mangled_name);
- cmd = cppfilt_cmd + " " + mangled_name
- stream = os.popen(cmd)
- list[0] = stream.readline()
- stream.close()
- list = map(string.strip, list)
- else:
- list = [ "(unknown)", "(unknown)" ]
- return list
-
-
-###############################################################################
-# similar to CallAddr2Line, but using objdump to find out the name of the
-# containing function of the specified address
-###############################################################################
-def CallObjdump(lib, addr):
- global objdump_cmd
- global symbols_dir
-
- unknown = "(unknown)"
- uname = os.uname()[0]
- if uname == "Darwin":
- proc = os.uname()[-1]
- if proc == "i386":
- uname = "darwin-x86"
- else:
- uname = "darwin-ppc"
- elif uname == "Linux":
- uname = "linux-x86"
- if lib != "":
- next_addr = string.atoi(addr, 16) + 1
- cmd = objdump_cmd \
- + " -C -d --start-address=0x" + addr + " --stop-address=" \
- + str(next_addr) \
- + " " + symbols_dir + lib
- stream = os.popen(cmd)
- lines = stream.readlines()
- map(string.strip, lines)
- stream.close()
- else:
- return unknown
-
- # output looks like
- #
- # file format elf32-littlearm
- #
- # Disassembly of section .text:
- #
- # 0000833c <func+0x4>:
- # 833c: 701a strb r2, [r3, #0]
- #
- # we want to extract the "func" part
- num_lines = len(lines)
- if num_lines < 2:
- return unknown
- func_name = lines[num_lines-2]
- func_regexp = re.compile("(^.*\<)(.*)(\+.*\>:$)")
- components = func_regexp.match(func_name)
- if components is None:
- return unknown
- return components.group(2)
-
-###############################################################################
-# determine the symbols directory in the local build
-###############################################################################
-def FindSymbolsDir():
- global symbols_dir
-
- try:
- path = os.environ['ANDROID_PRODUCT_OUT'] + "/symbols"
- except:
- cmd = "CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core " \
- + "SRC_TARGET_DIR=build/target make -f build/core/config.mk " \
- + "dumpvar-abs-TARGET_OUT_UNSTRIPPED"
- stream = os.popen(cmd)
- str = stream.read()
- stream.close()
- path = str.strip()
-
- if (not os.path.exists(path)):
- print path + " not found!"
- sys.exit(1)
-
- symbols_dir = path
-
-###############################################################################
-# determine the path of binutils
-###############################################################################
-def SetupToolsPath():
- global addr2line_cmd
- global objdump_cmd
- global cppfilt_cmd
- global symbols_dir
-
- uname = os.uname()[0]
- if uname == "Darwin":
- uname = "darwin-x86"
- elif uname == "Linux":
- uname = "linux-x86"
- gcc_version = os.environ["TARGET_GCC_VERSION"]
- prefix = "./prebuilts/gcc/" + uname + "/arm/arm-linux-androideabi-" + \
- gcc_version + "/bin/"
- addr2line_cmd = prefix + "arm-linux-androideabi-addr2line"
-
- if (not os.path.exists(addr2line_cmd)):
- try:
- prefix = os.environ['ANDROID_BUILD_TOP'] + "/prebuilts/gcc/" + \
- uname + "/arm/arm-linux-androideabi-" + gcc_version + "/bin/"
- except:
- prefix = "";
-
- addr2line_cmd = prefix + "arm-linux-androideabi-addr2line"
- if (not os.path.exists(addr2line_cmd)):
- print addr2line_cmd + " not found!"
- sys.exit(1)
-
- objdump_cmd = prefix + "arm-linux-androideabi-objdump"
- cppfilt_cmd = prefix + "arm-linux-androideabi-c++filt"
-
-###############################################################################
-# look up the function and file/line number for a raw stack trace line
-# groups[0]: log tag
-# groups[1]: stack level
-# groups[2]: "pc"
-# groups[3]: code address
-# groups[4]: library name
-###############################################################################
-def SymbolTranslation(groups):
- lib_name = groups[4]
- code_addr = groups[3]
- caller = CallObjdump(lib_name, code_addr)
- func_line_pair = CallAddr2Line(lib_name, code_addr)
-
- # If a callee is inlined to the caller, objdump will see the caller's
- # address but addr2line will report the callee's address. So the printed
- # format is desgined to be "caller<-callee file:line"
- if (func_line_pair[0] != caller):
- print groups[0] + groups[1] + " " + caller + "<-" + \
- ' '.join(func_line_pair[:]) + " "
- else:
- print groups[0] + groups[1] + " " + ' '.join(func_line_pair[:]) + " "
-
-###############################################################################
+sys.path.insert(0, os.path.dirname(__file__) + "/../../development/scripts")
+import stack_core
+import symbol
if __name__ == '__main__':
# pass the options to adb
adb_cmd = "adb " + ' '.join(sys.argv[1:])
- # setup addr2line_cmd and objdump_cmd
- SetupToolsPath()
-
- # setup the symbols directory
- FindSymbolsDir()
+ # create tracer for line parsing
+ tracer = stack_core.TraceConverter()
# invoke the adb command and filter its output
stream = os.popen(adb_cmd)
while (True):
line = stream.readline()
-
- # EOF reached
if (line == ''):
break
-
- # remove the trailing \n
- line = line.strip()
-
- # see if this is a stack trace line
- match = trace_line.match(line)
- if (match):
- groups = match.groups()
- # translate raw address into symbols
- SymbolTranslation(groups)
- else:
- print line
+ if(tracer.ProcessLine(line) == False):
+ print(line.strip())
sys.stdout.flush()
# adb itself aborts
diff --git a/tools/zipalign/Android.mk b/tools/zipalign/Android.mk
index 708c8bf..7986798 100644
--- a/tools/zipalign/Android.mk
+++ b/tools/zipalign/Android.mk
@@ -12,13 +12,15 @@
ZipEntry.cpp \
ZipFile.cpp
-LOCAL_C_INCLUDES += external/zlib
+LOCAL_C_INCLUDES += external/zlib \
+ external/zopfli/src
LOCAL_STATIC_LIBRARIES := \
libandroidfw \
libutils \
libcutils \
- liblog
+ liblog \
+ libzopfli
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index 8b2d1af..dc2826b 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -32,19 +32,20 @@
fprintf(stderr, "Zip alignment utility\n");
fprintf(stderr, "Copyright (C) 2009 The Android Open Source Project\n\n");
fprintf(stderr,
- "Usage: zipalign [-f] [-v] <align> infile.zip outfile.zip\n"
+ "Usage: zipalign [-f] [-v] [-z] <align> infile.zip outfile.zip\n"
" zipalign -c [-v] <align> infile.zip\n\n" );
fprintf(stderr,
" <align>: alignment in bytes, e.g. '4' provides 32-bit alignment\n");
fprintf(stderr, " -c: check alignment only (does not modify file)\n");
fprintf(stderr, " -f: overwrite existing outfile.zip\n");
fprintf(stderr, " -v: verbose output\n");
+ fprintf(stderr, " -z: recompress using Zopfli\n");
}
/*
* Copy all entries from "pZin" to "pZout", aligning as needed.
*/
-static int copyAndAlign(ZipFile* pZin, ZipFile* pZout, int alignment)
+static int copyAndAlign(ZipFile* pZin, ZipFile* pZout, int alignment, bool zopfli)
{
int numEntries = pZin->getNumEntries();
ZipEntry* pEntry;
@@ -67,6 +68,12 @@
// pEntry->getFileName(), (long) pEntry->getFileOffset(),
// (long) pEntry->getUncompressedLen());
+ if (zopfli) {
+ status = pZout->addRecompress(pZin, pEntry, &pNewEntry);
+ bias += pNewEntry->getCompressedLen() - pEntry->getCompressedLen();
+ } else {
+ status = pZout->add(pZin, pEntry, padding, &pNewEntry);
+ }
} else {
/*
* Copy the entry, adjusting as required. We assume that the
@@ -79,9 +86,9 @@
//printf("--- %s: orig at %ld(+%d) len=%ld, adding pad=%d\n",
// pEntry->getFileName(), (long) pEntry->getFileOffset(),
// bias, (long) pEntry->getUncompressedLen(), padding);
+ status = pZout->add(pZin, pEntry, padding, &pNewEntry);
}
- status = pZout->add(pZin, pEntry, padding, &pNewEntry);
if (status != NO_ERROR)
return 1;
bias += padding;
@@ -98,7 +105,7 @@
* output file exists and "force" wasn't specified.
*/
static int process(const char* inFileName, const char* outFileName,
- int alignment, bool force)
+ int alignment, bool force, bool zopfli)
{
ZipFile zin, zout;
@@ -129,7 +136,7 @@
return 1;
}
- int result = copyAndAlign(&zin, &zout, alignment);
+ int result = copyAndAlign(&zin, &zout, alignment, zopfli);
if (result != 0) {
printf("zipalign: failed rewriting '%s' to '%s'\n",
inFileName, outFileName);
@@ -196,6 +203,7 @@
bool check = false;
bool force = false;
bool verbose = false;
+ bool zopfli = false;
int result = 1;
int alignment;
char* endp;
@@ -222,6 +230,9 @@
case 'v':
verbose = true;
break;
+ case 'z':
+ zopfli = true;
+ break;
default:
fprintf(stderr, "ERROR: unknown flag -%c\n", *cp);
wantUsage = true;
@@ -252,7 +263,7 @@
result = verify(argv[1], alignment, verbose);
} else {
/* create the new archive */
- result = process(argv[1], argv[2], alignment, force);
+ result = process(argv[1], argv[2], alignment, force, zopfli);
/* trust, but verify */
if (result == 0)
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 8057068..3c5ec15 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -28,6 +28,8 @@
#include <zlib.h>
#define DEF_MEM_LEVEL 8 // normally in zutil.h?
+#include "zopfli/deflate.h"
+
#include <memory.h>
#include <sys/stat.h>
#include <errno.h>
@@ -638,6 +640,141 @@
}
/*
+ * Add an entry by copying it from another zip file, recompressing with
+ * Zopfli if already compressed.
+ *
+ * If "ppEntry" is non-NULL, a pointer to the new entry will be returned.
+ */
+status_t ZipFile::addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
+ ZipEntry** ppEntry)
+{
+ ZipEntry* pEntry = NULL;
+ status_t result;
+ long lfhPosn, startPosn, endPosn, uncompressedLen;
+
+ if (mReadOnly)
+ return INVALID_OPERATION;
+
+ /* make sure we're in a reasonable state */
+ assert(mZipFp != NULL);
+ assert(mEntries.size() == mEOCD.mTotalNumEntries);
+
+ if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0) {
+ result = UNKNOWN_ERROR;
+ goto bail;
+ }
+
+ pEntry = new ZipEntry;
+ if (pEntry == NULL) {
+ result = NO_MEMORY;
+ goto bail;
+ }
+
+ result = pEntry->initFromExternal(pSourceZip, pSourceEntry);
+ if (result != NO_ERROR)
+ goto bail;
+
+ /*
+ * From here on out, failures are more interesting.
+ */
+ mNeedCDRewrite = true;
+
+ /*
+ * Write the LFH, even though it's still mostly blank. We need it
+ * as a place-holder. In theory the LFH isn't necessary, but in
+ * practice some utilities demand it.
+ */
+ lfhPosn = ftell(mZipFp);
+ pEntry->mLFH.write(mZipFp);
+ startPosn = ftell(mZipFp);
+
+ /*
+ * Copy the data over.
+ *
+ * If the "has data descriptor" flag is set, we want to copy the DD
+ * fields as well. This is a fixed-size area immediately following
+ * the data.
+ */
+ if (fseek(pSourceZip->mZipFp, pSourceEntry->getFileOffset(), SEEK_SET) != 0)
+ {
+ result = UNKNOWN_ERROR;
+ goto bail;
+ }
+
+ uncompressedLen = pSourceEntry->getUncompressedLen();
+
+ if (pSourceEntry->isCompressed()) {
+ void *buf = pSourceZip->uncompress(pSourceEntry);
+ if (buf == NULL) {
+ result = NO_MEMORY;
+ goto bail;
+ }
+ long startPosn = ftell(mZipFp);
+ unsigned long crc;
+ if (compressFpToFp(mZipFp, NULL, buf, uncompressedLen, &crc) != NO_ERROR) {
+ ALOGW("recompress of '%s' failed\n", pEntry->mCDE.mFileName);
+ result = UNKNOWN_ERROR;
+ free(buf);
+ goto bail;
+ }
+ long endPosn = ftell(mZipFp);
+ pEntry->setDataInfo(uncompressedLen, endPosn - startPosn,
+ pSourceEntry->getCRC32(), ZipEntry::kCompressDeflated);
+ free(buf);
+ } else {
+ off_t copyLen;
+ copyLen = pSourceEntry->getCompressedLen();
+ if ((pSourceEntry->mLFH.mGPBitFlag & ZipEntry::kUsesDataDescr) != 0)
+ copyLen += ZipEntry::kDataDescriptorLen;
+
+ if (copyPartialFpToFp(mZipFp, pSourceZip->mZipFp, copyLen, NULL)
+ != NO_ERROR)
+ {
+ ALOGW("copy of '%s' failed\n", pEntry->mCDE.mFileName);
+ result = UNKNOWN_ERROR;
+ goto bail;
+ }
+ }
+
+ /*
+ * Update file offsets.
+ */
+ endPosn = ftell(mZipFp);
+
+ /*
+ * Success! Fill out new values.
+ */
+ pEntry->setLFHOffset(lfhPosn);
+ mEOCD.mNumEntries++;
+ mEOCD.mTotalNumEntries++;
+ mEOCD.mCentralDirSize = 0; // mark invalid; set by flush()
+ mEOCD.mCentralDirOffset = endPosn;
+
+ /*
+ * Go back and write the LFH.
+ */
+ if (fseek(mZipFp, lfhPosn, SEEK_SET) != 0) {
+ result = UNKNOWN_ERROR;
+ goto bail;
+ }
+ pEntry->mLFH.write(mZipFp);
+
+ /*
+ * Add pEntry to the list.
+ */
+ mEntries.add(pEntry);
+ if (ppEntry != NULL)
+ *ppEntry = pEntry;
+ pEntry = NULL;
+
+ result = NO_ERROR;
+
+bail:
+ delete pEntry;
+ return result;
+}
+
+/*
* Copy all of the bytes in "src" to "dst".
*
* On exit, "srcFp" will be seeked to the end of the file, and "dstFp"
@@ -744,73 +881,43 @@
const void* data, size_t size, unsigned long* pCRC32)
{
status_t result = NO_ERROR;
- const size_t kBufSize = 32768;
+ const size_t kBufSize = 1024 * 1024;
unsigned char* inBuf = NULL;
unsigned char* outBuf = NULL;
- z_stream zstream;
+ size_t outSize = 0;
bool atEof = false; // no feof() aviailable yet
unsigned long crc;
- int zerr;
+ ZopfliOptions options;
+ unsigned char bp = 0;
- /*
- * Create an input buffer and an output buffer.
- */
- inBuf = new unsigned char[kBufSize];
- outBuf = new unsigned char[kBufSize];
- if (inBuf == NULL || outBuf == NULL) {
- result = NO_MEMORY;
- goto bail;
- }
-
- /*
- * Initialize the zlib stream.
- */
- memset(&zstream, 0, sizeof(zstream));
- zstream.zalloc = Z_NULL;
- zstream.zfree = Z_NULL;
- zstream.opaque = Z_NULL;
- zstream.next_in = NULL;
- zstream.avail_in = 0;
- zstream.next_out = outBuf;
- zstream.avail_out = kBufSize;
- zstream.data_type = Z_UNKNOWN;
-
- zerr = deflateInit2(&zstream, Z_BEST_COMPRESSION,
- Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
- if (zerr != Z_OK) {
- result = UNKNOWN_ERROR;
- if (zerr == Z_VERSION_ERROR) {
- ALOGE("Installed zlib is not compatible with linked version (%s)\n",
- ZLIB_VERSION);
- } else {
- ALOGD("Call to deflateInit2 failed (zerr=%d)\n", zerr);
- }
- goto bail;
- }
+ ZopfliInitOptions(&options);
crc = crc32(0L, Z_NULL, 0);
- /*
- * Loop while we have data.
- */
- do {
- size_t getSize;
- int flush;
+ if (data) {
+ crc = crc32(crc, (const unsigned char*)data, size);
+ ZopfliDeflate(&options, 2, true, (const unsigned char*)data, size, &bp,
+ &outBuf, &outSize);
+ } else {
+ /*
+ * Create an input buffer and an output buffer.
+ */
+ inBuf = new unsigned char[kBufSize];
+ if (inBuf == NULL) {
+ result = NO_MEMORY;
+ goto bail;
+ }
- /* only read if the input buffer is empty */
- if (zstream.avail_in == 0 && !atEof) {
- ALOGV("+++ reading %d bytes\n", (int)kBufSize);
- if (data) {
- getSize = size > kBufSize ? kBufSize : size;
- memcpy(inBuf, data, getSize);
- data = ((const char*)data) + getSize;
- size -= getSize;
- } else {
- getSize = fread(inBuf, 1, kBufSize, srcFp);
- if (ferror(srcFp)) {
- ALOGD("deflate read failed (errno=%d)\n", errno);
- goto z_bail;
- }
+ /*
+ * Loop while we have data.
+ */
+ do {
+ size_t getSize;
+ getSize = fread(inBuf, 1, kBufSize, srcFp);
+ if (ferror(srcFp)) {
+ ALOGD("deflate read failed (errno=%d)\n", errno);
+ delete[] inBuf;
+ goto bail;
}
if (getSize < kBufSize) {
ALOGV("+++ got %d bytes, EOF reached\n",
@@ -819,51 +926,21 @@
}
crc = crc32(crc, inBuf, getSize);
+ ZopfliDeflate(&options, 2, atEof, inBuf, getSize, &bp, &outBuf, &outSize);
+ } while (!atEof);
+ delete[] inBuf;
+ }
- zstream.next_in = inBuf;
- zstream.avail_in = getSize;
- }
-
- if (atEof)
- flush = Z_FINISH; /* tell zlib that we're done */
- else
- flush = Z_NO_FLUSH; /* more to come! */
-
- zerr = deflate(&zstream, flush);
- if (zerr != Z_OK && zerr != Z_STREAM_END) {
- ALOGD("zlib deflate call failed (zerr=%d)\n", zerr);
- result = UNKNOWN_ERROR;
- goto z_bail;
- }
-
- /* write when we're full or when we're done */
- if (zstream.avail_out == 0 ||
- (zerr == Z_STREAM_END && zstream.avail_out != (uInt) kBufSize))
- {
- ALOGV("+++ writing %d bytes\n", (int) (zstream.next_out - outBuf));
- if (fwrite(outBuf, 1, zstream.next_out - outBuf, dstFp) !=
- (size_t)(zstream.next_out - outBuf))
- {
- ALOGD("write %d failed in deflate\n",
- (int) (zstream.next_out - outBuf));
- goto z_bail;
- }
-
- zstream.next_out = outBuf;
- zstream.avail_out = kBufSize;
- }
- } while (zerr == Z_OK);
-
- assert(zerr == Z_STREAM_END); /* other errors should've been caught */
+ ALOGV("+++ writing %d bytes\n", (int)outSize);
+ if (fwrite(outBuf, 1, outSize, dstFp) != outSize) {
+ ALOGD("write %d failed in deflate\n", (int)outSize);
+ goto bail;
+ }
*pCRC32 = crc;
-z_bail:
- deflateEnd(&zstream); /* free up any allocated structures */
-
bail:
- delete[] inBuf;
- delete[] outBuf;
+ free(outBuf);
return result;
}
@@ -1148,7 +1225,7 @@
#endif
// free the memory when you're done
-void* ZipFile::uncompress(const ZipEntry* entry)
+void* ZipFile::uncompress(const ZipEntry* entry) const
{
size_t unlen = entry->getUncompressedLen();
size_t clen = entry->getCompressedLen();
diff --git a/tools/zipalign/ZipFile.h b/tools/zipalign/ZipFile.h
index 7877550..b99cda5 100644
--- a/tools/zipalign/ZipFile.h
+++ b/tools/zipalign/ZipFile.h
@@ -127,6 +127,15 @@
int padding, ZipEntry** ppEntry);
/*
+ * Add an entry by copying it from another zip file, recompressing with
+ * Zopfli if already compressed.
+ *
+ * If "ppEntry" is non-NULL, a pointer to the new entry will be returned.
+ */
+ status_t addRecompress(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
+ ZipEntry** ppEntry);
+
+ /*
* Mark an entry as having been removed. It is not actually deleted
* from the archive or our internal data structures until flush() is
* called.
@@ -147,7 +156,7 @@
*/
//bool uncompress(const ZipEntry* pEntry, void* buf) const;
//bool uncompress(const ZipEntry* pEntry, FILE* fp) const;
- void* uncompress(const ZipEntry* pEntry);
+ void* uncompress(const ZipEntry* pEntry) const;
/*
* Get an entry, by name. Returns NULL if not found.