diff options
30 files changed, 747 insertions, 414 deletions
diff --git a/core/Makefile b/core/Makefile index 352ab1adad..2e72727cde 100644 --- a/core/Makefile +++ b/core/Makefile @@ -778,7 +778,7 @@ $(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_U $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@ ifeq ($(HOST_OS),linux) -$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT)) +$(call dist-for-goals, sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT)) endif #------------------------------------------------------------------ @@ -1617,7 +1617,8 @@ endef # $(2) the image prop file define add-common-ro-flags-to-image-props $(eval _var := $(call to-upper,$(1))) -$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor"$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2)) +$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2)) +$(if $(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE),$(hide) echo "$(1)_erofs_pcluster_size=$(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE)" >> $(2)) $(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2)) $(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2)) $(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2)) @@ -1634,6 +1635,8 @@ $(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$ $(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE)) $(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)) $(eval _headroom := $(PRODUCT_$(_var)_HEADROOM)) +$(if $(or $(_size), $(_reserved), $(_headroom)),, + $(hide) echo "$(1)_disable_sparse=true" >> $(2)) $(call add-common-flags-to-image-props,$(1),$(2)) endef @@ -1697,6 +1700,8 @@ $(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$( $(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1)) $(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1)) $(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1)) +$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1)) +$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1)) $(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1)) $(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1)) $(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1)) @@ -2289,76 +2294,83 @@ endif # Build debug ramdisk and debug boot image. ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),) +INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \ + $(ALL_GENERATED_SOURCES) \ + $(ALL_DEFAULT_INSTALLED_MODULES)) + +# Directories to be picked into the debug ramdisk. +# As these directories are all merged into one single cpio archive, the order +# matters. If there are multiple files with the same pathname, then the last one +# wins. +# # ramdisk-debug.img will merge the content from either ramdisk.img or # ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT # is set or not. -# INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP would ensure INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR is created. ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) - INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) - INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP := $(recovery_ramdisk) + INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT) + INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk) else # BOARD_USES_RECOVERY_AS_BOOT == true - INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR := $(TARGET_RAMDISK_OUT) - INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP := $(INSTALLED_RAMDISK_TARGET) + INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT) + INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET) endif # BOARD_USES_RECOVERY_AS_BOOT != true -# ----------------------------------------------------------------- -# the debug ramdisk, which is the original ramdisk plus additional -# files: force_debuggable, adb_debug.prop and userdebug sepolicy. -# When /force_debuggable is present, /init will load userdebug sepolicy -# and property files to allow adb root, if the device is unlocked. -INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img - -INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \ - $(ALL_GENERATED_SOURCES) \ - $(ALL_DEFAULT_INSTALLED_MODULES)) +INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT) +INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES) # INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created. INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK) -$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP) -$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL) - @echo Installed file list: $@ - mkdir -p $(dir $@) - rm -f $@ - $(FILESLIST) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) > $(@:.txt=.json) +$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS) +$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL) + @echo "Installed file list: $@" + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT) + touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable + $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@ +ifdef BUILDING_DEBUG_BOOT_IMAGE + +# ----------------------------------------------------------------- +# the debug ramdisk, which is the original ramdisk plus additional +# files: force_debuggable, adb_debug.prop and userdebug sepolicy. +# When /force_debuggable is present, /init will load userdebug sepolicy +# and property files to allow adb root, if the device is unlocked. +INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img + $(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) -$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP) -$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS) - $(call pretty,"Target debug ramdisk: $@") - mkdir -p $(TARGET_DEBUG_RAMDISK_OUT) - touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ +$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) + @echo "Target debug ramdisk: $@" + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@ .PHONY: ramdisk_debug-nodeps ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) - echo "make $@: ignoring dependencies" - mkdir -p $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) - touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET) + @echo "make $@: ignoring dependencies" + $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET) + $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET) # ----------------------------------------------------------------- # the boot-debug.img, which is the kernel plus ramdisk-debug.img # # Note: it's intentional to skip signing for boot-debug.img, because it # can only be used if the device is unlocked with verification error. -ifdef BUILDING_DEBUG_BOOT_IMAGE - ifneq ($(strip $(BOARD_KERNEL_BINARIES)),) - INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,$(DEBUG_RAMDISK_BOOT_IMAGE_NAME),$(BOARD_KERNEL_BINARIES)), \ + INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \ $(PRODUCT_OUT)/$(k).img) else - INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/$(DEBUG_RAMDISK_BOOT_IMAGE_NAME).img + INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img endif # Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img $(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET) ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) - INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_RECOVERYIMAGE_ARGS)) + INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_RECOVERYIMAGE_ARGS)) else - INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_BOOTIMAGE_ARGS)) + INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_BOOTIMAGE_ARGS)) endif # If boot.img is chained but boot-debug.img is not signed, libavb in bootloader @@ -2385,10 +2397,10 @@ endef # $(1): output file define build-debug-bootimage-target - $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst $(DEBUG_RAMDISK_BOOT_IMAGE_NAME),kernel,$(notdir $(1)))) \ + $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \ $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \ $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1 - $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,$(DEBUG_RAMDISK_BOOT_IMAGE_NAME))) + $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug)) endef # Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img @@ -2412,35 +2424,41 @@ INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OU $(ALL_GENERATED_SOURCES) \ $(ALL_DEFAULT_INSTALLED_MODULES)) +# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk. +INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT) +INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET) + +# Exclude recovery files in the default vendor ramdisk if including a standalone +# recovery ramdisk in vendor_boot. +ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) + ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) + INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT) + INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) + endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true +endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true + +INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT) +INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) + +# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created. INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json) $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK) -$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET) -$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL) - @echo Installed file list: $@ - mkdir -p $(dir $@) - rm -f $@ - mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) # The dir might not be created if no modules are installed here. - $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) > $(@:.txt=.json) +$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS) +$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL) + @echo "Installed file list: $@" + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) + $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@ INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT) -# Exclude recovery files in the default vendor ramdisk if including a standalone -# recovery ramdisk in vendor_boot. -ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) -ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) -$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) -$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) -endif -endif - -# The vendor debug ramdisk combines vendor ramdisk and debug ramdisk. -$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) -$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS) - mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ +$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@ INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET) @@ -2479,53 +2497,62 @@ $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_T endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE -# ----------------------------------------------------------------- -# The test harness ramdisk, which is based off debug_ramdisk, plus a -# few additional test-harness-specific properties in adb_debug.prop. -INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img - # Appends a few test harness specific properties into the adb_debug.prop. -TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1 ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1 -# $(1): a list of key=value pairs for additional property assignments -# $(2): the target .prop file to append the properties from $(1) -define append-test-harness-props - echo "#" >> $(2); \ - echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \ - echo "#" >> $(2); - $(foreach line,$(1), echo "$(line)" >> $(2);) -endef +INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES))) +INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop +$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) +ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET + $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@ +endif + $(hide) echo "" >> $@ + $(hide) echo "#" >> $@ + $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@ + $(hide) echo "#" >> $@ + $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \ + echo "$(line)" >> $@;) INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \ + $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \ $(ALL_GENERATED_SOURCES) \ $(ALL_DEFAULT_INSTALLED_MODULES)) -# The test harness ramdisk will rsync the files from the debug ramdisk, then appends some props. -$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET) -$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP) -$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS) - $(call pretty,"Target test harness ramdisk: $@") - rsync --chmod=u+w -a $(TARGET_DEBUG_RAMDISK_OUT)/ $(TARGET_TEST_HARNESS_RAMDISK_OUT) - $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET)) - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ +# The order is important here. The test harness ramdisk staging directory has to +# come last so that it can override the adb_debug.prop in the debug ramdisk +# staging directory. +INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT) +INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) + +ifdef BUILDING_DEBUG_BOOT_IMAGE + +# ----------------------------------------------------------------- +# The test harness ramdisk, which is based off debug_ramdisk, plus a +# few additional test-harness-specific properties in adb_debug.prop. +INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img + +$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS) +$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) + @echo "Target test harness ramdisk: $@" + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@ .PHONY: ramdisk_test_harness-nodeps ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) - echo "make $@: ignoring dependencies" - rsync --chmod=u+w -a $(TARGET_DEBUG_RAMDISK_OUT)/ $(TARGET_TEST_HARNESS_RAMDISK_OUT) - $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET)) - mkdir -p $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) + @echo "make $@: ignoring dependencies" + $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) + $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) # ----------------------------------------------------------------- # the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img # # Note: it's intentional to skip signing for boot-test-harness.img, because it # can only be used if the device is unlocked with verification error. -ifdef BUILDING_DEBUG_BOOT_IMAGE - ifneq ($(strip $(BOARD_KERNEL_BINARIES)),) INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \ $(PRODUCT_OUT)/$(k).img) @@ -2534,6 +2561,7 @@ else endif # Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img +$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS)) # If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader @@ -2553,8 +2581,7 @@ define build-boot-test-harness-target endef # Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img. -$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \ -$(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL) +$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL) $(call pretty,"Target boot test harness image: $@") $(call build-boot-test-harness-target,$@) @@ -2572,19 +2599,17 @@ ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) -# Exclude recovery files in the default vendor ramdisk if including a standalone -# recovery ramdisk in vendor_boot. -ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) -ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) -$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) -$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) -endif -endif +# The order is important here. The test harness ramdisk staging directory has to +# come last so that it can override the adb_debug.prop in the debug ramdisk +# staging directory. +INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT) +INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) -# The vendor test harness ramdisk combines vendor ramdisk and test harness ramdisk. -$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) +$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS) $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) - $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@ INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) @@ -2699,7 +2724,7 @@ $(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL) installed-file-list: $(INSTALLED_FILES_FILE) ifeq ($(HOST_OS),linux) -$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE)) +$(call dist-for-goals, sdk sdk_addon, $(INSTALLED_FILES_FILE)) endif systemimage_intermediates := \ @@ -3376,7 +3401,7 @@ $(INSTALLED_PVMFWIMAGE_TARGET): $(BUILT_PVMFWIMAGE_TARGET) $(AVBTOOL) $(BOARD_AV cp $(BUILT_PVMFWIMAGE_TARGET) $@ $(AVBTOOL) add_hash_footer \ --image $@ \ - --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \ + --partition_size $(BOARD_PVMFWIMAGE_PARTITION_SIZE) \ --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \ $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS) else @@ -4561,7 +4586,7 @@ endif # BOARD_PREBUILT_DTBOIMAGE ifeq ($(BOARD_USES_PVMFWIMAGE),true) $(hide) echo "has_pvmfw=true" >> $@ ifeq ($(BOARD_AVB_ENABLE),true) - $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@ + $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@ $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@ ifdef BOARD_AVB_PVMFW_KEY_PATH $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@ @@ -5181,7 +5206,10 @@ endif # BOARD_PREBUILT_DTBOIMAGE ifdef BOARD_PREBUILT_PVMFWIMAGE $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/ -endif # BOARD_PREBUILT_PVMFWIMAGE +else ifeq ($(BUILDING_PVMFW_IMAGE),true) + $(hide) mkdir -p $(zip_root)/IMAGES + $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/IMAGES/ +endif ifdef BOARD_PREBUILT_BOOTLOADER $(hide) mkdir -p $(zip_root)/IMAGES $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/ @@ -5832,6 +5860,8 @@ endif # ----------------------------------------------------------------- # The SDK +ifneq ($(filter sdk,$(MAKECMDGOALS)),) + # The SDK includes host-specific components, so it belongs under HOST_OUT. sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) @@ -5841,15 +5871,11 @@ sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) # darwin-x86 --> android-sdk_12345_mac-x86 # windows-x86 --> android-sdk_12345_windows # -sdk_name := android-sdk_$(FILE_NAME_TAG) -ifeq ($(HOST_OS),darwin) - INTERNAL_SDK_HOST_OS_NAME := mac -else - INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) -endif -ifneq ($(HOST_OS),windows) - INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH) +ifneq ($(HOST_OS),linux) + $(error Building the monolithic SDK is only supported on Linux) endif +sdk_name := android-sdk_$(FILE_NAME_TAG) +INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH) sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) sdk_dep_file := $(sdk_dir)/sdk_deps.mk @@ -5869,9 +5895,7 @@ endif atree_dir := development/build -sdk_atree_files := \ - $(atree_dir)/sdk.exclude.atree \ - $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree +sdk_atree_files := $(atree_dir)/sdk.exclude.atree # development/build/sdk-android-<abi>.atree is used to differentiate # between architecture models (e.g. ARMv5TE versus ARMv7) when copying @@ -5953,22 +5977,16 @@ $(INTERNAL_SDK_TARGET): $(deps) -o $(PRIVATE_DIR) && \ cp -f $(target_notice_file_txt) \ $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \ - cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ chmod -R ug+rwX $(PRIVATE_DIR) && \ cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \ ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) - -# Is a Windows SDK requested? If so, we need some definitions from here -# in order to find the Linux SDK used to create the Windows one. -MAIN_SDK_NAME := $(sdk_name) MAIN_SDK_DIR := $(sdk_dir) MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET) -ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),) -include $(TOPDIR)development/build/tools/windows_sdk.mk -endif + +endif # sdk in MAKECMDGOALS # ----------------------------------------------------------------- # Findbugs diff --git a/core/board_config.mk b/core/board_config.mk index 816b17632a..40b6b3fba9 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -84,6 +84,7 @@ _board_strip_readonly_list += BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE _board_strip_readonly_list += BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE _board_strip_readonly_list += BOARD_ODM_DLKMIMAGE_PARTITION_SIZE _board_strip_readonly_list += BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE +_board_strip_readonly_list += BOARD_PVMFWIMAGE_PARTITION_SIZE # Logical partitions related variables. _board_strip_readonly_list += BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE @@ -410,12 +411,6 @@ else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),true) endif .KATI_READONLY := BUILDING_BOOT_IMAGE -DEBUG_RAMDISK_BOOT_IMAGE_NAME := boot-debug -ifneq ($(PRODUCT_DEBUG_RAMDISK_BOOT_IMAGE_NAME),) - DEBUG_RAMDISK_BOOT_IMAGE_NAME := $(PRODUCT_DEBUG_RAMDISK_BOOT_IMAGE_NAME) -endif -.KATI_READONLY := DEBUG_RAMDISK_BOOT_IMAGE_NAME - # Are we building a recovery image BUILDING_RECOVERY_IMAGE := ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),) diff --git a/core/config.mk b/core/config.mk index 91659258e5..8f47ab58b7 100644 --- a/core/config.mk +++ b/core/config.mk @@ -252,6 +252,10 @@ endef # Initialize SOONG_CONFIG_NAMESPACES so that it isn't recursive. SOONG_CONFIG_NAMESPACES := +# TODO(asmundak): remove add_soong_config_namespace, add_soong_config_var, +# and add_soong_config_var_value once all their usages are replaced with +# soong_config_set/soong_config_append. + # The add_soong_config_namespace function adds a namespace and initializes it # to be empty. # $1 is the namespace. @@ -282,6 +286,32 @@ $(eval $2 := $3) \ $(call add_soong_config_var,$1,$2) endef +# Soong config namespace variables manipulation. +# +# internal utility to define a namespace and a variable in it. +define soong_config_define_internal +$(if $(filter $1,$(SOONG_CONFIG_NAMESPACES)),,$(eval SOONG_CONFIG_NAMESPACES:=$(SOONG_CONFIG_NAMESPACES) $1)) \ +$(if $(filter $2,$(SOONG_CONFIG_$(strip $1))),,$(eval SOONG_CONFIG_$(strip $1):=$(SOONG_CONFIG_$(strip $1)) $2)) +endef + +# soong_config_set defines the variable in the given Soong config namespace +# and sets its value. If the namespace does not exist, it will be defined. +# $1 is the namespace. $2 is the variable name. $3 is the variable value. +# Ex: $(call soong_config_set,acme,COOL_FEATURE,true) +define soong_config_set +$(call soong_config_define_internal,$1,$2) \ +$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$3) +endef + +# soong_config_append appends to the value of the variable in the given Soong +# config namespace. If the varabile does not exist, it will be defined. If the +# namespace does not exist, it will be defined. +# $1 is the namespace, $2 is the variable name, $3 is the value +define soong_config_append +$(call soong_config_define_internal,$1,$2) \ +$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(SOONG_CONFIG_$(strip $1)_$(strip $2)) $3) +endef + # Set the extensions used for various packages COMMON_PACKAGE_SUFFIX := .zip COMMON_JAVA_PACKAGE_SUFFIX := .jar diff --git a/core/main.mk b/core/main.mk index e3aa996803..18994ce57c 100644 --- a/core/main.mk +++ b/core/main.mk @@ -359,7 +359,7 @@ endif is_sdk_build := -ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),) +ifneq ($(filter sdk sdk_addon,$(MAKECMDGOALS)),) is_sdk_build := true endif @@ -534,7 +534,12 @@ FULL_BUILD := true # Include all of the makefiles in the system # -subdir_makefiles := $(SOONG_ANDROID_MK) $(file <$(OUT_DIR)/.module_paths/Android.mk.list) $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT).mk +subdir_makefiles := $(SOONG_ANDROID_MK) +# Android.mk files are only used on Linux builds, Mac only supports Android.bp +ifeq ($(HOST_OS),linux) + subdir_makefiles += $(file <$(OUT_DIR)/.module_paths/Android.mk.list) +endif +subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT).mk subdir_makefiles_total := $(words int $(subdir_makefiles) post finish) .KATI_READONLY := subdir_makefiles_total @@ -1310,7 +1315,11 @@ $(if $(strip $(1)), \ ) endef -ifdef FULL_BUILD +ifeq ($(HOST_OS),darwin) + # Target builds are not supported on Mac + product_target_FILES := + product_host_FILES := $(call host-installed-files,$(INTERNAL_PRODUCT)) +else ifdef FULL_BUILD ifneq (true,$(ALLOW_MISSING_DEPENDENCIES)) # Check to ensure that all modules in PRODUCT_PACKAGES exist (opt in per product) ifeq (true,$(PRODUCT_ENFORCE_PACKAGES_EXIST)) @@ -1466,7 +1475,9 @@ endif # contains everything that's built during the current make, but it also further # extends ALL_DEFAULT_INSTALLED_MODULES. ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install) -include $(BUILD_SYSTEM)/Makefile +ifeq ($(HOST_OS),linux) + include $(BUILD_SYSTEM)/Makefile +endif modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES)) ALL_DEFAULT_INSTALLED_MODULES := @@ -1687,7 +1698,11 @@ ifeq ($(SOONG_COLLECT_JAVA_DEPS), true) endif .PHONY: apps_only -ifneq ($(TARGET_BUILD_APPS),) +ifeq ($(HOST_OS),darwin) + # Mac only supports building host modules + droid_targets: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) dist_files + +else ifneq ($(TARGET_BUILD_APPS),) # If this build is just for apps, only build apps and not the full system by default. unbundled_build_modules := @@ -1914,11 +1929,11 @@ endif # TARGET_BUILD_UNBUNDLED == TARGET_BUILD_UNBUNDLED_IMAGE .PHONY: docs docs: $(ALL_DOCS) -.PHONY: sdk win_sdk winsdk-tools sdk_addon +.PHONY: sdk sdk_addon ifeq ($(HOST_OS),linux) ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET) sdk: $(ALL_SDK_TARGETS) -$(call dist-for-goals,sdk win_sdk, \ +$(call dist-for-goals,sdk, \ $(ALL_SDK_TARGETS) \ $(SYMBOLS_ZIP) \ $(COVERAGE_ZIP) \ diff --git a/core/ninja_config.mk b/core/ninja_config.mk index 2e1bd6915f..2157c9ea4a 100644 --- a/core/ninja_config.mk +++ b/core/ninja_config.mk @@ -38,15 +38,19 @@ PARSE_TIME_MAKE_GOALS := \ test-art% \ user \ userdataimage \ - userdebug \ - win_sdk \ - winsdk-tools + userdebug include $(wildcard vendor/*/build/ninja_config.mk) # Any Android goals that need to be built. ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS),\ $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS))) +# Temporary compatibility support until the build server configs are updated +ANDROID_GOALS := $(patsubst win_sdk,sdk,$(ANDROID_GOALS)) +ifneq ($(HOST_OS),linux) + ANDROID_GOALS := $(filter-out sdk,$(ANDROID_GOALS)) + ANDROID_GOALS := $(patsubst sdk_repo,sdk-repo-build-tools sdk-repo-platform-tools,$(ANDROID_GOALS)) +endif # Goals we need to pass to Ninja. NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS)) ifndef NINJA_GOALS diff --git a/core/product.mk b/core/product.mk index db7e2a8c92..1b3c9f5b23 100644 --- a/core/product.mk +++ b/core/product.mk @@ -279,9 +279,6 @@ _product_single_value_vars += \ PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION \ PRODUCT_USES_DEFAULT_ART_CONFIG \ -# The file name for the boot image with a debug ramdisk. -_product_single_value_vars += PRODUCT_DEBUG_RAMDISK_BOOT_IMAGE_NAME - _product_single_value_vars += PRODUCT_SYSTEM_SERVER_COMPILER_FILTER # Per-module sanitizer configs _product_list_vars += PRODUCT_SANITIZER_MODULE_CONFIGS diff --git a/core/product_config.mk b/core/product_config.mk index 200c3ab6b2..33b15d3825 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -110,6 +110,13 @@ define is-board-platform-in-list2 $(filter $(1),$(TARGET_BOARD_PLATFORM)) endef +# Return empty unless the board is QCOM +define is-vendor-board-qcom +$(if $(strip $(TARGET_BOARD_PLATFORM) $(QCOM_BOARD_PLATFORMS)),\ + $(filter $(TARGET_BOARD_PLATFORM),$(QCOM_BOARD_PLATFORMS)),\ + $(error both TARGET_BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM) and QCOM_BOARD_PLATFORMS=$(QCOM_BOARD_PLATFORMS))) +endef + # --------------------------------------------------------------- # Check for obsolete PRODUCT- and APP- goals ifeq ($(CALLED_FROM_SETUP),true) diff --git a/core/product_config.rbc b/core/product_config.rbc index 5219751e34..bcb031f5d6 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -293,6 +293,11 @@ def _add_soong_config_var_value(g, nsname, var, value): fail("no such namespace: " + nsname) ns[var] = value +def _abspath(path): + """Provided for compatibility, to be removed later.""" + return path + + def _addprefix(prefix, string_or_list): """Adds prefix and returns a list. @@ -598,6 +603,7 @@ _options = __get_options() rblf = struct( add_soong_config_namespace = _add_soong_config_namespace, add_soong_config_var_value = _add_soong_config_var_value, + abspath = _abspath, addprefix = _addprefix, addsuffix = _addsuffix, copy_files = _copy_files, diff --git a/envsetup.sh b/envsetup.sh index b5dc847853..4301d73f0c 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1459,7 +1459,7 @@ function refreshmod() { > $ANDROID_PRODUCT_OUT/module-info.json.build.log 2>&1 } -# Verifies that module-info.txt exists, creating it if it doesn't. +# Verifies that module-info.txt exists, returning nonzero if it doesn't. function verifymodinfo() { if [ ! "$ANDROID_PRODUCT_OUT" ]; then if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then @@ -1470,7 +1470,7 @@ function verifymodinfo() { if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then - echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2 + echo "Could not find module-info.json. Please run 'refreshmod' first." >&2 fi return 1 fi @@ -1589,6 +1589,10 @@ for output in module_info[module]['installed']: function installmod() { if [[ $# -eq 0 ]]; then echo "usage: installmod [adb install arguments] <module>" >&2 + echo "" >&2 + echo "Only flags to be passed after the \"install\" in adb install are supported," >&2 + echo "with the exception of -s. If -s is passed it will be placed before the \"install\"." >&2 + echo "-s must be the first flag passed if it exists." >&2 return 1 fi @@ -1603,9 +1607,18 @@ function installmod() { echo "Module '$1' does not produce a file ending with .apk (try 'refreshmod' if there have been build changes?)" >&2 return 1 fi + local serial_device="" + if [[ "$1" == "-s" ]]; then + if [[ $# -le 2 ]]; then + echo "-s requires an argument" >&2 + return 1 + fi + serial_device="-s $2" + shift 2 + fi local length=$(( $# - 1 )) - echo adb install ${@:1:$length} $_path - adb install ${@:1:$length} $_path + echo adb $serial_device install ${@:1:$length} $_path + adb $serial_device install ${@:1:$length} $_path } function _complete_android_module_names() { diff --git a/target/board/BoardConfigModuleCommon.mk b/target/board/BoardConfigModuleCommon.mk index 983247434e..24c01a58ef 100644 --- a/target/board/BoardConfigModuleCommon.mk +++ b/target/board/BoardConfigModuleCommon.mk @@ -4,7 +4,3 @@ # Required for all module devices. TARGET_USES_64_BIT_BINDER := true - -# Necessary to make modules able to use the VNDK via 'use_vendor: true' -# TODO(b/185769808): look into whether this is still used. -BOARD_VNDK_VERSION := current diff --git a/target/product/gsi/current.txt b/target/product/gsi/current.txt index 285c8c7c2f..399652cb81 100644 --- a/target/product/gsi/current.txt +++ b/target/product/gsi/current.txt @@ -75,6 +75,7 @@ VNDK-core: android.hardware.graphics.allocator@3.0.so VNDK-core: android.hardware.graphics.allocator@4.0.so VNDK-core: android.hardware.graphics.bufferqueue@1.0.so VNDK-core: android.hardware.graphics.bufferqueue@2.0.so +VNDK-core: android.hardware.health-V1-ndk.so VNDK-core: android.hardware.health.storage-V1-ndk.so VNDK-core: android.hardware.health.storage-V1-ndk_platform.so VNDK-core: android.hardware.identity-V3-ndk.so diff --git a/target/product/gsi_release.mk b/target/product/gsi_release.mk index d0a98c0614..94917f5757 100644 --- a/target/product/gsi_release.mk +++ b/target/product/gsi_release.mk @@ -67,6 +67,8 @@ PRODUCT_EXTRA_VNDK_VERSIONS := 28 29 30 # Do not build non-GSI partition images. PRODUCT_BUILD_CACHE_IMAGE := false +PRODUCT_BUILD_DEBUG_BOOT_IMAGE := false +PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE := false PRODUCT_BUILD_USERDATA_IMAGE := false PRODUCT_BUILD_VENDOR_IMAGE := false PRODUCT_BUILD_SUPER_PARTITION := false @@ -79,7 +81,3 @@ MODULE_BUILD_FROM_SOURCE := true # Additional settings used in all GSI builds PRODUCT_PRODUCT_PROPERTIES += \ ro.crypto.metadata_init_delete_all_keys.enabled=false \ - -# Renames boot-debug-*.img to boot-with-debug-ramdisk-*.img to avoid confusion -# with GKI boot images. -PRODUCT_DEBUG_RAMDISK_BOOT_IMAGE_NAME := boot-with-debug-ramdisk diff --git a/target/product/sdk_phone_arm64.mk b/target/product/sdk_phone_arm64.mk index 0831b54a2b..4203d45c5e 100644 --- a/target/product/sdk_phone_arm64.mk +++ b/target/product/sdk_phone_arm64.mk @@ -50,10 +50,6 @@ $(call inherit-product-if-exists, device/generic/goldfish/arm64-vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/emulator_arm64/device.mk) -# Define the host tools and libs that are parts of the SDK. -$(call inherit-product, sdk/build/product_sdk.mk) -$(call inherit-product, development/build/product_sdk.mk) - # keep this apk for sdk targets for now PRODUCT_PACKAGES += \ EmulatorSmokeTests diff --git a/target/product/sdk_phone_armv7.mk b/target/product/sdk_phone_armv7.mk index f64998043a..6c88b44fd0 100644 --- a/target/product/sdk_phone_armv7.mk +++ b/target/product/sdk_phone_armv7.mk @@ -49,10 +49,6 @@ $(call inherit-product-if-exists, device/generic/goldfish/arm32-vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/emulator_arm/device.mk) -# Define the host tools and libs that are parts of the SDK. -$(call inherit-product, sdk/build/product_sdk.mk) -$(call inherit-product, development/build/product_sdk.mk) - # keep this apk for sdk targets for now PRODUCT_PACKAGES += \ EmulatorSmokeTests diff --git a/target/product/sdk_phone_x86.mk b/target/product/sdk_phone_x86.mk index 0e1bca4cfd..a324e5f023 100644 --- a/target/product/sdk_phone_x86.mk +++ b/target/product/sdk_phone_x86.mk @@ -49,10 +49,6 @@ $(call inherit-product-if-exists, device/generic/goldfish/x86-vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/emulator_x86/device.mk) -# Define the host tools and libs that are parts of the SDK. -$(call inherit-product-if-exists, sdk/build/product_sdk.mk) -$(call inherit-product-if-exists, development/build/product_sdk.mk) - # Overrides PRODUCT_BRAND := Android PRODUCT_NAME := sdk_phone_x86 diff --git a/target/product/sdk_phone_x86_64.mk b/target/product/sdk_phone_x86_64.mk index fffac047e8..ff9018d93f 100644 --- a/target/product/sdk_phone_x86_64.mk +++ b/target/product/sdk_phone_x86_64.mk @@ -50,10 +50,6 @@ $(call inherit-product-if-exists, device/generic/goldfish/x86_64-vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator_vendor.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/emulator_x86_64/device.mk) -# Define the host tools and libs that are parts of the SDK. -$(call inherit-product-if-exists, sdk/build/product_sdk.mk) -$(call inherit-product-if-exists, development/build/product_sdk.mk) - # Overrides PRODUCT_BRAND := Android PRODUCT_NAME := sdk_phone_x86_64 diff --git a/target/product/security/README b/target/product/security/README index 2b161bb0ee..4ad523605a 100644 --- a/target/product/security/README +++ b/target/product/security/README @@ -16,6 +16,7 @@ The following commands were used to generate the test key pairs: development/tools/make_key shared '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' development/tools/make_key media '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' development/tools/make_key cts_uicc_2021 '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' + development/tools/make_key fsverity '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' signing using the openssl commandline (for boot/system images) -------------------------------------------------------------- diff --git a/target/product/security/fsverity.pk8 b/target/product/security/fsverity.pk8 Binary files differnew file mode 100644 index 0000000000..5bb69dc50a --- /dev/null +++ b/target/product/security/fsverity.pk8 diff --git a/target/product/security/fsverity.x509.pem b/target/product/security/fsverity.x509.pem new file mode 100644 index 0000000000..b29c711272 --- /dev/null +++ b/target/product/security/fsverity.x509.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIECzCCAvOgAwIBAgIUDkPsN3C2kwiPnOnNZiHrK5S6oqowDQYJKoZIhvcNAQEL +BQAwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH +DA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRy +b2lkMRAwDgYDVQQDDAdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFu +ZHJvaWQuY29tMB4XDTIxMTAxMjA0MzUyMFoXDTQ5MDIyNzA0MzUyMFowgZQxCzAJ +BgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFp +biBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRyb2lkMRAwDgYD +VQQDDAdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29t +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1N8ro0RTY2Cl91daJvjo +tDLjHrwrzSAQaVpEXGddPJYs0m8ej3Oh7Hbo4+ju36CIjgH9xDgpOb9LeTUMSXLF +9Rlkdhz4VJlvaQuYz10FoqkvQo2/IsD2pAq3EktOHexfXCG8fhdCaVkayAuKX5ou ++RchZWCPwVhBx6fbpZeGhkFg6f7CwPSMEJ5DNtvHUieny8OwIbml0NILQjavP4nU +GGJxkyKgodUYCdnOSE7FCUv875Op9e0ryTPvUZhKHPoRMe5enEgfq/WXVdqLhifF +k6gYelcfq1bFRpwBm5KntX1b39V52vYUqXM8gD8Wy5RNo+aF0msJ6aBVcYeQsMlY +4QIDAQABo1MwUTAdBgNVHQ4EFgQURbNJabjEzJ2CZzqIrX/ppnDM9l4wHwYDVR0j +BBgwFoAURbNJabjEzJ2CZzqIrX/ppnDM9l4wDwYDVR0TAQH/BAUwAwEB/zANBgkq +hkiG9w0BAQsFAAOCAQEAl3eEb9xzlwAG31WKorYzflvFLX+LSuVMN3FEcZBcCXsW ++5QPfyvbJ2AgBzJmuH4XeGH0PebgLQN3PA4p9M0ZgXcHf4KBrSOMfpwUsFiTiD+z +9KJxr4MTyXyFxO3rVlVCg/za0V8om2cRWsOb2TPRu8qeUSIT4yIj/pOXmz66b4xL +5fKCuI7khRADCRnwyhPD9/f2/udB6qYx2MvDRchHMLqLvCzHJPS4gjhDTJJSo/st +/GKqHWspHl5IbpRNlQci1ncc1RLub5gxPwlkIcNlOcziD+eYWeSn5B7v+5uIqxdP +VY+WltSg4FEEzKFMjzfNpk1Uz+J6h2bi3VS0WZXdXQ== +-----END CERTIFICATE----- diff --git a/target/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk b/target/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk index bc81b339a5..de1f07d8cb 100644 --- a/target/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk +++ b/target/product/virtual_ab_ota/launch_with_vendor_ramdisk.mk @@ -24,3 +24,4 @@ PRODUCT_VENDOR_PROPERTIES += ro.virtual_ab.enabled=true PRODUCT_PACKAGES += \ linker.vendor_ramdisk \ e2fsck.vendor_ramdisk \ + fsck.f2fs.vendor_ramdisk \ diff --git a/tools/canoninja/README.md b/tools/canoninja/README.md new file mode 100644 index 0000000000..506acf76d1 --- /dev/null +++ b/tools/canoninja/README.md @@ -0,0 +1,151 @@ +# Ninja File Canonicalizer + +Suppose we have a tool that generates a Ninja file from some other description (think Kati and makefiles), and during +the testing we discovered a regression. Furthermore, suppose that the generated Ninja file is large (think millions of +lines). And, the new Ninja file has build statements and rules in a slightly different order. As the tool generates the +rule names, the real differences in the output of the `diff` command are drowned in noise. Enter Canoninja. + +Canoninja renames each Ninja rule to the hash of its contents. After that, we can just sort the build statements, and a +simple `comm` command immediately reveal the essential difference between the files. + +## Example + +Consider the following makefile + +```makefile +second := +first: foo +foo: + @echo foo +second: bar +bar: + @echo bar +``` + +Depending on Kati version converting it to Ninja file will yield either: + +``` +$ cat /tmp/1.ninja +# Generated by kati 06f2569b2d16628608c000a76e3d495a5a5528cb + +pool local_pool + depth = 72 + +build _kati_always_build_: phony + +build first: phony foo +rule rule0 + description = build $out + command = /bin/sh -c "echo foo" +build foo: rule0 +build second: phony bar +rule rule1 + description = build $out + command = /bin/sh -c "echo bar" +build bar: rule1 + +default first +``` + +or + +``` +$ cat 2.ninja +# Generated by kati 371194da71b3e191fea6f2ccceb7b061bd0de310 + +pool local_pool + depth = 72 + +build _kati_always_build_: phony + +build second: phony bar +rule rule0 + description = build $out + command = /bin/sh -c "echo bar" +build bar: rule0 +build first: phony foo +rule rule1 + description = build $out + command = /bin/sh -c "echo foo" +build foo: rule1 + +default first +``` + +This is a quirk in Kati, see https://github.com/google/kati/issues/238 + +Trying to find out the difference between the targets even after sorting them isn't too helpful: + +``` +diff <(grep '^build' /tmp/1.ninja|sort) <(grep '^build' /tmp/2.ninja | sort) +1c1 +< build bar: rule1 +--- +> build bar: rule0 +3c3 +< build foo: rule0 +--- +> build foo: rule1 +``` + +However, running these files through `canoninja` yields + +``` +$ canoninja /tmp/1.ninja +# Generated by kati 06f2569b2d16628608c000a76e3d495a5a5528cb + +pool local_pool + depth = 72 + +build _kati_always_build_: phony + +build first: phony foo +rule R2f9981d3c152fc255370dc67028244f7bed72a03 + description = build $out + command = /bin/sh -c "echo foo" +build foo: R2f9981d3c152fc255370dc67028244f7bed72a03 +build second: phony bar +rule R62640f3f9095cf2da5b9d9e2a82f746cc710c94c + description = build $out + command = /bin/sh -c "echo bar" +build bar: R62640f3f9095cf2da5b9d9e2a82f746cc710c94c + +default first +``` + +and + +``` +~/go/bin/canoninja /tmp/2.ninja +# Generated by kati 371194da71b3e191fea6f2ccceb7b061bd0de310 + +pool local_pool + depth = 72 + +build _kati_always_build_: phony + +build second: phony bar +rule R62640f3f9095cf2da5b9d9e2a82f746cc710c94c + description = build $out + command = /bin/sh -c "echo bar" +build bar: R62640f3f9095cf2da5b9d9e2a82f746cc710c94c +build first: phony foo +rule R2f9981d3c152fc255370dc67028244f7bed72a03 + description = build $out + command = /bin/sh -c "echo foo" +build foo: R2f9981d3c152fc255370dc67028244f7bed72a03 + +default first +``` + +and when we extract only build statements and sort them, we see that both Ninja files define the same graph: + +```shell +$ diff <(~/go/bin/canoninja /tmp/1.ninja | grep '^build' | sort) \ + <(~/go/bin/canoninja /tmp/2.ninja | grep '^build' | sort) +``` + +# Todo + +* Optionally output only the build statements, optionally sorted +* Handle continuation lines correctly diff --git a/tools/canoninja/canoninja.go b/tools/canoninja/canoninja.go new file mode 100644 index 0000000000..681a69438c --- /dev/null +++ b/tools/canoninja/canoninja.go @@ -0,0 +1,130 @@ +package canoninja + +import ( + "bytes" + "crypto/sha1" + "encoding/hex" + "fmt" + "io" +) + +var ( + rulePrefix = []byte("rule ") + buildPrefix = []byte("build ") + phonyRule = []byte("phony") +) + +func Generate(path string, buffer []byte, sink io.Writer) error { + // Break file into lines + from := 0 + var lines [][]byte + for from < len(buffer) { + line := getLine(buffer[from:]) + lines = append(lines, line) + from += len(line) + } + + // FOr each rule, calculate and remember its digest + ruleDigest := make(map[string]string) + for i := 0; i < len(lines); { + if bytes.HasPrefix(lines[i], rulePrefix) { + // Find ruleName + rn := ruleName(lines[i]) + if len(rn) == 0 { + return fmt.Errorf("%s:%d: rule name is missing or on the next line", path, i+1) + } + sRuleName := string(rn) + if _, ok := ruleDigest[sRuleName]; ok { + return fmt.Errorf("%s:%d: the rule %s has been already defined", path, i+1, sRuleName) + } + // Calculate rule text digest as a digests of line digests. + var digests []byte + doDigest := func(b []byte) { + h := sha1.New() + h.Write(b) + digests = h.Sum(digests) + + } + // For the first line, digest everything after rule's name + doDigest(lines[i][cap(lines[i])+len(rn)-cap(rn):]) + for i++; i < len(lines) && lines[i][0] == ' '; i++ { + doDigest(lines[i]) + } + h := sha1.New() + h.Write(digests) + ruleDigest[sRuleName] = "R" + hex.EncodeToString(h.Sum(nil)) + + } else { + i++ + } + } + + // Rewrite rule names. + for i, line := range lines { + if bytes.HasPrefix(line, buildPrefix) { + brn := getBuildRuleName(line) + if bytes.Equal(brn, phonyRule) { + sink.Write(line) + continue + } + if len(brn) == 0 { + return fmt.Errorf("%s:%d: build statement lacks rule name", path, i+1) + } + sink.Write(line[0 : cap(line)-cap(brn)]) + if digest, ok := ruleDigest[string(brn)]; ok { + sink.Write([]byte(digest)) + } else { + return fmt.Errorf("%s:%d: no rule for this build target", path, i+1) + } + sink.Write(line[cap(line)+len(brn)-cap(brn):]) + } else if bytes.HasPrefix(line, rulePrefix) { + rn := ruleName(line) + // Write everything before it + sink.Write(line[0 : cap(line)-cap(rn)]) + sink.Write([]byte(ruleDigest[string(rn)])) + sink.Write(line[cap(line)+len(rn)-cap(rn):]) + } else { + //goland:noinspection GoUnhandledErrorResult + sink.Write(line) + } + } + return nil +} + +func getLine(b []byte) []byte { + if n := bytes.IndexByte(b, '\n'); n >= 0 { + return b[:n+1] + } + return b +} + +// Returns build statement's rule name +func getBuildRuleName(line []byte) []byte { + n := bytes.IndexByte(line, ':') + if n <= 0 { + return nil + } + ruleName := line[n+1:] + if ruleName[0] == ' ' { + ruleName = bytes.TrimLeft(ruleName, " ") + } + if n := bytes.IndexAny(ruleName, " \t\r\n"); n >= 0 { + ruleName = ruleName[0:n] + } + return ruleName +} + +// Returns rule statement's rule name +func ruleName(lineAfterRule []byte) []byte { + ruleName := lineAfterRule[len(rulePrefix):] + if len(ruleName) == 0 { + return ruleName + } + if ruleName[0] == ' ' { + ruleName = bytes.TrimLeft(ruleName, " ") + } + if n := bytes.IndexAny(ruleName, " \t\r\n"); n >= 0 { + ruleName = ruleName[0:n] + } + return ruleName +} diff --git a/tools/canoninja/canoninja_test.go b/tools/canoninja/canoninja_test.go new file mode 100644 index 0000000000..3c45f8cf4b --- /dev/null +++ b/tools/canoninja/canoninja_test.go @@ -0,0 +1,47 @@ +package canoninja + +import ( + "bytes" + "testing" +) + +func TestGenerate(t *testing.T) { + tests := []struct { + name string + in []byte + wantSink string + wantErr bool + }{ + { + name: "1", + in: []byte(` +rule rule1 + abcd +rule rule2 + abcd +build x: rule1 +`), + wantSink: ` +rule R9c97aba7f61994be6862f5ea9a62d26130c7f48b + abcd +rule R9c97aba7f61994be6862f5ea9a62d26130c7f48b + abcd +build x: R9c97aba7f61994be6862f5ea9a62d26130c7f48b +`, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + sink := &bytes.Buffer{} + err := Generate("<file>", tt.in, sink) + if (err != nil) != tt.wantErr { + t.Errorf("Generate() error = %v, wantErr %v", err, tt.wantErr) + return + } + if gotSink := sink.String(); gotSink != tt.wantSink { + t.Errorf("Generate() gotSink = %v, want %v", gotSink, tt.wantSink) + } + }) + } +} diff --git a/tools/canoninja/cmd/canoninja.go b/tools/canoninja/cmd/canoninja.go new file mode 100644 index 0000000000..71802efa6a --- /dev/null +++ b/tools/canoninja/cmd/canoninja.go @@ -0,0 +1,36 @@ +package main + +/* + Canoninja reads a Ninja file and changes the rule names to be the digest of the rule contents. + Feed it to a filter that extracts only build statements, sort them, and you will have a crude + but effective tool to find small differences between two Ninja files. +*/ + +import ( + "canoninja" + "flag" + "fmt" + "os" +) + +func main() { + flag.Parse() + files := flag.Args() + if len(files) == 0 { + files = []string{"/dev/stdin"} + } + rc := 0 + for _, f := range files { + if buffer, err := os.ReadFile(f); err == nil { + err = canoninja.Generate(f, buffer, os.Stdout) + if err != nil { + fmt.Fprintln(os.Stderr, err) + rc = 1 + } + } else { + fmt.Fprintf(os.Stderr, "%s: %s\n", f, err) + rc = 1 + } + } + os.Exit(rc) +} diff --git a/tools/canoninja/go.mod b/tools/canoninja/go.mod new file mode 100644 index 0000000000..c5a924e7c3 --- /dev/null +++ b/tools/canoninja/go.mod @@ -0,0 +1 @@ +module canoninja diff --git a/tools/rbcrun/cmd/rbcrun.go b/tools/rbcrun/cmd/rbcrun.go index 784856259b..4db6a0bf38 100644 --- a/tools/rbcrun/cmd/rbcrun.go +++ b/tools/rbcrun/cmd/rbcrun.go @@ -93,6 +93,6 @@ func main() { } func quit(format string, s ...interface{}) { - fmt.Fprintln(os.Stderr, format, s) + fmt.Fprintf(os.Stderr, format, s...) os.Exit(2) } diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index d749c9e767..38104affa4 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -330,10 +330,6 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config): build_command.extend(["-C", fs_config]) if "selinux_fc" in prop_dict: build_command.extend(["-c", prop_dict["selinux_fc"]]) - if "timestamp" in prop_dict: - build_command.extend(["-T", str(prop_dict["timestamp"])]) - if "uuid" in prop_dict: - build_command.extend(["-U", prop_dict["uuid"]]) compressor = None if "erofs_default_compressor" in prop_dict: compressor = prop_dict["erofs_default_compressor"] @@ -341,6 +337,16 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config): compressor = prop_dict["erofs_compressor"] if compressor: build_command.extend(["-z", compressor]) + if "timestamp" in prop_dict: + build_command.extend(["-T", str(prop_dict["timestamp"])]) + if "uuid" in prop_dict: + build_command.extend(["-U", prop_dict["uuid"]]) + if "block_list" in prop_dict: + build_command.extend(["-B", prop_dict["block_list"]]) + if "erofs_pcluster_size" in prop_dict: + build_command.extend(["-P", prop_dict["erofs_pcluster_size"]]) + if "erofs_share_dup_blocks" in prop_dict: + build_command.extend(["-k", "4096"]) elif fs_type.startswith("squash"): build_command = ["mksquashfsimage.sh"] build_command.extend([in_dir, out_file]) @@ -615,6 +621,8 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): common_props = ( "extfs_sparse_flag", "erofs_default_compressor", + "erofs_pcluster_size", + "erofs_share_dup_blocks", "erofs_sparse_flag", "squashfs_sparse_flag", "system_f2fs_compress", @@ -634,252 +642,96 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): for p in common_props: copy_prop(p, p) - suffixed_props = ( - "erofs_compressor", + ro_mount_points = set([ + "odm", + "odm_dlkm", + "oem", + "product", + "system", + "system_ext", + "system_other", + "vendor", + "vendor_dlkm", + ]) + + # Tuple layout: (readonly, specific prop, general prop) + fmt_props = ( + # Generic first, then specific file type. + (False, "fs_type", "fs_type"), + (False, "{}_fs_type", "fs_type"), + + # Ordering for these doesn't matter. + (False, "{}_selinux_fc", "selinux_fc"), + (False, "{}_size", "partition_size"), + (True, "avb_{}_add_hashtree_footer_args", "avb_add_hashtree_footer_args"), + (True, "avb_{}_algorithm", "avb_algorithm"), + (True, "avb_{}_hashtree_enable", "avb_hashtree_enable"), + (True, "avb_{}_key_path", "avb_key_path"), + (True, "avb_{}_salt", "avb_salt"), + (True, "ext4_share_dup_blocks", "ext4_share_dup_blocks"), + (True, "{}_base_fs_file", "base_fs_file"), + (True, "{}_disable_sparse", "disable_sparse"), + (True, "{}_erofs_compressor", "erofs_compressor"), + (True, "{}_erofs_pcluster_size", "erofs_pcluster_size"), + (True, "{}_erofs_share_dup_blocks", "erofs_share_dup_blocks"), + (True, "{}_extfs_inode_count", "extfs_inode_count"), + (True, "{}_f2fs_compress", "f2fs_compress"), + (True, "{}_f2fs_sldc_flags", "f2fs_sldc_flags"), + (True, "{}_reserved_size", "partition_reserved_size"), + (True, "{}_squashfs_block_size", "squashfs_block_size"), + (True, "{}_squashfs_compressor", "squashfs_compressor"), + (True, "{}_squashfs_compressor_opt", "squashfs_compressor_opt"), + (True, "{}_squashfs_disable_4k_align", "squashfs_disable_4k_align"), + (True, "{}_verity_block_device", "verity_block_device"), ) - for p in suffixed_props: - copy_prop("{}_{}".format(mount_point, p), p) + # Translate prefixed properties into generic ones. + if mount_point == "data": + prefix = "userdata" + else: + prefix = mount_point + + for readonly, src_prop, dest_prop in fmt_props: + if readonly and mount_point not in ro_mount_points: + continue + + if src_prop == "fs_type": + # This property is legacy and only used on a few partitions. b/202600377 + allowed_partitions = set(["system", "system_other", "data", "oem"]) + if mount_point not in allowed_partitions: + continue + + if mount_point == "system_other": + # Propagate system properties to system_other. They'll get overridden + # after as needed. + copy_prop(src_prop.format("system"), dest_prop) + + copy_prop(src_prop.format(prefix), dest_prop) + + # Set prefixed properties that need a default value. + if mount_point in ro_mount_points: + prop = "{}_journal_size".format(prefix) + if not copy_prop(prop, "journal_size"): + d["journal_size"] = "0" + + prop = "{}_extfs_rsv_pct".format(prefix) + if not copy_prop(prop, "extfs_rsv_pct"): + d["extfs_rsv_pct"] = "0" + + # Copy partition-specific properties. d["mount_point"] = mount_point if mount_point == "system": - copy_prop("avb_system_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_system_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_system_key_path", "avb_key_path") - copy_prop("avb_system_algorithm", "avb_algorithm") - copy_prop("avb_system_salt", "avb_salt") - copy_prop("fs_type", "fs_type") - # Copy the generic system fs type first, override with specific one if - # available. - copy_prop("system_fs_type", "fs_type") copy_prop("system_headroom", "partition_headroom") - copy_prop("system_size", "partition_size") - if not copy_prop("system_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("system_verity_block_device", "verity_block_device") copy_prop("system_root_image", "system_root_image") copy_prop("root_dir", "root_dir") copy_prop("root_fs_config", "root_fs_config") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("system_f2fs_compress", "f2fs_compress") - copy_prop("system_f2fs_sldc_flags", "f2fs_sldc_flags") - copy_prop("system_squashfs_compressor", "squashfs_compressor") - copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("system_squashfs_block_size", "squashfs_block_size") - copy_prop("system_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("system_base_fs_file", "base_fs_file") - copy_prop("system_extfs_inode_count", "extfs_inode_count") - if not copy_prop("system_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("system_reserved_size", "partition_reserved_size") - copy_prop("system_selinux_fc", "selinux_fc") - copy_prop("system_disable_sparse", "disable_sparse") - elif mount_point == "system_other": - # We inherit the selinux policies of /system since we contain some of its - # files. - copy_prop("avb_system_other_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_system_other_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_system_other_key_path", "avb_key_path") - copy_prop("avb_system_other_algorithm", "avb_algorithm") - copy_prop("avb_system_other_salt", "avb_salt") - copy_prop("fs_type", "fs_type") - copy_prop("system_fs_type", "fs_type") - copy_prop("system_other_size", "partition_size") - if not copy_prop("system_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("system_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("system_f2fs_compress", "f2fs_compress") - copy_prop("system_f2fs_sldc_flags", "f2fs_sldc_flags") - copy_prop("system_squashfs_compressor", "squashfs_compressor") - copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("system_squashfs_block_size", "squashfs_block_size") - copy_prop("system_extfs_inode_count", "extfs_inode_count") - if not copy_prop("system_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("system_reserved_size", "partition_reserved_size") - copy_prop("system_selinux_fc", "selinux_fc") - copy_prop("system_disable_sparse", "disable_sparse") elif mount_point == "data": # Copy the generic fs type first, override with specific one if available. - copy_prop("fs_type", "fs_type") - copy_prop("userdata_fs_type", "fs_type") - copy_prop("userdata_size", "partition_size") copy_prop("flash_logical_block_size", "flash_logical_block_size") copy_prop("flash_erase_block_size", "flash_erase_block_size") - copy_prop("userdata_selinux_fc", "selinux_fc") copy_prop("needs_casefold", "needs_casefold") copy_prop("needs_projid", "needs_projid") copy_prop("needs_compress", "needs_compress") - elif mount_point == "cache": - copy_prop("cache_fs_type", "fs_type") - copy_prop("cache_size", "partition_size") - copy_prop("cache_selinux_fc", "selinux_fc") - elif mount_point == "vendor": - copy_prop("avb_vendor_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_vendor_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_vendor_key_path", "avb_key_path") - copy_prop("avb_vendor_algorithm", "avb_algorithm") - copy_prop("avb_vendor_salt", "avb_salt") - copy_prop("vendor_fs_type", "fs_type") - copy_prop("vendor_size", "partition_size") - if not copy_prop("vendor_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("vendor_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("vendor_f2fs_compress", "f2fs_compress") - copy_prop("vendor_f2fs_sldc_flags", "f2fs_sldc_flags") - copy_prop("vendor_squashfs_compressor", "squashfs_compressor") - copy_prop("vendor_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("vendor_squashfs_block_size", "squashfs_block_size") - copy_prop("vendor_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("vendor_base_fs_file", "base_fs_file") - copy_prop("vendor_extfs_inode_count", "extfs_inode_count") - if not copy_prop("vendor_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("vendor_reserved_size", "partition_reserved_size") - copy_prop("vendor_selinux_fc", "selinux_fc") - copy_prop("vendor_disable_sparse", "disable_sparse") - elif mount_point == "product": - copy_prop("avb_product_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_product_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_product_key_path", "avb_key_path") - copy_prop("avb_product_algorithm", "avb_algorithm") - copy_prop("avb_product_salt", "avb_salt") - copy_prop("product_fs_type", "fs_type") - copy_prop("product_size", "partition_size") - if not copy_prop("product_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("product_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("product_f2fs_compress", "f2fs_compress") - copy_prop("product_f2fs_sldc_flags", "f2fs_sldc_flags") - copy_prop("product_squashfs_compressor", "squashfs_compressor") - copy_prop("product_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("product_squashfs_block_size", "squashfs_block_size") - copy_prop("product_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("product_base_fs_file", "base_fs_file") - copy_prop("product_extfs_inode_count", "extfs_inode_count") - if not copy_prop("product_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("product_reserved_size", "partition_reserved_size") - copy_prop("product_selinux_fc", "selinux_fc") - copy_prop("product_disable_sparse", "disable_sparse") - elif mount_point == "system_ext": - copy_prop("avb_system_ext_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_system_ext_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_system_ext_key_path", "avb_key_path") - copy_prop("avb_system_ext_algorithm", "avb_algorithm") - copy_prop("avb_system_ext_salt", "avb_salt") - copy_prop("system_ext_fs_type", "fs_type") - copy_prop("system_ext_size", "partition_size") - if not copy_prop("system_ext_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("system_ext_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("system_ext_f2fs_compress", "f2fs_compress") - copy_prop("system_ext_f2fs_sldc_flags", "f2fs_sldc_flags") - copy_prop("system_ext_squashfs_compressor", "squashfs_compressor") - copy_prop("system_ext_squashfs_compressor_opt", - "squashfs_compressor_opt") - copy_prop("system_ext_squashfs_block_size", "squashfs_block_size") - copy_prop("system_ext_squashfs_disable_4k_align", - "squashfs_disable_4k_align") - copy_prop("system_ext_base_fs_file", "base_fs_file") - copy_prop("system_ext_extfs_inode_count", "extfs_inode_count") - if not copy_prop("system_ext_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("system_ext_reserved_size", "partition_reserved_size") - copy_prop("system_ext_selinux_fc", "selinux_fc") - copy_prop("system_ext_disable_sparse", "disable_sparse") - elif mount_point == "odm": - copy_prop("avb_odm_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_odm_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_odm_key_path", "avb_key_path") - copy_prop("avb_odm_algorithm", "avb_algorithm") - copy_prop("avb_odm_salt", "avb_salt") - copy_prop("odm_fs_type", "fs_type") - copy_prop("odm_size", "partition_size") - if not copy_prop("odm_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("odm_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("odm_squashfs_compressor", "squashfs_compressor") - copy_prop("odm_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("odm_squashfs_block_size", "squashfs_block_size") - copy_prop("odm_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("odm_base_fs_file", "base_fs_file") - copy_prop("odm_extfs_inode_count", "extfs_inode_count") - if not copy_prop("odm_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("odm_reserved_size", "partition_reserved_size") - copy_prop("odm_selinux_fc", "selinux_fc") - copy_prop("odm_disable_sparse", "disable_sparse") - elif mount_point == "vendor_dlkm": - copy_prop("avb_vendor_dlkm_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_vendor_dlkm_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_vendor_dlkm_key_path", "avb_key_path") - copy_prop("avb_vendor_dlkm_algorithm", "avb_algorithm") - copy_prop("avb_vendor_dlkm_salt", "avb_salt") - copy_prop("vendor_dlkm_fs_type", "fs_type") - copy_prop("vendor_dlkm_size", "partition_size") - copy_prop("vendor_dlkm_f2fs_compress", "f2fs_compress") - copy_prop("vendor_dlkm_f2fs_sldc_flags", "f2fs_sldc_flags") - if not copy_prop("vendor_dlkm_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("vendor_dlkm_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("vendor_dlkm_squashfs_compressor", "squashfs_compressor") - copy_prop("vendor_dlkm_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("vendor_dlkm_squashfs_block_size", "squashfs_block_size") - copy_prop("vendor_dlkm_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("vendor_dlkm_base_fs_file", "base_fs_file") - copy_prop("vendor_dlkm_extfs_inode_count", "extfs_inode_count") - if not copy_prop("vendor_dlkm_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("vendor_dlkm_reserved_size", "partition_reserved_size") - copy_prop("vendor_dlkm_selinux_fc", "selinux_fc") - copy_prop("vendor_dlkm_disable_sparse", "disable_sparse") - elif mount_point == "odm_dlkm": - copy_prop("avb_odm_dlkm_hashtree_enable", "avb_hashtree_enable") - copy_prop("avb_odm_dlkm_add_hashtree_footer_args", - "avb_add_hashtree_footer_args") - copy_prop("avb_odm_dlkm_key_path", "avb_key_path") - copy_prop("avb_odm_dlkm_algorithm", "avb_algorithm") - copy_prop("avb_odm_dlkm_salt", "avb_salt") - copy_prop("odm_dlkm_fs_type", "fs_type") - copy_prop("odm_dlkm_size", "partition_size") - if not copy_prop("odm_dlkm_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("odm_dlkm_verity_block_device", "verity_block_device") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - copy_prop("odm_dlkm_squashfs_compressor", "squashfs_compressor") - copy_prop("odm_dlkm_squashfs_compressor_opt", "squashfs_compressor_opt") - copy_prop("odm_dlkm_squashfs_block_size", "squashfs_block_size") - copy_prop("odm_dlkm_squashfs_disable_4k_align", "squashfs_disable_4k_align") - copy_prop("odm_dlkm_base_fs_file", "base_fs_file") - copy_prop("odm_dlkm_extfs_inode_count", "extfs_inode_count") - if not copy_prop("odm_dlkm_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("odm_dlkm_reserved_size", "partition_reserved_size") - copy_prop("odm_dlkm_selinux_fc", "selinux_fc") - copy_prop("odm_dlkm_disable_sparse", "disable_sparse") - elif mount_point == "oem": - copy_prop("fs_type", "fs_type") - copy_prop("oem_size", "partition_size") - if not copy_prop("oem_journal_size", "journal_size"): - d["journal_size"] = "0" - copy_prop("oem_extfs_inode_count", "extfs_inode_count") - copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks") - if not copy_prop("oem_extfs_rsv_pct", "extfs_rsv_pct"): - d["extfs_rsv_pct"] = "0" - copy_prop("oem_selinux_fc", "selinux_fc") d["partition_name"] = mount_point return d diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py index d219ed61c3..bd5d7d3c69 100755 --- a/tools/releasetools/sign_target_files_apks.py +++ b/tools/releasetools/sign_target_files_apks.py @@ -136,6 +136,11 @@ Usage: sign_target_files_apks [flags] input_target_files output_target_files --android_jar_path <path> Path to the android.jar to repack the apex file. + + --allow_gsi_debug_sepolicy + Allow the existence of the file 'userdebug_plat_sepolicy.cil' under + (/system/system_ext|/system_ext)/etc/selinux. + If not set, error out when the file exists. """ from __future__ import print_function @@ -191,6 +196,7 @@ OPTIONS.gki_signing_extra_args = None OPTIONS.android_jar_path = None OPTIONS.vendor_partitions = set() OPTIONS.vendor_otatools = None +OPTIONS.allow_gsi_debug_sepolicy = False AVB_FOOTER_ARGS_BY_PARTITION = { @@ -664,7 +670,7 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info, # Updates system_other.avbpubkey in /product/etc/. elif filename in ( "PRODUCT/etc/security/avb/system_other.avbpubkey", - "SYSTEM/product/etc/security/avb/system_other.avbpubkey"): + "SYSTEM/product/etc/security/avb/system_other.avbpubkey"): # Only update system_other's public key, if the corresponding signing # key is specified via --avb_system_other_key. signing_key = OPTIONS.avb_keys.get("system_other") @@ -677,9 +683,19 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info, # Should NOT sign boot-debug.img. elif filename in ( "BOOT/RAMDISK/force_debuggable", - "BOOT/RAMDISK/first_stage_ramdisk/force_debuggable"): + "BOOT/RAMDISK/first_stage_ramdisk/force_debuggable"): raise common.ExternalError("debuggable boot.img cannot be signed") + # Should NOT sign userdebug sepolicy file. + elif filename in ( + "SYSTEM_EXT/etc/selinux/userdebug_plat_sepolicy.cil", + "SYSTEM/system_ext/etc/selinux/userdebug_plat_sepolicy.cil"): + if not OPTIONS.allow_gsi_debug_sepolicy: + raise common.ExternalError("debug sepolicy shouldn't be included") + else: + # Copy it verbatim if we allow the file to exist. + common.ZipWriteStr(output_tf_zip, out_info, data) + # A non-APK file; copy it verbatim. else: common.ZipWriteStr(output_tf_zip, out_info, data) @@ -1356,6 +1372,8 @@ def main(argv): OPTIONS.vendor_otatools = a elif o == "--vendor_partitions": OPTIONS.vendor_partitions = set(a.split(",")) + elif o == "--allow_gsi_debug_sepolicy": + OPTIONS.allow_gsi_debug_sepolicy = True else: return False return True @@ -1408,6 +1426,7 @@ def main(argv): "gki_signing_extra_args=", "vendor_partitions=", "vendor_otatools=", + "allow_gsi_debug_sepolicy", ], extra_option_handler=option_handler) diff --git a/tools/warn/cpp_warn_patterns.py b/tools/warn/cpp_warn_patterns.py index b738086640..1e1aa43fd5 100644 --- a/tools/warn/cpp_warn_patterns.py +++ b/tools/warn/cpp_warn_patterns.py @@ -297,6 +297,7 @@ warn_patterns = [ [r".*: warning: declaration 'class .+' does not declare anything"]), medium('Initialization order will be different', [r".*: warning: '.+' will be initialized after", + r".*: warning: initializer order does not match the declaration order", r".*: warning: field .+ will be initialized after .+Wreorder"]), skip('skip, ....', [r".*: warning: '.+'"]), @@ -448,6 +449,7 @@ warn_patterns = [ [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]), medium('NULL used in arithmetic', [r".*: warning: NULL used in arithmetic", + r".*: warning: .* subtraction with a null pointer", r".*: warning: comparison between NULL and non-pointer"]), medium('Misspelled header guard', [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]), diff --git a/tools/warn/tidy_warn_patterns.py b/tools/warn/tidy_warn_patterns.py index 1297966b53..a5842ea125 100644 --- a/tools/warn/tidy_warn_patterns.py +++ b/tools/warn/tidy_warn_patterns.py @@ -81,6 +81,7 @@ def analyzer_group_check(check): warn_patterns = [ # pylint does not recognize g-inconsistent-quotes # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes + group_tidy_warn_pattern('altera'), group_tidy_warn_pattern('android'), simple_tidy_warn_pattern('abseil-string-find-startswith'), simple_tidy_warn_pattern('bugprone-argument-comment'), @@ -127,8 +128,9 @@ warn_patterns = [ simple_tidy_warn_pattern('cert-oop54-cpp'), group_tidy_warn_pattern('cert'), group_tidy_warn_pattern('clang-diagnostic'), + group_tidy_warn_pattern('concurrency'), group_tidy_warn_pattern('cppcoreguidelines'), - group_tidy_warn_pattern('llvm'), + group_tidy_warn_pattern('fuchsia'), simple_tidy_warn_pattern('google-default-arguments'), simple_tidy_warn_pattern('google-runtime-int'), simple_tidy_warn_pattern('google-runtime-operator'), @@ -152,8 +154,10 @@ warn_patterns = [ simple_tidy_warn_pattern('hicpp-noexcept-move'), simple_tidy_warn_pattern('hicpp-use-override'), group_tidy_warn_pattern('hicpp'), - group_tidy_warn_pattern('modernize'), + group_tidy_warn_pattern('llvm'), + group_tidy_warn_pattern('llvmlibc'), group_tidy_warn_pattern('misc'), + group_tidy_warn_pattern('modernize'), simple_tidy_warn_pattern('performance-faster-string-find'), simple_tidy_warn_pattern('performance-for-range-copy'), simple_tidy_warn_pattern('performance-implicit-cast-in-loop'), @@ -173,6 +177,7 @@ warn_patterns = [ group_tidy_warn_pattern('portability'), tidy_warn('TIMEOUT', [r".*: warning: clang-tidy aborted "]), + tidy_warn('Long Runs', [r".*: warning: clang-tidy used "]), # warnings from clang-tidy's clang-analyzer checks analyzer_high('clang-analyzer-core, null pointer', |