diff --git a/core/Makefile b/core/Makefile index 09f9eb0ac3..da961f28dc 100644 --- a/core/Makefile +++ b/core/Makefile @@ -144,6 +144,21 @@ else endif FINAL_VENDOR_DEFAULT_PROPERTIES += \ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)) + +# Although these variables are prefixed with TARGET_RECOVERY_, they are also needed under charger +# mode (via libminui). +ifdef TARGET_RECOVERY_DEFAULT_ROTATION +FINAL_VENDOR_DEFAULT_PROPERTIES += \ + ro.minui.default_rotation=$(TARGET_RECOVERY_DEFAULT_ROTATION) +endif +ifdef TARGET_RECOVERY_OVERSCAN_PERCENT +FINAL_VENDOR_DEFAULT_PROPERTIES += \ + ro.minui.overscan_percent=$(TARGET_RECOVERY_OVERSCAN_PERCENT) +endif +ifdef TARGET_RECOVERY_PIXEL_FORMAT +FINAL_VENDOR_DEFAULT_PROPERTIES += \ + ro.minui.pixel_format=$(TARGET_RECOVERY_PIXEL_FORMAT) +endif FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \ $(FINAL_VENDOR_DEFAULT_PROPERTIES),=) @@ -1557,9 +1572,6 @@ endif INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default $(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \ - TARGET_RECOVERY_DEFAULT_ROTATION:default_rotation \ - TARGET_RECOVERY_OVERSCAN_PERCENT:overscan_percent \ - TARGET_RECOVERY_PIXEL_FORMAT:pixel_format \ TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \ TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \ TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \ @@ -2645,6 +2657,15 @@ BOARD_AVB_ALGORITHM := SHA256_RSA4096 BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem endif +INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \ + $(BOARD_AVB_VBMETA_MAINLINE) \ + $(BOARD_AVB_VBMETA_VENDOR) + +# Not allowing the same partition to appear in multiple groups. +ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))) + $(error BOARD_AVB_VBMETA_MAINLINE and BOARD_AVB_VBMETA_VENDOR cannot have duplicates) +endif + BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS @@ -2655,7 +2676,7 @@ PRODUCT_SERVICES_FOOTER_ARGS := BOARD_AVB_PRODUCT_SERVICES_ADD_HASHTREE_FOOTER_A ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS # Helper function that checks and sets required build variables for an AVB chained partition. -# $(1): the partition to enable AVB chain, e.g., boot or system. +# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_mainline. define _check-and-set-avb-chain-args $(eval part := $(1)) $(eval PART=$(call to-upper,$(part))) @@ -2677,20 +2698,27 @@ $(eval $(_signing_args) := \ $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \ --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey) -# Set rollback_index via footer args -$(eval _footer_args := $(PART)_FOOTER_ARGS) -$(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))) +# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up +# the index via a separate flag (e.g. BOARD_AVB_VBMETA_MAINLINE_ROLLBACK_INDEX). +$(if $(filter $(part),$(part:vbmeta_%=%)),\ + $(eval _footer_args := $(PART)_FOOTER_ARGS) \ + $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index)))) endef # Checks and sets the required build variables for an AVB partition. The partition will be # configured as a chained partition, if BOARD_AVB__KEY_PATH is defined. Otherwise the -# image descriptor will be included into vbmeta.img. +# image descriptor will be included into vbmeta.img, unless it has been already added to any chained +# VBMeta image. # $(1): Partition name, e.g. boot or system. define check-and-set-avb-args +$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))) $(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\ + $(if $(_in_chained_vbmeta),\ + $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \ $(call _check-and-set-avb-chain-args,$(1)),\ - $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \ - --include_descriptors_from_image $(call images-for-partitions,$(1)))) + $(if $(_in_chained_vbmeta),,\ + $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \ + --include_descriptors_from_image $(call images-for-partitions,$(1))))) endef ifdef INSTALLED_BOOTIMAGE_TARGET @@ -2723,6 +2751,15 @@ ifdef INSTALLED_RECOVERYIMAGE_TARGET $(eval $(call check-and-set-avb-args,recovery)) endif +# Not using INSTALLED_VBMETA_MAINLINEIMAGE_TARGET as it won't be set yet. +ifdef BOARD_AVB_VBMETA_MAINLINE +$(eval $(call check-and-set-avb-args,vbmeta_mainline)) +endif + +ifdef BOARD_AVB_VBMETA_VENDOR +$(eval $(call check-and-set-avb-args,vbmeta_vendor)) +endif + # Add kernel cmdline descriptor for kernel to mount system.img as root with # dm-verity. This works when system.img is either chained or not-chained: # - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel @@ -2734,13 +2771,27 @@ BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel endif BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096 +BOARD_AVB_MAKE_VBMETA_MAINLINE_IMAGE_ARGS += --padding_size 4096 +BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096 + +ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT))) +BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag +BOARD_AVB_MAKE_VBMETA_MAINLINE_IMAGE_ARGS += --set_hashtree_disabled_flag +BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --set_hashtree_disabled_flag +endif ifdef BOARD_AVB_ROLLBACK_INDEX BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX) endif -ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT))) -BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag +ifdef BOARD_AVB_VBMETA_MAINLINE_ROLLBACK_INDEX +BOARD_AVB_MAKE_VBMETA_MAINLINE_IMAGE_ARGS += \ + --rollback_index $(BOARD_AVB_VBMETA_MAINLINE_ROLLBACK_INDEX) +endif + +ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX +BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \ + --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX) endif # $(1): the directory to extract public keys to @@ -2769,8 +2820,50 @@ define extract-avb-chain-public-keys $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\ $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \ --output $(1)/recovery.avbpubkey) + $(if $(BOARD_AVB_VBMETA_MAINLINE_KEY_PATH),\ + $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_MAINLINE_KEY_PATH) \ + --output $(1)/vbmeta_mainline.avbpubkey) + $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\ + $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \ + --output $(1)/vbmeta_vendor.avbpubkey) endef +# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions +# specified in BOARD_AVB_VBMETA_. The built VBMeta image will be included into the top-level +# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_MAINLINE +# := system product_services`, `vbmeta_mainline.img` will be created that includes the descriptors +# for `system.img` and `product_services.img`. `vbmeta_mainline.img` itself will be included into +# `vbmeta.img` as a chained partition. +# $(1): VBMeta image name, such as "vbmeta_mainline", "vbmeta_vendor" etc. +# $(2): Output filename. +define build-chained-vbmeta-image + $(call pretty,"Target chained vbmeta image: $@") + $(hide) $(AVBTOOL) make_vbmeta_image \ + $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \ + $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \ + $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \ + --include_descriptors_from_image $(call images-for-partitions,$(image))) \ + --output $@ +endef + +ifdef BOARD_AVB_VBMETA_MAINLINE +INSTALLED_VBMETA_MAINLINEIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_mainline.img +$(INSTALLED_VBMETA_MAINLINEIMAGE_TARGET): \ + $(AVBTOOL) \ + $(call images-for-partitions,$(BOARD_AVB_VBMETA_MAINLINE)) \ + $(BOARD_AVB_VBMETA_MAINLINE_KEY_PATH) + $(call build-chained-vbmeta-image,vbmeta_mainline) +endif + +ifdef BOARD_AVB_VBMETA_VENDOR +INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img +$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \ + $(AVBTOOL) \ + $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \ + $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) + $(call build-chained-vbmeta-image,vbmeta_vendor) +endif + define build-vbmetaimage-target $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)") $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR) @@ -2797,6 +2890,10 @@ $(INSTALLED_VBMETAIMAGE_TARGET): \ $(INSTALLED_ODMIMAGE_TARGET) \ $(INSTALLED_DTBOIMAGE_TARGET) \ $(INSTALLED_RECOVERYIMAGE_TARGET) \ + $(INSTALLED_VBMETA_MAINLINEIMAGE_TARGET) \ + $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \ + $(BOARD_AVB_VBMETA_MAINLINE_KEY_PATH) \ + $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \ $(BOARD_AVB_KEY_PATH) $(build-vbmetaimage-target) @@ -2804,14 +2901,6 @@ $(INSTALLED_VBMETAIMAGE_TARGET): \ vbmetaimage-nodeps: $(build-vbmetaimage-target) -else ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE)) -BUILT_DISABLED_VBMETAIMAGE := $(PRODUCT_OUT)/vbmeta.img - -INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_DISABLED_VBMETAIMAGE) -$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL) - $(hide) $(AVBTOOL) make_vbmeta_image \ - --flag 2 --padding_size 4096 --output $@ - endif # BOARD_AVB_ENABLE # ----------------------------------------------------------------- @@ -3380,6 +3469,20 @@ ifdef BOARD_AVB_RECOVERY_KEY_PATH $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $(zip_root)/META/misc_info.txt $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt endif # BOARD_AVB_RECOVERY_KEY_PATH +ifneq (,$(strip $(BOARD_AVB_VBMETA_MAINLINE))) + $(hide) echo "avb_vbmeta_mainline=$(BOARD_AVB_VBMETA_MAINLINE)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_mainline_args=$(BOARD_AVB_MAKE_VBMETA_MAINLINE_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_mainline_key_path=$(BOARD_AVB_VBMETA_MAINLINE_KEY_PATH)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_mainline_algorithm=$(BOARD_AVB_VBMETA_MAINLINE_ALGORITHM)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_mainline_rollback_index_location=$(BOARD_AVB_VBMETA_MAINLINE_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt +endif # BOARD_AVB_VBMETA_MAINLINE +ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR))) + $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_MAINLINE_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt +endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH endif # BOARD_AVB_ENABLE ifdef BOARD_BPT_INPUT_FILES $(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt @@ -3416,14 +3519,6 @@ ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true) @# If breakpad symbols have been generated, add them to the zip. $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD endif -# BOARD_BUILD_DISABLED_VBMETAIMAGE is used to build a special vbmeta.img -# that disables AVB verification. The content is fixed and we can just copy -# it to $(zip_root)/IMAGES without passing some info into misc_info.txt for -# regeneration. -ifeq (true,$(BOARD_BUILD_DISABLED_VBMETAIMAGE)) - $(hide) mkdir -p $(zip_root)/IMAGES - $(hide) cp $(INSTALLED_VBMETAIMAGE_TARGET) $(zip_root)/IMAGES/ -endif ifdef BOARD_PREBUILT_VENDORIMAGE $(hide) mkdir -p $(zip_root)/IMAGES $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/ diff --git a/core/base_rules.mk b/core/base_rules.mk index fce7a1f8ef..58d838d231 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -328,7 +328,11 @@ LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE) # As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used, # dependent binaries of a .toc file will be rebuilt only when the content of # the .toc file is changed. +# +# Don't create .toc files for Soong shared libraries, that is handled in +# Soong and soong_cc_prebuilt.mk ########################################################### +ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc $(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE) @@ -345,6 +349,7 @@ $(eval $(call copy-one-file,$(LOCAL_BUILT_MODULE).toc,$(OVERRIDE_BUILT_MODULE_PA $(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc: $(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem) endif endif +endif ########################################################### ## logtags: Add .logtags files to global list diff --git a/core/binary.mk b/core/binary.mk index 2ccdb4131e..440c32df1b 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -372,10 +372,7 @@ my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_V my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries) my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries) -# soong defined modules already have done through this -ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) include $(BUILD_SYSTEM)/cxx_stl_setup.mk -endif # Add static HAL libraries ifdef LOCAL_HAL_STATIC_LIBRARIES @@ -392,8 +389,6 @@ else my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER) endif -# Modules from soong do not need this since the dependencies are already handled there. -ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) include $(BUILD_SYSTEM)/config_sanitizers.mk ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true) @@ -407,7 +402,6 @@ endif ifeq ($($(my_prefix)OS),windows) my_static_libraries += libwinpthread endif -endif # this module is not from soong ifneq ($(filter ../%,$(my_src_files)),) my_soong_problems += dotdot_srcs @@ -1270,29 +1264,23 @@ ifneq ($(LOCAL_USE_VNDK),) ## switch all soong libraries over to the /vendor ## variant. #################################################### - ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - # We don't do this renaming for soong-defined modules since they already have correct - # names (with .vendor suffix when necessary) in their LOCAL_*_LIBRARIES. - my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\ - $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) - my_static_libraries := $(foreach l,$(my_static_libraries),\ - $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) - my_shared_libraries := $(foreach l,$(my_shared_libraries),\ - $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) - my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\ - $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) - my_header_libraries := $(foreach l,$(my_header_libraries),\ - $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l))) - endif + my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\ + $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) + my_static_libraries := $(foreach l,$(my_static_libraries),\ + $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) + my_shared_libraries := $(foreach l,$(my_shared_libraries),\ + $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) + my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\ + $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) + my_header_libraries := $(foreach l,$(my_header_libraries),\ + $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l))) endif # Platform can use vendor public libraries. If a required shared lib is one of # the vendor public libraries, the lib is switched to the stub version of the lib. ifeq ($(LOCAL_USE_VNDK),) - ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - my_shared_libraries := $(foreach l,$(my_shared_libraries),\ - $(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l))) - endif + my_shared_libraries := $(foreach l,$(my_shared_libraries),\ + $(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l))) endif ########################################################## @@ -1613,26 +1601,23 @@ ifeq ($(my_strict),true) endif # Check if -Werror or -Wno-error is used in C compiler flags. -# Modules defined in $(SOONG_ANDROID_MK) are checked in soong's cc.go. -ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - # Header libraries do not need cflags. - ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)) - # Prebuilt modules do not need cflags. - ifeq (,$(LOCAL_PREBUILT_MODULE_FILE)) - my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override) - # Issue warning if -Wno-error is used. - ifneq (,$(filter -Wno-error,$(my_all_cflags))) - $(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE)) - else - # Issue warning if -Werror is not used. Add it. - ifeq (,$(filter -Werror,$(my_all_cflags))) - # Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list. - ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH)))) - my_cflags := -Wall -Werror $(my_cflags) - else - $(eval MODULES_ADDED_WALL := $(MODULES_ADDED_WALL) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE)) - my_cflags := -Wall $(my_cflags) - endif +# Header libraries do not need cflags. +ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)) + # Prebuilt modules do not need cflags. + ifeq (,$(LOCAL_PREBUILT_MODULE_FILE)) + my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override) + # Issue warning if -Wno-error is used. + ifneq (,$(filter -Wno-error,$(my_all_cflags))) + $(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE)) + else + # Issue warning if -Werror is not used. Add it. + ifeq (,$(filter -Werror,$(my_all_cflags))) + # Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list. + ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH)))) + my_cflags := -Wall -Werror $(my_cflags) + else + $(eval MODULES_ADDED_WALL := $(MODULES_ADDED_WALL) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE)) + my_cflags := -Wall $(my_cflags) endif endif endif @@ -1764,12 +1749,6 @@ all_libraries := \ ########################################################### export_includes := $(intermediates)/export_includes export_cflags := $(foreach d,$(my_export_c_include_dirs),-I $(d)) -# Soong exports cflags instead of include dirs, so that -isystem can be included. -ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) -export_cflags += $(LOCAL_EXPORT_CFLAGS) -else ifdef LOCAL_EXPORT_CFLAGS -$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead) -endif $(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags) # Headers exported by whole static libraries are also exported by this library. export_include_deps := $(strip \ @@ -1814,7 +1793,6 @@ export_cflags := # Make sure export_includes gets generated when you are running mm/mmm $(LOCAL_BUILT_MODULE) : | $(export_includes) -ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs))) my_soong_problems += non_local__export_c_include_dirs endif @@ -1830,7 +1808,6 @@ SOONG_CONV.$(LOCAL_MODULE).DEPS := \ $(my_system_shared_libraries)) SOONG_CONV.$(LOCAL_MODULE).TYPE := native SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE) -endif ########################################################### # Coverage packaging. diff --git a/core/build_id.mk b/core/build_id.mk index 18f9495bd2..db94c72c8f 100644 --- a/core/build_id.mk +++ b/core/build_id.mk @@ -18,4 +18,4 @@ # (like "CRB01"). It must be a single word, and is # capitalized by convention. -BUILD_ID=QP1A.180911.002 +BUILD_ID=QP1A.180912.001 diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 07c7e51f73..f738ab409b 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -3,6 +3,7 @@ ########################################################### # '',true +LOCAL_2ND_ARCH_VAR_PREFIX:= LOCAL_32_BIT_ONLY:= LOCAL_AAPT2_ONLY:= LOCAL_AAPT_FLAGS:= @@ -66,13 +67,16 @@ LOCAL_DONT_DELETE_JAR_META_INF:= LOCAL_DONT_MERGE_MANIFESTS:= LOCAL_DPI_FILE_STEM:= LOCAL_DPI_VARIANTS:= +LOCAL_DROIDDOC_ANNOTATIONS_ZIP := LOCAL_DROIDDOC_ASSET_DIR:= LOCAL_DROIDDOC_CUSTOM_ASSET_DIR:= LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:= +LOCAL_DROIDDOC_DOC_ZIP := LOCAL_DROIDDOC_HTML_DIR:= LOCAL_DROIDDOC_OPTIONS:= LOCAL_DROIDDOC_SOURCE_PATH:= LOCAL_DROIDDOC_STUB_OUT_DIR:= +LOCAL_DROIDDOC_STUBS_SRCJAR := LOCAL_DROIDDOC_TEMPLATE_DIR:= LOCAL_DROIDDOC_USE_STANDARD_DOCLET:= LOCAL_DX_FLAGS:= @@ -107,6 +111,7 @@ LOCAL_GROUP_STATIC_LIBRARIES:= LOCAL_GTEST:=true LOCAL_HAL_STATIC_LIBRARIES:= LOCAL_HEADER_LIBRARIES:= +LOCAL_HOST_PREFIX:= LOCAL_HOST_REQUIRED_MODULES:= LOCAL_INIT_RC:= LOCAL_INSTALLED_MODULE:= @@ -252,13 +257,13 @@ LOCAL_SOONG_DEX_JAR := LOCAL_SOONG_EXPORT_PROGUARD_FLAGS := LOCAL_SOONG_HEADER_JAR := LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR := +LOCAL_SOONG_LINK_TYPE := LOCAL_SOONG_PROGUARD_DICT := LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE := LOCAL_SOONG_RRO_DIRS := LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES := -LOCAL_DROIDDOC_STUBS_SRCJAR := -LOCAL_DROIDDOC_DOC_ZIP := -LOCAL_DROIDDOC_ANNOTATIONS_ZIP := +LOCAL_SOONG_TOC := +LOCAL_SOONG_UNSTRIPPED_BINARY := # '',true LOCAL_SOURCE_FILES_ALL_GENERATED:= LOCAL_SRC_FILES:= diff --git a/core/header_library_internal.mk b/core/header_library_internal.mk index 3e4958fb41..35ee1bc032 100644 --- a/core/header_library_internal.mk +++ b/core/header_library_internal.mk @@ -11,16 +11,6 @@ ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),) $(error $(LOCAL_PATH): Cannot set module stem for a library) endif -ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - ifdef LOCAL_USE_VNDK - name_without_suffix := $(patsubst %.vendor,%,$(LOCAL_MODULE)) - ifneq ($(name_without_suffix),$(LOCAL_MODULE)) - SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1 - endif - name_without_suffix := - endif -endif - include $(BUILD_SYSTEM)/binary.mk ifneq ($(strip $(all_objects)),) diff --git a/core/main.mk b/core/main.mk index fd62a9865c..1b00124487 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1391,7 +1391,7 @@ endif # TARGET_BUILD_APPS .PHONY: docs docs: $(ALL_DOCS) -.PHONY: sdk +.PHONY: sdk win_sdk winsdk-tools ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET) sdk: $(ALL_SDK_TARGETS) $(call dist-for-goals,sdk win_sdk, \ diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 78da421bd5..256c598466 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -68,20 +68,6 @@ else prebuilt_module_is_a_library := endif -ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - ifeq ($(prebuilt_module_is_a_library),true) - SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) - endif - - ifdef LOCAL_USE_VNDK - name_without_suffix := $(patsubst %.vendor,%,$(LOCAL_MODULE)) - ifneq ($(name_without_suffix),$(LOCAL_MODULE) - SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1 - endif - name_without_suffix := - endif -endif - # Don't install static libraries by default. ifndef LOCAL_UNINSTALLABLE_MODULE ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) @@ -156,12 +142,6 @@ else # my_strip_module not true ifdef prebuilt_module_is_a_library export_includes := $(intermediates)/export_includes export_cflags := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d)) -# Soong exports cflags instead of include dirs, so that -isystem can be included. -ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) -export_cflags += $(LOCAL_EXPORT_CFLAGS) -else ifdef LOCAL_EXPORT_CFLAGS -$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead) -endif $(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags) $(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS) @echo Export includes file: $< -- $@ @@ -210,10 +190,8 @@ my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) # Extra shared libraries introduced by LOCAL_CXX_STL. include $(BUILD_SYSTEM)/cxx_stl_setup.mk ifdef LOCAL_USE_VNDK - ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - my_shared_libraries := $(foreach l,$(my_shared_libraries),\ - $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) - endif + my_shared_libraries := $(foreach l,$(my_shared_libraries),\ + $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) endif $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk new file mode 100644 index 0000000000..9aa6fb746b --- /dev/null +++ b/core/soong_cc_prebuilt.mk @@ -0,0 +1,209 @@ +# Native prebuilt coming from Soong. +# Extra inputs: +# LOCAL_SOONG_LINK_TYPE +# LOCAL_SOONG_TOC +# LOCAL_SOONG_UNSTRIPPED_BINARY + +ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) + $(call pretty-error,soong_cc_prebuilt.mk may only be used from Soong) +endif + +skip_module := +ifdef LOCAL_IS_HOST_MODULE + ifneq ($(HOST_OS),$(LOCAL_MODULE_HOST_OS)) + my_prefix := HOST_CROSS_ + LOCAL_HOST_PREFIX := $(my_prefix) + else + my_prefix := HOST_ + LOCAL_HOST_PREFIX := + endif +else + my_prefix := TARGET_ +endif + +ifeq ($($(my_prefix)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)) + # primary arch + LOCAL_2ND_ARCH_VAR_PREFIX := +else ifeq ($($(my_prefix)2ND_ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)) + # secondary arch + LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX) +else + $(call pretty-error,Unsupported LOCAL_MODULE_$(my_prefix)ARCH=$(LOCAL_MODULE_$(my_prefix)ARCH)) +endif + +ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) + ifndef LOCAL_IS_HOST_MODULE + ifdef LOCAL_2ND_ARCH_VAR_PREFIX + # Only support shared and static libraries and tests for translated arch + ifeq ($(filter SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) + skip_module := true + endif + endif + endif +endif + +ifndef skip_module + +# Don't install static libraries by default. +ifndef LOCAL_UNINSTALLABLE_MODULE + ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) + LOCAL_UNINSTALLABLE_MODULE := true + endif +endif + +ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) + # LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES indicates that this prebuilt should be + # installed to the common directory of libraries. This is needed for the NDK + # shared libraries built by soong, as we build many different versions of each + # library (one for each API level). Since they all have the same basename, + # they'd clobber each other (as well as any platform libraries by the same + # name). + ifneq ($(LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES),false) + # Put the built targets of all shared libraries in a common directory + # to simplify the link line. + OVERRIDE_BUILT_MODULE_PATH := \ + $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) + endif +endif + +####################################### +include $(BUILD_SYSTEM)/base_rules.mk +####################################### + +ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) + # Soong module is a static or shared library + export_includes := $(intermediates)/export_includes + $(export_includes): PRIVATE_EXPORT_CFLAGS := $(LOCAL_EXPORT_CFLAGS) + $(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS) + @echo Export includes file: $< -- $@ + $(hide) mkdir -p $(dir $@) && rm -f $@ + ifdef LOCAL_EXPORT_CFLAGS + $(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >$@ + else + $(hide) touch $@ + endif + + ifdef LOCAL_SOONG_TOC + $(eval $(call copy-one-file,$(LOCAL_SOONG_TOC),$(LOCAL_BUILT_MODULE).toc)) + $(call add-dependency,$(LOCAL_BUILT_MODULE).toc,$(LOCAL_BUILT_MODULE)) + $(my_all_targets): $(LOCAL_BUILT_MODULE).toc + + ifdef OVERRIDE_BUILT_MODULE_PATH + $(eval $(call copy-one-file,$(LOCAL_BUILT_MODULE).toc,$(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc)) + $(call add-dependency,$(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc,$(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem)) + $(my_all_targets): $(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc + endif + endif + + SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) + + my_link_type := $(LOCAL_SOONG_LINK_TYPE) + my_warn_types := + my_allowed_types := + my_link_deps := + my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) + my_common := + include $(BUILD_SYSTEM)/link_type.mk +endif + +ifdef LOCAL_USE_VNDK + name_without_suffix := $(patsubst %.vendor,%,$(LOCAL_MODULE)) + ifneq ($(name_without_suffix),$(LOCAL_MODULE) + SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1 + endif + name_without_suffix := +endif + +# The real dependency will be added after all Android.mks are loaded and the install paths +# of the shared libraries are determined. +ifdef LOCAL_INSTALLED_MODULE + ifdef LOCAL_SHARED_LIBRARIES + my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) + ifdef LOCAL_USE_VNDK + my_shared_libraries := $(foreach l,$(my_shared_libraries),\ + $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) + endif + $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ + $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) + + # We also need the LOCAL_BUILT_MODULE dependency, + # since we use -rpath-link which points to the built module's path. + my_built_shared_libraries := \ + $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ + $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ + $(my_shared_libraries))) + $(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) + endif +endif + +$(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) + $(transform-prebuilt-to-target) +ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) + $(hide) chmod +x $@ +endif + +ifndef LOCAL_IS_HOST_MODULE + ifdef LOCAL_SOONG_UNSTRIPPED_BINARY + # Store a copy with symbols for symbolic debugging + my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) + symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem) + $(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output))) + $(call add-dependency,$(LOCAL_BUILT_MODULE),$(symbolic_output)) + + ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true) + my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) + breakpad_output := $(my_breakpad_path)/$(my_installed_module_stem).sym + $(breakpad_output) : $(LOCAL_SOONG_UNSTRIPPED_BINARY) | $(BREAKPAD_DUMP_SYMS) $(PRIVATE_READELF) + @echo "target breakpad: $(PRIVATE_MODULE) ($@)" + @mkdir -p $(dir $@) + $(hide) if $(PRIVATE_READELF) -S $< > /dev/null 2>&1 ; then \ + $(BREAKPAD_DUMP_SYMS) -c $< > $@ ; \ + else \ + echo "skipped for non-elf file."; \ + touch $@; \ + fi + $(call add-dependency,$(LOCAL_BUILT_MODULE),$(breakpad_output)) + endif + endif +endif + +ifeq ($(NATIVE_COVERAGE),true) + ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE))) + $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir)) + ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true) + ifdef LOCAL_IS_HOST_MODULE + my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) + else + my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) + endif + 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 + else + # Coverage information is needed when static lib is a dependency of another + # coverage-enabled module. + ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS)) + GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir + $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := + $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := + $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix) + $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) + $(intermediates)/$(GCNO_ARCHIVE) : + $(transform-o-to-static-lib) + endif + endif +endif + +# A product may be configured to strip everything in some build variants. +# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE +# is still with the symbols and we don't need to clean it (and relink) when +# you switch build variant. +ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),) +$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \ + $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE) +endif + +endif # !skip_module + +skip_module := diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk index bc11b4941b..91443a0e54 100644 --- a/core/tasks/sdk-addon.mk +++ b/core/tasks/sdk-addon.mk @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +.PHONY: sdk_addon # If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define # any of these rules. @@ -122,7 +123,6 @@ $(full_target_img): $(full_target) $(addon_img_source_prop) | $(ACP) $(SOONG_ZIP $(hide) $(SOONG_ZIP) -o $@ -C $(dir $(PRIVATE_STAGING_DIR)) -D $(PRIVATE_STAGING_DIR) -.PHONY: sdk_addon sdk_addon: $(full_target) $(full_target_img) ifneq ($(sdk_repo_goal),) diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk index ca2176c735..a1d5cde0dd 100644 --- a/target/board/BoardConfigEmuCommon.mk +++ b/target/board/BoardConfigEmuCommon.mk @@ -28,8 +28,9 @@ USE_OPENGL_RENDERER := true TARGET_COPY_OUT_VENDOR := vendor # ~100 MB vendor image. Please adjust system image / vendor image sizes -# when finalizing them. -BOARD_VENDORIMAGE_PARTITION_SIZE := 100000000 +# when finalizing them. The partition size needs to be a multiple of image +# block size: 4096. +BOARD_VENDORIMAGE_PARTITION_SIZE := 100003840 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 BOARD_FLASH_BLOCK_SIZE := 512 DEVICE_MATRIX_FILE := device/generic/goldfish/compatibility_matrix.xml diff --git a/target/board/BoardConfigGsiCommon.mk b/target/board/BoardConfigGsiCommon.mk index c1f36271f6..1df981b073 100644 --- a/target/board/BoardConfigGsiCommon.mk +++ b/target/board/BoardConfigGsiCommon.mk @@ -10,18 +10,28 @@ TARGET_USERIMAGES_USE_EXT4 := true # we explicit specify this need below (even though it's the current default). TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false -# Enable dyanmic system image size and reserved 64MB in it. -BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE := 67108864 +# Enable dynamic system image size and reserved 128MB in it. +# Currently the reserve size includes verified boot metadata. +# TODO: adjust to a smaller value if the reserved size is only for file system. +BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE := 134217728 # Android Verified Boot (AVB): -# Builds a special vbmeta.img that disables AVB verification. -# Otherwise, AVB will prevent the device from booting the generic system.img. -# Also checks that BOARD_AVB_ENABLE is not set, to prevent adding verity -# metadata into system.img. -ifeq ($(BOARD_AVB_ENABLE),true) -$(error BOARD_AVB_ENABLE cannot be set for GSI) -endif -BOARD_BUILD_DISABLED_VBMETAIMAGE := true +# 1) Sets BOARD_AVB_ENABLE to sign the GSI image. +# 2) Sets AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED (--flag 2) in +# vbmeta.img to disable AVB verification. +# +# To disable AVB for GSI, use the vbmeta.img and the GSI together. +# To enable AVB for GSI, include the GSI public key into the device-specific +# vbmeta.img. +BOARD_AVB_ENABLE := true +BOARD_AVB_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) +BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2 + +# Enable chain partition for system. +BOARD_AVB_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem +BOARD_AVB_SYSTEM_ALGORITHM := SHA256_RSA2048 +BOARD_AVB_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) +BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) # GSI is always userdebug and needs a couple of properties taking precedence diff --git a/target/board/treble_common.mk b/target/board/treble_common.mk index daa0f4cdbc..186900074d 100644 --- a/target/board/treble_common.mk +++ b/target/board/treble_common.mk @@ -35,8 +35,10 @@ TARGET_USERIMAGES_USE_EXT4 := true TARGET_USERIMAGES_USE_F2FS := true TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false -# Enable dyanmic system image size and reserved 64MB in it. -BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE := 67108864 +# Enable dynamic system image size and reserved 128MB in it. +# Currently the reserve size includes verified boot metadata. +# TODO: adjust to a smaller value if the reserved size is only for file system. +BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE := 134217728 # Generic AOSP image always requires separate vendor.img TARGET_COPY_OUT_VENDOR := vendor @@ -53,11 +55,19 @@ NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 USE_XML_AUDIO_POLICY_CONF := 1 # Android Verified Boot (AVB): -# Builds a special vbmeta.img that disables AVB verification. -# Otherwise, AVB will prevent the device from booting the generic system.img. -# Also checks that BOARD_AVB_ENABLE is not set, to prevent adding verity -# metadata into system.img. -ifeq ($(BOARD_AVB_ENABLE),true) -$(error BOARD_AVB_ENABLE cannot be set for Treble GSI) -endif -BOARD_BUILD_DISABLED_VBMETAIMAGE := true +# 1) Sets BOARD_AVB_ENABLE to sign the GSI image. +# 2) Sets AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED (--flag 2) in +# vbmeta.img to disable AVB verification. +# +# To disable AVB for GSI, use the vbmeta.img and the GSI together. +# To enable AVB for GSI, include the GSI public key into the device-specific +# vbmeta.img. +BOARD_AVB_ENABLE := true +BOARD_AVB_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) +BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2 + +# Enable chain partition for system. +BOARD_AVB_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem +BOARD_AVB_SYSTEM_ALGORITHM := SHA256_RSA2048 +BOARD_AVB_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) +BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 9e8b6987ab..e9419feb5a 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -393,32 +393,46 @@ def AppendVBMetaArgsForPartition(cmd, partition, image): cmd.extend(["--include_descriptors_from_image", image]) -def AddVBMeta(output_zip, partitions): - """Creates a VBMeta image and store it in output_zip. +def AddVBMeta(output_zip, partitions, name, needed_partitions): + """Creates a VBMeta image and stores it in output_zip. + + It generates the requested VBMeta image. The requested image could be for + top-level or chained VBMeta image, which is determined based on the name. 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, as listed in common.AVB_PARTITIONS. + name: Name of the VBMeta partition, e.g. 'vbmeta', 'vbmeta_mainline'. + needed_partitions: Partitions whose descriptors should be included into the + generated VBMeta image. + + Raises: + AssertionError: On invalid input args. """ - img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "vbmeta.img") + assert needed_partitions, "Needed partitions must be specified" + + img = OutputFile( + output_zip, OPTIONS.input_tmp, "IMAGES", "{}.img".format(name)) if os.path.exists(img.input_name): - print("vbmeta.img already exists; not rebuilding...") + print("{}.img already exists; not rebuilding...".format(name)) 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") + common.AppendAVBSigningArgs(cmd, name) for partition, path in partitions.items(): + if partition not in needed_partitions: + continue assert partition in common.AVB_PARTITIONS, \ 'Unknown partition: {}'.format(partition) assert os.path.exists(path), \ 'Failed to find {} for {}'.format(path, partition) AppendVBMetaArgsForPartition(cmd, partition, path) - args = OPTIONS.info_dict.get("avb_vbmeta_args") + args = OPTIONS.info_dict.get("avb_{}_args".format(name)) if args and args.strip(): split_args = shlex.split(args) for index, arg in enumerate(split_args[:-1]): @@ -439,7 +453,7 @@ def AddVBMeta(output_zip, partitions): split_args[index + 1] = alt_path found = True break - assert found, 'failed to find %s' % (image_path,) + assert found, 'Failed to find {}'.format(image_path) cmd.extend(split_args) p = common.Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -693,8 +707,8 @@ def AddImagesToTargetFiles(filename): os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", "vendor.img"))) has_odm = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "ODM")) or - os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", - "odm.img"))) + os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", + "odm.img"))) has_product = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "PRODUCT")) or os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", "product.img"))) @@ -806,8 +820,33 @@ def AddImagesToTargetFiles(filename): partitions['dtbo'] = AddDtbo(output_zip) if OPTIONS.info_dict.get("avb_enable") == "true": + # vbmeta_partitions includes the partitions that should be included into + # top-level vbmeta.img, which are the ones that are not included in any + # chained VBMeta image plus the chained VBMeta images themselves. + vbmeta_partitions = common.AVB_PARTITIONS[:] + + vbmeta_mainline = OPTIONS.info_dict.get("avb_vbmeta_mainline", "").strip() + if vbmeta_mainline: + banner("vbmeta_mainline") + AddVBMeta( + output_zip, partitions, "vbmeta_mainline", vbmeta_mainline.split()) + vbmeta_partitions = [ + item for item in vbmeta_partitions + if item not in vbmeta_mainline.split()] + vbmeta_partitions.append("vbmeta_mainline") + + vbmeta_vendor = OPTIONS.info_dict.get("avb_vbmeta_vendor", "").strip() + if vbmeta_vendor: + banner("vbmeta_vendor") + AddVBMeta( + output_zip, partitions, "vbmeta_vendor", vbmeta_vendor.split()) + vbmeta_partitions = [ + item for item in vbmeta_partitions + if item not in vbmeta_vendor.split()] + vbmeta_partitions.append("vbmeta_vendor") + banner("vbmeta") - AddVBMeta(output_zip, partitions) + AddVBMeta(output_zip, partitions, "vbmeta", vbmeta_partitions) if OPTIONS.info_dict.get("super_size"): banner("super_empty") diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 8d51df6b2d..ee2c6f4998 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -408,7 +408,7 @@ def AppendAVBSigningArgs(cmd, partition): cmd.extend(["--key", key_path, "--algorithm", algorithm]) avb_salt = OPTIONS.info_dict.get("avb_salt") # make_vbmeta_image doesn't like "--salt" (and it's not needed). - if avb_salt and partition != "vbmeta": + if avb_salt and not partition.startswith("vbmeta"): cmd.extend(["--salt", avb_salt])