Merge "Set the default ring buffer size for stats log, and set it loggable."
diff --git a/core/Makefile b/core/Makefile
index 5bc6322..4ef0d89 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -31,12 +31,13 @@
$(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
$(eval unique_product_copy_files_pairs += $(cf))))
unique_product_copy_files_destinations :=
+product_copy_files_ignored :=
$(foreach cf,$(unique_product_copy_files_pairs), \
$(eval _src := $(call word-colon,1,$(cf))) \
$(eval _dest := $(call word-colon,2,$(cf))) \
$(call check-product-copy-files,$(cf)) \
$(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
- $(info PRODUCT_COPY_FILES $(cf) ignored.), \
+ $(eval product_copy_files_ignored += $(cf)), \
$(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
$(if $(filter %.xml,$(_dest)),\
$(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
@@ -45,6 +46,14 @@
$(eval $(call copy-one-file,$(_src),$(_fulldest))))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
$(eval unique_product_copy_files_destinations += $(_dest))))
+
+# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
+$(file >$(PRODUCT_OUT)/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
+ifdef dist_goal
+$(file >$(DIST_DIR)/logs/product_copy_files_ignored.txt,$(subst $(space),$(newline),$(strip $(product_copy_files_ignored))))
+endif
+
+product_copy_files_ignored :=
unique_product_copy_files_pairs :=
unique_product_copy_files_destinations :=
@@ -1213,15 +1222,15 @@
# $(1): output file
define build-recoveryimage-target
- @echo ----- Making recovery image ------
+ # Making recovery image
$(hide) mkdir -p $(TARGET_RECOVERY_OUT)
$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
- @echo Copying baseline ramdisk...
+ # Copying baseline ramdisk...
# Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
$(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
# Copy adbd from system/bin to recovery/root/sbin
$(hide) cp -f $(TARGET_OUT_EXECUTABLES)/adbd $(TARGET_RECOVERY_ROOT_OUT)/sbin/adbd
- @echo Modifying ramdisk contents...
+ # Modifying ramdisk contents...
$(if $(BOARD_RECOVERY_KERNEL_MODULES), \
$(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery)))
# Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
@@ -1273,7 +1282,6 @@
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
$(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
$(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
- @echo ----- Made recovery image: $(1) --------
endef
ADBD := $(TARGET_OUT_EXECUTABLES)/adbd
diff --git a/core/aapt2.mk b/core/aapt2.mk
index 8bb2d4b..c582e30 100644
--- a/core/aapt2.mk
+++ b/core/aapt2.mk
@@ -108,3 +108,13 @@
cp $@ $(PRIVATE_RESOURCE_EXPORT_PACKAGE)
endif
+
+# Clear inputs only used in this file, so that they're not re-used during the next build
+my_res_resources :=
+my_overlay_resources :=
+my_compiled_res_base_dir :=
+my_asset_dirs :=
+my_full_asset_paths :=
+my_apk_split_configs :=
+my_generated_res_dirs :=
+my_generated_res_dirs_deps :=
diff --git a/core/base_rules.mk b/core/base_rules.mk
index b501fbd..592650d 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -65,6 +65,16 @@
my_host_cross :=
endif
+_path := $(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)
+ifneq ($(filter $(TARGET_OUT_VENDOR)%,$(_path)),)
+LOCAL_VENDOR_MODULE := true
+else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(_path)),)
+LOCAL_OEM_MODULE := true
+else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(_path)),)
+LOCAL_ODM_MODULE := true
+endif
+_path :=
+
ifndef LOCAL_PROPRIETARY_MODULE
LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE)
endif
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 1e64c4f..bd605ec 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -4,6 +4,7 @@
# '',true
LOCAL_32_BIT_ONLY:=
+LOCAL_AAPT2_ONLY:=
LOCAL_AAPT_FLAGS:=
LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
LOCAL_ADDITIONAL_CERTIFICATES:=
diff --git a/core/config.mk b/core/config.mk
index 232f1d0..bebc186 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -536,17 +536,17 @@
ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign
else # TARGET_BUILD_APPS || TARGET_BUILD_PDK
- AIDL := $(prebuilt_sdk_tools_bin)/aidl
+ AIDL := $(prebuilt_build_tools_bin)/aidl
AAPT := $(prebuilt_sdk_tools_bin)/aapt
AAPT2 := $(prebuilt_sdk_tools_bin)/aapt2
DESUGAR := $(prebuilt_build_tools_jars)/desugar.jar
MAINDEXCLASSES := $(prebuilt_sdk_tools)/mainDexClasses
SIGNAPK_JAR := $(prebuilt_sdk_tools)/lib/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
SIGNAPK_JNI_LIBRARY_PATH := $(prebuilt_sdk_tools)/$(HOST_OS)/lib64
- ZIPALIGN := $(prebuilt_sdk_tools_bin)/zipalign
+ ZIPALIGN := $(prebuilt_build_tools_bin)/zipalign
endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
-R8_COMPAT_PROGUARD_JAR := prebuilts/r8/compatproguard-master.jar
+R8_COMPAT_PROGUARD := $(HOST_OUT_EXECUTABLES)/r8-compat-proguard
ifeq (,$(TARGET_BUILD_APPS))
# Use RenderScript prebuilts for unbundled builds but not PDK builds
@@ -665,14 +665,28 @@
COLUMN:= column
-# Path to tools.jar, or empty if EXPERIMENTAL_USE_OPENJDK9 is set
+ifeq ($(EXPERIMENTAL_USE_OPENJDK9),)
+USE_OPENJDK9 :=
+TARGET_OPENJDK9 :=
+else ifeq ($(EXPERIMENTAL_USE_OPENJDK9),false)
+USE_OPENJDK9 :=
+TARGET_OPENJDK9 :=
+else ifeq ($(EXPERIMENTAL_USE_OPENJDK9),1.8)
+USE_OPENJDK9 := true
+TARGET_OPENJDK9 :=
+else ifeq ($(EXPERIMENTAL_USE_OPENJDK9),true)
+USE_OPENJDK9 := true
+TARGET_OPENJDK9 := true
+endif
+
+# Path to tools.jar, or empty if USE_OPENJDK9 is unset
HOST_JDK_TOOLS_JAR :=
# TODO: Remove HOST_JDK_TOOLS_JAR and all references to it once OpenJDK 8
-# toolchains are no longer supported (i.e. when what is now
-# EXPERIMENTAL_USE_OPENJDK9 becomes the standard). http://b/38418220
-ifeq ($(EXPERIMENTAL_USE_OPENJDK9),)
+# toolchains are no longer supported (i.e. when USE_OPENJDK9 is enforced).
+# http://b/38418220
+ifndef USE_OPENJDK9
HOST_JDK_TOOLS_JAR := $(ANDROID_JAVA_TOOLCHAIN)/../lib/tools.jar
-endif # ifeq ($(EXPERIMENTAL_USE_OPENJDK9),)
+endif # ifndef USE_OPENJDK9
# It's called md5 on Mac OS and md5sum on Linux
ifeq ($(HOST_OS),darwin)
@@ -709,13 +723,15 @@
# PRODUCT_FULL_TREBLE
$(foreach req,$(requirements),$(eval \
$(req) := $(if $($(req)_OVERRIDE),$($(req)_OVERRIDE),$(PRODUCT_FULL_TREBLE))))
-# If the requirement is false for any reason, then it's not PRODUCT_FULL_TREBLE
-$(foreach req,$(requirements),$(eval \
- PRODUCT_FULL_TREBLE := $(if $(filter false,$($(req))),false,$(PRODUCT_FULL_TREBLE))))
+
+PRODUCT_FULL_TREBLE_OVERRIDE ?=
+$(foreach req,$(requirements),$(eval $(req)_OVERRIDE ?=))
.KATI_READONLY := \
+ PRODUCT_FULL_TREBLE_OVERRIDE \
+ $(foreach req,$(requirements),$(req)_OVERRIDE) \
$(requirements) \
- PRODUCT_FULL_TREBLE
+ PRODUCT_FULL_TREBLE \
requirements :=
diff --git a/core/definitions.mk b/core/definitions.mk
index c7799b0..13bd47c 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2381,7 +2381,7 @@
@rm -rf $(dir $@)/desugar_dumped_classes
@mkdir $(dir $@)/desugar_dumped_classes
$(hide) $(JAVA) \
- $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-opens java.base/java.lang.invoke=ALL-UNNAMED,) \
+ $(if $(USE_OPENJDK9),--add-opens java.base/java.lang.invoke=ALL-UNNAMED,) \
-Djdk.internal.lambda.dumpProxyClasses=$(abspath $(dir $@))/desugar_dumped_classes \
-jar $(DESUGAR) \
$(addprefix --bootclasspath_entry ,$(PRIVATE_BOOTCLASSPATH)) \
@@ -2774,7 +2774,7 @@
###########################################################
## Commands to call Proguard
###########################################################
-ifeq ($(EXPERIMENTAL_USE_OPENJDK9),true)
+ifdef TARGET_OPENJDK9
define transform-jar-to-proguard
@echo Skipping Proguard: $<$(PRIVATE_PROGUARD_INJAR_FILTERS) $@
$(hide) cp '$<' $@
@@ -2795,7 +2795,7 @@
###########################################################
define transform-jar-to-dex-r8
@echo R8: $@
-$(hide) $(JAVA) -jar $(R8_COMPAT_PROGUARD_JAR) -injars '$<$(PRIVATE_PROGUARD_INJAR_FILTERS)' \
+$(hide) $(R8_COMPAT_PROGUARD) -injars '$<$(PRIVATE_PROGUARD_INJAR_FILTERS)' \
--min-api $(PRIVATE_MIN_SDK_VERSION) \
--force-proguard-compatibility --output $(subst classes.dex,,$@) \
$(PRIVATE_PROGUARD_FLAGS) \
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index 45b8af0..2bac984 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -91,8 +91,11 @@
$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH))
$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files))
$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
+$(full_target): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(full_target): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list
+$(full_target): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/droiddoc-srcjar-list
ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
@@ -173,17 +176,21 @@
$(droiddoc) \
$(html_dir_files) \
$(full_java_libs) \
+ $(EXTRACT_SRCJARS) \
+ $(LOCAL_SRCJARS) \
$(LOCAL_ADDITIONAL_DEPENDENCIES)
@echo Docs droiddoc: $(PRIVATE_OUT_DIR)
$(hide) mkdir -p $(dir $@)
- $(addprefix $(hide) rm -rf ,$(PRIVATE_STUB_OUT_DIR))
+ $(hide) rm -rf $(PRIVATE_STUB_OUT_DIR) $(PRIVATE_SRCJAR_INTERMEDIATES_DIR)
$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
$(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
+ $(EXTRACT_SRCJARS) $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) $(PRIVATE_SRCJAR_LIST_FILE) $(PRIVATE_SRCJARS)
$(hide) ( \
$(JAVADOC) \
-encoding UTF-8 \
-source 1.8 \
\@$(PRIVATE_SRC_LIST_FILE) \
+ \@$(PRIVATE_SRCJAR_LIST_FILE) \
-J-Xmx1600m \
-J-XX:-OmitStackTraceInFastThrow \
-XDignore.symbol.file \
@@ -213,7 +220,7 @@
##
##
-ifneq ($(EXPERIMENTAL_USE_OPENJDK9),)
+ifdef USE_OPENJDK9
# For OpenJDK 9 we use --patch-module to define the core libraries code.
# TODO(tobiast): Reorganize this when adding proper support for OpenJDK 9
# modules. Here we treat all code in core libraries as being in java.base
@@ -223,17 +230,19 @@
# For OpenJDK 8 we can use -bootclasspath to define the core libraries code.
$(full_target): PRIVATE_BOOTCLASSPATH_ARG := $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH))
endif
-
-$(full_target): $(full_src_files) $(full_java_libs)
+$(full_target): $(full_src_files) $(full_java_libs) $(EXTRACT_SRCJARS) $(LOCAL_SRCJARS) $(LOCAL_ADDITIONAL_DEPENDENCIES)
@echo Docs javadoc: $(PRIVATE_OUT_DIR)
@mkdir -p $(dir $@)
+ rm -rf $(PRIVATE_SRCJAR_INTERMEDIATES_DIR)
$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
$(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
+ $(EXTRACT_SRCJARS) $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) $(PRIVATE_SRCJAR_LIST_FILE) $(PRIVATE_SRCJARS)
$(hide) ( \
$(JAVADOC) \
-encoding UTF-8 \
$(PRIVATE_DROIDDOC_OPTIONS) \
\@$(PRIVATE_SRC_LIST_FILE) \
+ \@$(PRIVATE_SRCJAR_LIST_FILE) \
-J-Xmx1024m \
-XDignore.symbol.file \
-Xdoclint:none \
diff --git a/core/java.mk b/core/java.mk
index 71bed38..9143bc1 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -555,7 +555,9 @@
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
-ifeq ($(EXPERIMENTAL_USE_OPENJDK9),true)
+# Temporarily enable --multi-dex until proguard supports v53 class files
+# ( http://b/67673860 ) or we move away from proguard altogether.
+ifdef TARGET_OPENJDK9
LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex
endif
@@ -752,7 +754,7 @@
$(built_dex_intermediate): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
$(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
$(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
-$(built_dex_intermediate) : $(full_classes_proguard_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) $(R8_COMPAT_PROGUARD_JAR)
+$(built_dex_intermediate) : $(full_classes_proguard_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) $(R8_COMPAT_PROGUARD)
$(transform-jar-to-dex-r8)
endif # USE_R8
endif # LOCAL_PROGUARD_ENABLED
diff --git a/core/java_common.mk b/core/java_common.mk
index 37de700..4dd0de6 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -23,8 +23,7 @@
# TODO(ccross): allow 1.9 for current and unbundled once we have SDK system modules
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
else
- # DEFAULT_JAVA_LANGUAGE_VERSION is 1.8 unless EXPERIMENTAL_USE_OPENJDK9=true
- # in which case it is 1.9
+ # DEFAULT_JAVA_LANGUAGE_VERSION is 1.8, unless TARGET_OPENJDK9 in which case it is 1.9
LOCAL_JAVA_LANGUAGE_VERSION := $(DEFAULT_JAVA_LANGUAGE_VERSION)
endif
endif
@@ -415,7 +414,14 @@
my_allowed_types := java:sdk java:system java:platform
endif
-my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES))
+ifdef LOCAL_AAPT2_ONLY
+my_link_type += aapt2_only
+endif
+ifdef LOCAL_USE_AAPT2
+my_allowed_types += aapt2_only
+endif
+
+my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES))
my_link_deps += $(addprefix APPS:,$(apk_libraries))
my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
diff --git a/core/local_vndk.mk b/core/local_vndk.mk
index 640aac7..3677d40 100644
--- a/core/local_vndk.mk
+++ b/core/local_vndk.mk
@@ -5,10 +5,8 @@
ifndef LOCAL_SDK_VERSION
ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
LOCAL_USE_VNDK:=true
- else
- ifneq (,$(filter $(TARGET_OUT_VENDOR)%,$(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)))
- LOCAL_USE_VNDK:=true
- endif
+ # Note: no need to check LOCAL_MODULE_PATH* since LOCAL_[VENDOR|ODM|OEM]_MODULE is already
+ # set correctly before this is included.
endif
endif
endif
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 9bf173f..9f99c7a 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -146,6 +146,10 @@
need_compile_asset := true
endif
+ifdef LOCAL_AAPT2_ONLY
+LOCAL_USE_AAPT2 := true
+endif
+
my_res_package :=
ifdef LOCAL_USE_AAPT2
# In aapt2 the last takes precedence.
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 48e410b..47bd1b2 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -216,7 +216,7 @@
else
my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
endif
- my_coverage_path := $(my_coverage_path)/$(basename $(my_installed_module_stem)).gcnodir
+ my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).gcnodir
$(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
$(LOCAL_BUILT_MODULE): $(my_coverage_path)
endif
@@ -547,6 +547,10 @@
$(common_javalib_jar) : $(common_classes_jar)
$(transform-prebuilt-to-target)
+ifdef LOCAL_AAPT2_ONLY
+LOCAL_USE_AAPT2 := true
+endif
+
ifdef LOCAL_USE_AAPT2
ifneq ($(my_src_aar),)
LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 69cf955..5ffb88d 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -28,6 +28,10 @@
my_res_package :=
+ifdef LOCAL_AAPT2_ONLY
+LOCAL_USE_AAPT2 := true
+endif
+
# Hack to build static Java library with Android resource
# See bug 5714516
all_resources :=
diff --git a/core/tasks/collect_gpl_sources.mk b/core/tasks/collect_gpl_sources.mk
index 30ba62b..70f0afe 100644
--- a/core/tasks/collect_gpl_sources.mk
+++ b/core/tasks/collect_gpl_sources.mk
@@ -12,20 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-gpl_source_tgz := $(call intermediates-dir-for,PACKAGING,gpl_source,HOST,COMMON)/gpl_source.tgz
+ifdef dist_goal
+
+# The rule below doesn't have dependenices on the files that it copies,
+# so manually generate directly into the DIST_DIR directory that is always
+# wiped between dist builds.
+gpl_source_tgz := $(DIST_DIR)/gpl_source.tgz
# FORCE since we can't know whether any of the sources changed
$(gpl_source_tgz): PRIVATE_PATHS := $(sort $(patsubst %/, %, $(dir $(ALL_GPL_MODULE_LICENSE_FILES))))
-$(gpl_source_tgz) : $(ALL_GPL_MODULE_LICENSE_FILES) FORCE
+$(gpl_source_tgz) : $(ALL_GPL_MODULE_LICENSE_FILES)
@echo Package gpl sources: $@
- @rm -rf $(dir $@) && mkdir -p $(dir $@)
$(hide) tar cfz $@ --exclude ".git*" $(PRIVATE_PATHS)
-
-.PHONY: gpl_source_tgz
-gpl_source_tgz : $(gpl_source_tgz)
-
# Dist the tgz only if we are doing a full build
ifeq (,$(TARGET_BUILD_APPS))
-$(call dist-for-goals, droidcore, $(gpl_source_tgz))
+droidcore: $(gpl_source_tgz)
endif
+
+endif # dist_goal
diff --git a/core/tasks/vndk.mk b/core/tasks/vndk.mk
new file mode 100644
index 0000000..d824a41
--- /dev/null
+++ b/core/tasks/vndk.mk
@@ -0,0 +1,124 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+current_makefile := $(lastword $(MAKEFILE_LIST))
+
+# BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
+ifeq ($(BOARD_VNDK_VERSION),current)
+
+# Returns arch-specific libclang_rt.ubsan* library name.
+# Because VNDK_CORE_LIBRARIES includes all arch variants for libclang_rt.ubsan*
+# libs, the arch-specific libs are selected separately.
+#
+# Args:
+# $(1): if not empty, evaluates for TARGET_2ND_ARCH
+define clang-ubsan-vndk-core
+ $(eval prefix := $(if $(1),2ND_,))
+ $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY)))
+endef
+
+# Args:
+# $(1): list of lib names without '.so' suffix (e.g., libX.vendor)
+# $(2): if not empty, evaluates for TARGET_2ND_ARCH
+define paths-of-intermediates
+ $(strip \
+ $(foreach lib,$(1), \
+ $(call append-path,$(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),,,$(2)),$(lib).so)))
+endef
+
+vndk_core_libs := $(addsuffix .vendor,$(filter-out libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
+vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
+vndk_snapshot_dependencies := \
+ $(vndk_core_libs) \
+ $(vndk_sp_libs)
+
+# If in the future libclang_rt.ubsan* is removed from the VNDK-core list,
+# need to update the related logic in this file.
+ifeq (,$(filter libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
+ $(error libclang_rt.ubsan* is no longer a VNDK-core library.)
+endif
+
+# for TARGET_ARCH
+clang_ubsan_vndk_core_$(TARGET_ARCH) := $(call clang-ubsan-vndk-core)
+vndk_snapshot_dependencies += \
+ $(clang_ubsan_vndk_core_$(TARGET_ARCH))
+
+ifdef TARGET_2ND_ARCH
+clang_ubsan_vndk_core_$(TARGET_2ND_ARCH) := $(call clang-ubsan-vndk-core,true)
+vndk_snapshot_dependencies += \
+ $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH))
+endif
+
+vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_ARCH).zip
+vndk_snapshot_out := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
+$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
+
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH) := \
+ $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-core
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH) := \
+ $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_ARCH)))
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH) := \
+ $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-sp
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH) := \
+ $(call paths-of-intermediates,$(vndk_sp_libs))
+
+ifdef TARGET_2ND_ARCH
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH) := \
+ $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-core
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH) := \
+ $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH)),true)
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH) := \
+ $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-sp
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH) := \
+ $(call paths-of-intermediates,$(vndk_sp_libs),true)
+endif
+
+# Args
+# $(1): destination directory
+# $(2): list of libs to copy
+$(vndk_snapshot_zip): private-copy-vndk-intermediates = \
+ @mkdir -p $(1); \
+ $(foreach lib,$(2),cp -p $(lib) $(call append-path,$(1),$(subst .vendor,,$(notdir $(lib))));)
+
+$(vndk_snapshot_zip): $(vndk_snapshot_dependencies) $(SOONG_ZIP)
+ @echo 'Generating VNDK snapshot: $@'
+ @rm -f $@
+ @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
+ @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
+ $(call private-copy-vndk-intermediates, \
+ $(PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH)))
+ $(call private-copy-vndk-intermediates, \
+ $(PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH)))
+ifdef TARGET_2ND_ARCH
+ $(call private-copy-vndk-intermediates, \
+ $(PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH)))
+ $(call private-copy-vndk-intermediates, \
+ $(PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH)))
+endif
+ $(hide) $(SOONG_ZIP) -o $@ -P vndk-snapshot -C $(PRIVATE_VNDK_SNAPSHOT_OUT) \
+ -D $(PRIVATE_VNDK_SNAPSHOT_OUT)
+
+.PHONY: vndk
+vndk: $(vndk_snapshot_zip)
+
+$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
+
+else # BOARD_VNDK_VERSION is NOT set to 'current'
+
+.PHONY: vndk
+vndk:
+ $(call echo-error,$(current_makefile),CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'.)
+ exit 1
+
+endif # BOARD_VNDK_VERSION
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index e14de96..05e3b45 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -155,7 +155,7 @@
# On userdebug builds, collect more tombstones by default.
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
tombstoned.max_tombstone_count=50
endif
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 4e1adc8..9e684f7 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -105,7 +105,7 @@
# Ensure that this property is always defined so that bionic_systrace.cpp
# can rely on it being initially set by init.
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
debug.atrace.tags.enableflags=0
PRODUCT_COPY_FILES += \
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index 42c8ea8..6e7038e 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -89,5 +89,5 @@
pm.dexopt.shared=speed
# Enable minidebuginfo generation unless overridden.
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
dalvik.vm.dex2oat-minidebuginfo=true
diff --git a/tools/generate-notice-files.py b/tools/generate-notice-files.py
index adbf7c2..b754174 100755
--- a/tools/generate-notice-files.py
+++ b/tools/generate-notice-files.py
@@ -253,15 +253,12 @@
filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())]
- print "Combining NOTICE files into text"
combine_notice_files_text(filesets, input_dir, txt_output_file, file_title)
if html_output_file is not None:
- print "Combining NOTICE files into HTML"
combine_notice_files_html(filesets, input_dir, html_output_file)
if xml_output_file is not None:
- print "Combining NOTICE files into XML"
combine_notice_files_xml(files_with_same_hash, input_dir, xml_output_file)
if __name__ == "__main__":
diff --git a/tools/java-event-log-tags.py b/tools/java-event-log-tags.py
index f364751..37cd712 100755
--- a/tools/java-event-log-tags.py
+++ b/tools/java-event-log-tags.py
@@ -51,30 +51,37 @@
print >> sys.stderr, "unhandled option %s" % (o,)
sys.exit(1)
-if len(args) != 2:
- print "need exactly two input files, not %d" % (len(args),)
+if len(args) != 1 and len(args) != 2:
+ print "need one or two input files, not %d" % (len(args),)
print __doc__
sys.exit(1)
fn = args[0]
tagfile = event_log_tags.TagFile(fn)
-# Load the merged tag file (which should have numbers assigned for all
-# tags. Use the numbers from the merged file to fill in any missing
-# numbers from the input file.
-merged_fn = args[1]
-merged_tagfile = event_log_tags.TagFile(merged_fn)
-merged_by_name = dict([(t.tagname, t) for t in merged_tagfile.tags])
-for t in tagfile.tags:
- if t.tagnum is None:
- if t.tagname in merged_by_name:
- t.tagnum = merged_by_name[t.tagname].tagnum
- else:
- # We're building something that's not being included in the
- # product, so its tags don't appear in the merged file. Assign
- # them all an arbitrary number so we can emit the java and
- # compile the (unused) package.
- t.tagnum = 999999
+if len(args) > 1:
+ # Load the merged tag file (which should have numbers assigned for all
+ # tags. Use the numbers from the merged file to fill in any missing
+ # numbers from the input file.
+ merged_fn = args[1]
+ merged_tagfile = event_log_tags.TagFile(merged_fn)
+ merged_by_name = dict([(t.tagname, t) for t in merged_tagfile.tags])
+ for t in tagfile.tags:
+ if t.tagnum is None:
+ if t.tagname in merged_by_name:
+ t.tagnum = merged_by_name[t.tagname].tagnum
+ else:
+ # We're building something that's not being included in the
+ # product, so its tags don't appear in the merged file. Assign
+ # them all an arbitrary number so we can emit the java and
+ # compile the (unused) package.
+ t.tagnum = 999999
+else:
+ # Not using the merged tag file, so all tags must have manually assigned
+ # numbers
+ for t in tagfile.tags:
+ if t.tagnum is None:
+ tagfilef.AddError("tag \"%s\" has no number" % (tagname,), tag.linenum)
if "java_package" not in tagfile.options:
tagfile.AddError("java_package option not specified", linenum=0)
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index d31a297..a882685 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -346,10 +346,20 @@
cmd.extend(["--include_descriptors_from_image", img_path])
-def AddVBMeta(output_zip, boot_img_path, system_img_path, vendor_img_path,
- dtbo_img_path, prefix="IMAGES/"):
- """Create a VBMeta image and store it in output_zip."""
+def AddVBMeta(output_zip, partitions, prefix="IMAGES/"):
+ """Creates a VBMeta image and store it in output_zip.
+
+ Args:
+ output_zip: The output zip file, which needs to be already open.
+ partitions: A dict that's keyed by partition names with image paths as
+ values. Only valid partition names are accepted, which include 'boot',
+ 'recovery', 'system', 'vendor', 'dtbo'.
+ """
img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "vbmeta.img")
+ if os.path.exists(img.input_name):
+ print("vbmeta.img already exists in %s; not rebuilding..." % (prefix,))
+ return img.input_name
+
avbtool = os.getenv('AVBTOOL') or OPTIONS.info_dict["avb_avbtool"]
cmd = [avbtool, "make_vbmeta_image", "--output", img.name]
common.AppendAVBSigningArgs(cmd, "vbmeta")
@@ -357,10 +367,12 @@
public_key_dir = tempfile.mkdtemp(prefix="avbpubkey-")
OPTIONS.tempfiles.append(public_key_dir)
- AppendVBMetaArgsForPartition(cmd, "boot", boot_img_path, public_key_dir)
- AppendVBMetaArgsForPartition(cmd, "system", system_img_path, public_key_dir)
- AppendVBMetaArgsForPartition(cmd, "vendor", vendor_img_path, public_key_dir)
- AppendVBMetaArgsForPartition(cmd, "dtbo", dtbo_img_path, public_key_dir)
+ for partition, path in partitions.items():
+ assert partition in common.AVB_PARTITIONS, 'Unknown partition: %s' % (
+ partition,)
+ assert os.path.exists(path), 'Failed to find %s for partition %s' % (
+ path, partition)
+ AppendVBMetaArgsForPartition(cmd, partition, path, public_key_dir)
args = OPTIONS.info_dict.get("avb_vbmeta_args")
if args and args.strip():
@@ -477,6 +489,17 @@
def AddImagesToTargetFiles(filename):
+ """Creates and adds images (boot/recovery/system/...) to a target_files.zip.
+
+ It works with either a zip file (zip mode), or a directory that contains the
+ files to be packed into a target_files.zip (dir mode). The latter is used when
+ being called from build/make/core/Makefile.
+
+ The images will be created under IMAGES/ in the input target_files.zip.
+
+ Args:
+ filename: the target_files.zip, or the zip root directory.
+ """
if os.path.isdir(filename):
OPTIONS.input_tmp = os.path.abspath(filename)
input_zip = None
@@ -508,10 +531,13 @@
else:
OPTIONS.info_dict = common.LoadInfoDict(filename, filename)
output_zip = None
- images_dir = os.path.join(OPTIONS.input_tmp, "IMAGES")
- if not os.path.isdir(images_dir):
- os.makedirs(images_dir)
- images_dir = None
+
+ # Always make input_tmp/IMAGES available, since we may stage boot / recovery
+ # images there even under zip mode. The directory will be cleaned up as part
+ # of OPTIONS.input_tmp.
+ images_dir = os.path.join(OPTIONS.input_tmp, "IMAGES")
+ if not os.path.isdir(images_dir):
+ os.makedirs(images_dir)
has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
@@ -526,67 +552,63 @@
if fp:
OPTIONS.info_dict["avb_salt"] = hashlib.sha256(fp).hexdigest()
+ # A map between partition names and their paths, which could be used when
+ # generating AVB vbmeta image.
+ partitions = dict()
+
def banner(s):
print("\n\n++++ " + s + " ++++\n\n")
- prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img")
- boot_image = None
- if os.path.exists(prebuilt_path):
- banner("boot")
- print("boot.img already exists in IMAGES/, no need to rebuild...")
- if OPTIONS.rebuild_recovery:
- boot_image = common.GetBootableImage(
- "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
- else:
- banner("boot")
- boot_image = common.GetBootableImage(
- "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
- if boot_image:
+ banner("boot")
+ # common.GetBootableImage() returns the image directly if present.
+ boot_image = common.GetBootableImage(
+ "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
+ # boot.img may be unavailable in some targets (e.g. aosp_arm64).
+ if boot_image:
+ partitions['boot'] = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img")
+ if not os.path.exists(partitions['boot']):
+ boot_image.WriteToDir(OPTIONS.input_tmp)
if output_zip:
boot_image.AddToZip(output_zip)
- else:
- boot_image.WriteToDir(OPTIONS.input_tmp)
recovery_image = None
if has_recovery:
banner("recovery")
- prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
- if os.path.exists(prebuilt_path):
- print("recovery.img already exists in IMAGES/, no need to rebuild...")
- if OPTIONS.rebuild_recovery:
- recovery_image = common.GetBootableImage(
- "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp,
- "RECOVERY")
- else:
- recovery_image = common.GetBootableImage(
- "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
- if recovery_image:
- if output_zip:
- recovery_image.AddToZip(output_zip)
- else:
- recovery_image.WriteToDir(OPTIONS.input_tmp)
+ recovery_image = common.GetBootableImage(
+ "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
+ assert recovery_image, "Failed to create recovery.img."
+ partitions['recovery'] = os.path.join(
+ OPTIONS.input_tmp, "IMAGES", "recovery.img")
+ if not os.path.exists(partitions['recovery']):
+ recovery_image.WriteToDir(OPTIONS.input_tmp)
+ if output_zip:
+ recovery_image.AddToZip(output_zip)
banner("recovery (two-step image)")
# The special recovery.img for two-step package use.
recovery_two_step_image = common.GetBootableImage(
"IMAGES/recovery-two-step.img", "recovery-two-step.img",
OPTIONS.input_tmp, "RECOVERY", two_step_image=True)
- if recovery_two_step_image:
+ assert recovery_two_step_image, "Failed to create recovery-two-step.img."
+ recovery_two_step_image_path = os.path.join(
+ OPTIONS.input_tmp, "IMAGES", "recovery-two-step.img")
+ if not os.path.exists(recovery_two_step_image_path):
+ recovery_two_step_image.WriteToDir(OPTIONS.input_tmp)
if output_zip:
recovery_two_step_image.AddToZip(output_zip)
- else:
- recovery_two_step_image.WriteToDir(OPTIONS.input_tmp)
banner("system")
- system_img_path = AddSystem(
+ partitions['system'] = system_img_path = AddSystem(
output_zip, recovery_img=recovery_image, boot_img=boot_image)
- vendor_img_path = None
+
if has_vendor:
banner("vendor")
- vendor_img_path = AddVendor(output_zip)
+ partitions['vendor'] = vendor_img_path = AddVendor(output_zip)
+
if has_system_other:
banner("system_other")
AddSystemOther(output_zip)
+
if not OPTIONS.is_signing:
banner("userdata")
AddUserdata(output_zip)
@@ -597,16 +619,13 @@
banner("partition-table")
AddPartitionTable(output_zip)
- dtbo_img_path = None
if OPTIONS.info_dict.get("has_dtbo") == "true":
banner("dtbo")
- dtbo_img_path = AddDtbo(output_zip)
+ partitions['dtbo'] = AddDtbo(output_zip)
if OPTIONS.info_dict.get("avb_enable") == "true":
banner("vbmeta")
- boot_contents = boot_image.WriteToTemp()
- AddVBMeta(output_zip, boot_contents.name, system_img_path,
- vendor_img_path, dtbo_img_path)
+ AddVBMeta(output_zip, partitions)
# For devices using A/B update, copy over images from RADIO/ and/or
# VENDOR_IMAGES/ to IMAGES/ and make sure we have all the needed
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index c184c42..6bca99e 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -16,6 +16,7 @@
import array
import common
+import copy
import functools
import heapq
import itertools
@@ -204,6 +205,18 @@
self.id = len(by_id)
by_id.append(self)
+ self._patch = None
+
+ @property
+ def patch(self):
+ return self._patch
+
+ @patch.setter
+ def patch(self, patch):
+ if patch:
+ assert self.style == "diff"
+ self._patch = patch
+
def NetStashChange(self):
return (sum(sr.size() for (_, sr) in self.stash_before) -
sum(sr.size() for (_, sr) in self.use_stash))
@@ -213,6 +226,7 @@
self.use_stash = []
self.style = "new"
self.src_ranges = RangeSet()
+ self.patch = None
def __str__(self):
return (str(self.id) + ": <" + str(self.src_ranges) + " " + self.style +
@@ -675,6 +689,7 @@
# These are identical; we don't need to generate a patch,
# just issue copy commands on the device.
xf.style = "move"
+ xf.patch = None
tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
if xf.src_ranges != xf.tgt_ranges:
print("%10d %10d (%6.2f%%) %7s %s %s (from %s)" % (
@@ -683,24 +698,33 @@
xf.tgt_name + " (from " + xf.src_name + ")"),
str(xf.tgt_ranges), str(xf.src_ranges)))
else:
- # For files in zip format (eg, APKs, JARs, etc.) we would
- # like to use imgdiff -z if possible (because it usually
- # produces significantly smaller patches than bsdiff).
- # This is permissible if:
- #
- # - imgdiff is not disabled, and
- # - the source and target files are monotonic (ie, the
- # data is stored with blocks in increasing order), and
- # - we haven't removed any blocks from the source set.
- #
- # If these conditions are satisfied then appending all the
- # blocks in the set together in order will produce a valid
- # zip file (plus possibly extra zeros in the last block),
- # which is what imgdiff needs to operate. (imgdiff is
- # fine with extra zeros at the end of the file.)
- imgdiff = (not self.disable_imgdiff and xf.intact and
- xf.tgt_name.split(".")[-1].lower()
- in ("apk", "jar", "zip"))
+ if xf.patch:
+ # We have already generated the patch with imgdiff. Check if the
+ # transfer is intact.
+ assert not self.disable_imgdiff
+ imgdiff = True
+ if not xf.intact:
+ imgdiff = False
+ xf.patch = None
+ else:
+ # For files in zip format (eg, APKs, JARs, etc.) we would
+ # like to use imgdiff -z if possible (because it usually
+ # produces significantly smaller patches than bsdiff).
+ # This is permissible if:
+ #
+ # - imgdiff is not disabled, and
+ # - the source and target files are monotonic (ie, the
+ # data is stored with blocks in increasing order), and
+ # - we haven't removed any blocks from the source set.
+ #
+ # If these conditions are satisfied then appending all the
+ # blocks in the set together in order will produce a valid
+ # zip file (plus possibly extra zeros in the last block),
+ # which is what imgdiff needs to operate. (imgdiff is
+ # fine with extra zeros at the end of the file.)
+ imgdiff = (not self.disable_imgdiff and xf.intact and
+ xf.tgt_name.split(".")[-1].lower()
+ in ("apk", "jar", "zip"))
xf.style = "imgdiff" if imgdiff else "bsdiff"
diff_queue.append((index, imgdiff, patch_num))
patch_num += 1
@@ -738,48 +762,51 @@
xf_index, imgdiff, patch_index = diff_queue.pop()
xf = self.transfers[xf_index]
- src_ranges = xf.src_ranges
- tgt_ranges = xf.tgt_ranges
+ patch = xf.patch
+ if not patch:
+ src_ranges = xf.src_ranges
+ tgt_ranges = xf.tgt_ranges
- # Needs lock since WriteRangeDataToFd() is stateful (calling seek).
- with lock:
- src_file = common.MakeTempFile(prefix="src-")
- with open(src_file, "wb") as fd:
- self.src.WriteRangeDataToFd(src_ranges, fd)
-
- tgt_file = common.MakeTempFile(prefix="tgt-")
- with open(tgt_file, "wb") as fd:
- self.tgt.WriteRangeDataToFd(tgt_ranges, fd)
-
- message = []
- try:
- patch = compute_patch(src_file, tgt_file, imgdiff)
- except ValueError as e:
- message.append(
- "Failed to generate %s for %s: tgt=%s, src=%s:\n%s" % (
- "imgdiff" if imgdiff else "bsdiff",
- xf.tgt_name if xf.tgt_name == xf.src_name else
- xf.tgt_name + " (from " + xf.src_name + ")",
- xf.tgt_ranges, xf.src_ranges, e.message))
- # TODO(b/68016761): Better handle the holes in mke2fs created images.
- if imgdiff:
- try:
- patch = compute_patch(src_file, tgt_file, imgdiff=False)
- message.append(
- "Fell back and generated with bsdiff instead for %s" % (
- xf.tgt_name,))
- xf.style = "bsdiff"
- with lock:
- warning_messages.extend(message)
- del message[:]
- except ValueError as e:
- message.append(
- "Also failed to generate with bsdiff for %s:\n%s" % (
- xf.tgt_name, e.message))
-
- if message:
+ # Needs lock since WriteRangeDataToFd() is stateful (calling seek).
with lock:
- error_messages.extend(message)
+ src_file = common.MakeTempFile(prefix="src-")
+ with open(src_file, "wb") as fd:
+ self.src.WriteRangeDataToFd(src_ranges, fd)
+
+ tgt_file = common.MakeTempFile(prefix="tgt-")
+ with open(tgt_file, "wb") as fd:
+ self.tgt.WriteRangeDataToFd(tgt_ranges, fd)
+
+ message = []
+ try:
+ patch = compute_patch(src_file, tgt_file, imgdiff)
+ except ValueError as e:
+ message.append(
+ "Failed to generate %s for %s: tgt=%s, src=%s:\n%s" % (
+ "imgdiff" if imgdiff else "bsdiff",
+ xf.tgt_name if xf.tgt_name == xf.src_name else
+ xf.tgt_name + " (from " + xf.src_name + ")",
+ xf.tgt_ranges, xf.src_ranges, e.message))
+ # TODO(b/68016761): Better handle the holes in mke2fs created
+ # images.
+ if imgdiff:
+ try:
+ patch = compute_patch(src_file, tgt_file, imgdiff=False)
+ message.append(
+ "Fell back and generated with bsdiff instead for %s" % (
+ xf.tgt_name,))
+ xf.style = "bsdiff"
+ with lock:
+ warning_messages.extend(message)
+ del message[:]
+ except ValueError as e:
+ message.append(
+ "Also failed to generate with bsdiff for %s:\n%s" % (
+ xf.tgt_name, e.message))
+
+ if message:
+ with lock:
+ error_messages.extend(message)
with lock:
patches[patch_index] = (xf_index, patch)
@@ -1167,12 +1194,9 @@
Compared to the fixed 1024-block limit, it reduces the overall package
size by 30% for volantis, and 20% for angler and bullhead."""
+ assert style == "diff"
# Possibly split large files into smaller chunks.
pieces = 0
- cache_size = common.OPTIONS.cache_size
- split_threshold = 0.125
- max_blocks_per_transfer = int(cache_size * split_threshold /
- self.tgt.blocksize)
# Change nothing for small files.
if (tgt_ranges.size() <= max_blocks_per_transfer and
@@ -1182,6 +1206,14 @@
style, by_id)
return
+ if tgt_name.split(".")[-1].lower() in ("apk", "jar", "zip"):
+ split_enable = (not self.disable_imgdiff and src_ranges.monotonic and
+ tgt_ranges.monotonic)
+ if split_enable and (self.tgt.RangeSha1(tgt_ranges) !=
+ self.src.RangeSha1(src_ranges)):
+ large_apks.append((tgt_name, src_name, tgt_ranges, src_ranges))
+ return
+
while (tgt_ranges.size() > max_blocks_per_transfer and
src_ranges.size() > max_blocks_per_transfer):
tgt_split_name = "%s-%d" % (tgt_name, pieces)
@@ -1275,8 +1307,136 @@
AddSplitTransfers(
tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
+ def ParseAndValidateSplitInfo(patch_size, tgt_ranges, src_ranges,
+ split_info):
+ """Parse the split_info and return a list of info tuples.
+
+ Args:
+ patch_size: total size of the patch file.
+ tgt_ranges: Ranges of the target file within the original image.
+ src_ranges: Ranges of the source file within the original image.
+ split_info format:
+ imgdiff version#
+ count of pieces
+ <patch_size_1> <tgt_size_1> <src_ranges_1>
+ ...
+ <patch_size_n> <tgt_size_n> <src_ranges_n>
+
+ Returns:
+ [patch_start, patch_len, split_tgt_ranges, split_src_ranges]
+ """
+
+ version = int(split_info[0])
+ assert version == 2
+ count = int(split_info[1])
+ assert len(split_info) - 2 == count
+
+ split_info_list = []
+ patch_start = 0
+ tgt_remain = copy.deepcopy(tgt_ranges)
+ # each line has the format <patch_size>, <tgt_size>, <src_ranges>
+ for line in split_info[2:]:
+ info = line.split()
+ assert len(info) == 3
+ patch_length = int(info[0])
+
+ split_tgt_size = int(info[1])
+ assert split_tgt_size % 4096 == 0
+ assert split_tgt_size / 4096 <= tgt_remain.size()
+ split_tgt_ranges = tgt_remain.first(split_tgt_size / 4096)
+ tgt_remain = tgt_remain.subtract(split_tgt_ranges)
+
+ # Find the split_src_ranges within the image file from its relative
+ # position in file.
+ split_src_indices = RangeSet.parse_raw(info[2])
+ split_src_ranges = RangeSet()
+ for r in split_src_indices:
+ curr_range = src_ranges.first(r[1]).subtract(src_ranges.first(r[0]))
+ assert not split_src_ranges.overlaps(curr_range)
+ split_src_ranges = split_src_ranges.union(curr_range)
+
+ split_info_list.append((patch_start, patch_length,
+ split_tgt_ranges, split_src_ranges))
+ patch_start += patch_length
+
+ # Check that the sizes of all the split pieces add up to the final file
+ # size for patch and target.
+ assert tgt_remain.size() == 0
+ assert patch_start == patch_size
+ return split_info_list
+
+ def AddSplitTransferForLargeApks():
+ """Create split transfers for large apk files.
+
+ Example: Chrome.apk will be split into
+ src-0: Chrome.apk-0, tgt-0: Chrome.apk-0
+ src-1: Chrome.apk-1, tgt-1: Chrome.apk-1
+ ...
+
+ After the split, the target pieces are continuous and block aligned; and
+ the source pieces are mutually exclusive. During the split, we also
+ generate and save the image patch between src-X & tgt-X. This patch will
+ be valid because the block ranges of src-X & tgt-X will always stay the
+ same afterwards; but there's a chance we don't use the patch if we
+ convert the "diff" command into "new" or "move" later.
+ """
+
+ while True:
+ with transfer_lock:
+ if not large_apks:
+ return
+ tgt_name, src_name, tgt_ranges, src_ranges = large_apks.pop(0)
+
+ src_file = common.MakeTempFile(prefix="src-")
+ tgt_file = common.MakeTempFile(prefix="tgt-")
+ with transfer_lock:
+ with open(src_file, "wb") as src_fd:
+ self.src.WriteRangeDataToFd(src_ranges, src_fd)
+ with open(tgt_file, "wb") as tgt_fd:
+ self.tgt.WriteRangeDataToFd(tgt_ranges, tgt_fd)
+
+ patch_file = common.MakeTempFile(prefix="patch-")
+ patch_info_file = common.MakeTempFile(prefix="split_info-")
+ cmd = ["imgdiff", "-z",
+ "--block-limit={}".format(max_blocks_per_transfer),
+ "--split-info=" + patch_info_file,
+ src_file, tgt_file, patch_file]
+ p = common.Run(cmd, stdout=subprocess.PIPE)
+ p.communicate()
+ # TODO(xunchang) fall back to the normal split if imgdiff fails.
+ if p.returncode != 0:
+ raise ValueError("Failed to create patch between {} and {}".format(
+ src_name, tgt_name))
+
+ with open(patch_info_file) as patch_info:
+ lines = patch_info.readlines()
+
+ patch_size_total = os.path.getsize(patch_file)
+ split_info_list = ParseAndValidateSplitInfo(patch_size_total,
+ tgt_ranges, src_ranges,
+ lines)
+ for index, (patch_start, patch_length, split_tgt_ranges,
+ split_src_ranges) in enumerate(split_info_list):
+ with open(patch_file) as f:
+ f.seek(patch_start)
+ patch_content = f.read(patch_length)
+
+ split_src_name = "{}-{}".format(src_name, index)
+ split_tgt_name = "{}-{}".format(tgt_name, index)
+ transfer_split = Transfer(split_tgt_name, split_src_name,
+ split_tgt_ranges, split_src_ranges,
+ self.tgt.RangeSha1(split_tgt_ranges),
+ self.src.RangeSha1(split_src_ranges),
+ "diff", self.transfers)
+ transfer_split.patch = patch_content
+
print("Finding transfers...")
+ large_apks = []
+ cache_size = common.OPTIONS.cache_size
+ split_threshold = 0.125
+ max_blocks_per_transfer = int(cache_size * split_threshold /
+ self.tgt.blocksize)
empty = RangeSet()
for tgt_fn, tgt_ranges in self.tgt.file_map.items():
if tgt_fn == "__ZERO":
@@ -1321,6 +1481,14 @@
AddTransfer(tgt_fn, None, tgt_ranges, empty, "new", self.transfers)
+ transfer_lock = threading.Lock()
+ threads = [threading.Thread(target=AddSplitTransferForLargeApks)
+ for _ in range(self.threads)]
+ for th in threads:
+ th.start()
+ while threads:
+ threads.pop().join()
+
def AbbreviateSourceNames(self):
for k in self.src.file_map.keys():
b = os.path.basename(k)
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index a388f8a..e11f5a6 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -195,8 +195,9 @@
else:
hi = i
- print("Adjusted partition size for verity, partition_size: {},"
- " verity_size: {}".format(result, verity_size))
+ if OPTIONS.verbose:
+ print("Adjusted partition size for verity, partition_size: {},"
+ " verity_size: {}".format(result, verity_size))
AdjustPartitionSizeForVerity.results[key] = (result, verity_size)
return (result, verity_size)
@@ -257,7 +258,7 @@
return True
def Append(target, file_to_append, error_message):
- print "appending %s to %s" % (file_to_append, target)
+ # appending file_to_append to target
with open(target, "a") as out_file:
with open(file_to_append, "r") as input_file:
for line in input_file:
@@ -535,9 +536,9 @@
try:
if fs_type.startswith("ext4"):
- (ext4fs_output, exit_code) = RunCommand(build_command, True)
+ (ext4fs_output, exit_code) = RunCommand(build_command)
else:
- (_, exit_code) = RunCommand(build_command, True)
+ (_, exit_code) = RunCommand(build_command)
finally:
if in_dir != origin_in:
# Clean up temporary directories and files.
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index d16f5eb..75c86cc 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -75,6 +75,11 @@
# Values for "certificate" in apkcerts that mean special things.
SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL")
+
+# The partitions allowed to be signed by AVB (Android verified boot 2.0).
+AVB_PARTITIONS = ('boot', 'recovery', 'system', 'vendor', 'dtbo')
+
+
class ErrorCode(object):
"""Define error_codes for failures that happen during the actual
update package installation.
@@ -447,10 +452,12 @@
else:
cmd.extend(["--output", img.name])
+ # "boot" or "recovery", without extension.
+ partition_name = os.path.basename(sourcedir).lower()
+
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
- assert p.returncode == 0, "mkbootimg of %s image failed" % (
- os.path.basename(sourcedir),)
+ assert p.returncode == 0, "mkbootimg of %s image failed" % (partition_name,)
if (info_dict.get("boot_signer", None) == "true" and
info_dict.get("verity_key", None)):
@@ -459,7 +466,7 @@
if two_step_image:
path = "/boot"
else:
- path = "/" + os.path.basename(sourcedir).lower()
+ path = "/" + partition_name
cmd = [OPTIONS.boot_signer_path]
cmd.extend(OPTIONS.boot_signer_args)
cmd.extend([path, img.name,
@@ -471,7 +478,7 @@
# Sign the image if vboot is non-empty.
elif info_dict.get("vboot", None):
- path = "/" + os.path.basename(sourcedir).lower()
+ path = "/" + partition_name
img_keyblock = tempfile.NamedTemporaryFile()
# We have switched from the prebuilt futility binary to using the tool
# (futility-host) built from the source. Override the setting in the old
@@ -498,15 +505,16 @@
avbtool = os.getenv('AVBTOOL') or info_dict["avb_avbtool"]
part_size = info_dict["boot_size"]
cmd = [avbtool, "add_hash_footer", "--image", img.name,
- "--partition_size", str(part_size), "--partition_name", "boot"]
- AppendAVBSigningArgs(cmd, "boot")
+ "--partition_size", str(part_size), "--partition_name",
+ partition_name]
+ AppendAVBSigningArgs(cmd, partition_name)
args = info_dict.get("avb_boot_add_hash_footer_args")
if args and args.strip():
cmd.extend(shlex.split(args))
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
assert p.returncode == 0, "avbtool add_hash_footer of %s failed" % (
- os.path.basename(OPTIONS.input_tmp))
+ partition_name,)
img.seek(os.SEEK_SET, 0)
data = img.read()
@@ -727,10 +735,18 @@
def CheckSize(data, target, info_dict):
- """Check the data string passed against the max size limit, if
- any, for the given target. Raise exception if the data is too big.
- Print a warning if the data is nearing the maximum size."""
+ """Checks the data string passed against the max size limit.
+ For non-AVB images, raise exception if the data is too big. Print a warning
+ if the data is nearing the maximum size.
+
+ For AVB images, the actual image size should be identical to the limit.
+
+ Args:
+ data: A string that contains all the data for the partition.
+ target: The partition name. The ".img" suffix is optional.
+ info_dict: The dict to be looked up for relevant info.
+ """
if target.endswith(".img"):
target = target[:-4]
mount_point = "/" + target
@@ -750,14 +766,22 @@
return
size = len(data)
- pct = float(size) * 100.0 / limit
- msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)
- if pct >= 99.0:
- raise ExternalError(msg)
- elif pct >= 95.0:
- print("\n WARNING: %s\n" % (msg,))
- elif OPTIONS.verbose:
- print(" ", msg)
+ # target could be 'userdata' or 'cache'. They should follow the non-AVB image
+ # path.
+ if info_dict.get("avb_enable") == "true" and target in AVB_PARTITIONS:
+ if size != limit:
+ raise ExternalError(
+ "Mismatching image size for %s: expected %d actual %d" % (
+ target, limit, size))
+ else:
+ pct = float(size) * 100.0 / limit
+ msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)
+ if pct >= 99.0:
+ raise ExternalError(msg)
+ elif pct >= 95.0:
+ print("\n WARNING: %s\n" % (msg,))
+ elif OPTIONS.verbose:
+ print(" ", msg)
def ReadApkCerts(tf_zip):
diff --git a/tools/signtos/Android.bp b/tools/signtos/Android.bp
new file mode 100644
index 0000000..b26631f
--- /dev/null
+++ b/tools/signtos/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// the signtos tool - signs Trusty images
+// ============================================================
+java_library_host {
+ name: "signtos",
+ srcs: ["SignTos.java"],
+ manifest: "SignTos.mf",
+ static_libs: [
+ "bouncycastle",
+ "bouncycastle-bcpkix",
+ ],
+}
diff --git a/tools/signtos/Android.mk b/tools/signtos/Android.mk
deleted file mode 100644
index 3e869b3..0000000
--- a/tools/signtos/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-
-# the signtos tool - signs Trusty images
-# ============================================================
-include $(CLEAR_VARS)
-LOCAL_MODULE := signtos
-LOCAL_SRC_FILES := SignTos.java
-LOCAL_JAR_MANIFEST := SignTos.mf
-LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle bouncycastle-bcpkix
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/warn.py b/tools/warn.py
index 44ad368..cc63de4 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1807,6 +1807,7 @@
'patterns': [r".*: warning: In file included from .+,"]},
# warnings from clang-tidy
+ group_tidy_warn_pattern('android'),
group_tidy_warn_pattern('cert'),
group_tidy_warn_pattern('clang-diagnostic'),
group_tidy_warn_pattern('cppcoreguidelines'),