Merge "Revert "Re-land "Enable apex compression on all devices with updatable apex""
diff --git a/Changes.md b/Changes.md
index 0a6adc4..1ab005f 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,5 +1,49 @@
# Build System Changes for Android.mk Writers
+## Dexpreopt starts enforcing `<uses-library>` checks (for Java modules)
+
+In order to construct correct class loader context for dexpreopt, build system
+needs to know about the shared library dependencies of Java modules listed in
+the `<uses-library>` tags in the manifest. Since the build system does not have
+access to the manifest contents, that information must be present in the build
+files. In simple cases Soong is able to infer it from its knowledge of Java SDK
+libraries and the `libs` property in Android.bp, but in more complex cases it is
+necessary to add the missing information in Android.bp/Android.mk manually.
+
+To specify a list of libraries for a given modules, use:
+
+* Android.bp properties: `uses_libs`, `optional_uses_libs`
+* Android.mk variables: `LOCAL_USES_LIBRARIES`, `LOCAL_OPTIONAL_USES_LIBRARIES`
+
+If a library is in `libs`, it usually should *not* be added to the above
+properties, and Soong should be able to infer the `<uses-library>` tag. But
+sometimes a library also needs additional information in its
+Android.bp/Android.mk file (e.g. when it is a `java_library` rather than a
+`java_sdk_library`, or when the library name is different from its module name,
+or when the module is defined in Android.mk rather than Android.bp). In such
+cases it is possible to tell the build system that the library provides a
+`<uses-library>` with a given name (however, this is discouraged and will be
+deprecated in the future, and it is recommended to fix the underlying problem):
+
+* Android.bp property: `provides_uses_lib`
+* Android.mk variable: `LOCAL_PROVIDES_USES_LIBRARY`
+
+It is possible to disable the check on a per-module basis. When doing that it is
+also recommended to disable dexpreopt, as disabling a failed check will result
+in incorrect class loader context recorded in the .odex file, which will cause
+class loader context mismatch and dexopt at first boot.
+
+* Android.bp property: `enforce_uses_lib`
+* Android.mk variable: `LOCAL_ENFORCE_USES_LIBRARIES`
+
+Finally, it is possible to globally disable the check:
+
+* For a given product: `PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true`
+* On the command line: `RELAX_USES_LIBRARY_CHECK=true`
+
+The environment variable overrides the product variable, so it is possible to
+disable the check for a product, but quickly re-enable it for a local build.
+
## `LOCAL_REQUIRED_MODULES` requires listed modules to exist {#BUILD_BROKEN_MISSING_REQUIRED_MODULES}
Modules listed in `LOCAL_REQUIRED_MODULES`, `LOCAL_HOST_REQUIRED_MODULES` and
diff --git a/banchanHelp.sh b/banchanHelp.sh
new file mode 100755
index 0000000..eab22e4
--- /dev/null
+++ b/banchanHelp.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# locate some directories
+cd "$(dirname $0)"
+SCRIPT_DIR="${PWD}"
+cd ../..
+TOP="${PWD}"
+
+message='usage: banchan <module> ... [<product>|arm|x86|arm64|x86_64] [eng|userdebug|user]
+
+banchan selects individual APEX modules to be built by the Android build system.
+Like "tapas", "banchan" does not request the building of images for a device but
+instead configures it for an unbundled build of the given modules, suitable for
+installing on any api-compatible device.
+
+The difference from "tapas" is that "banchan" sets the appropriate products etc
+for building APEX modules rather than apps (APKs).
+
+The module names should match apex{} modules in Android.bp files, typically
+starting with "com.android.".
+
+The product argument should be a product name ending in "_<arch>", where <arch>
+is one of arm, x86, arm64, x86_64. It can also be just an arch, in which case
+the standard product for building modules with that architecture is used, i.e.
+module_<arch>.
+
+The usage of the other arguments matches that of the rest of the platform
+build system and can be found by running `m help`'
+
+echo "$message"
diff --git a/core/Makefile b/core/Makefile
index 99df084..40866ec 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -211,6 +211,62 @@
$(hide) mv $@.tmp $@
# -----------------------------------------------------------------
+# declare recovery ramdisk files
+ifeq ($(BUILDING_RECOVERY_IMAGE),true)
+INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
+endif
+
+# -----------------------------------------------------------------
+# Declare vendor ramdisk fragments
+INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
+
+ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
+ ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
+ $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
+ BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
+ endif
+ INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
+ VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
+ VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
+ BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
+ .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
+endif
+
+# Validation check and assign default --ramdisk_type.
+$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
+ $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
+ $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
+ $(error Must not specify KERNEL_MODULE_DIRS for prebuilt vendor ramdisk fragment "$(vendor_ramdisk_fragment)": $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS))) \
+ $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
+ $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
+ $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
+ $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
+ $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
+)
+
+# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
+$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
+ $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
+ $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
+ $(if $($(kmd_vrf)),$(error Kernel module directory "$(kmd)" belongs to multiple vendor ramdisk fragments: "$($(kmd_vrf))" "$(vendor_ramdisk_fragment)", each kernel module directory should belong to exactly one or none vendor ramdisk fragment)) \
+ $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
+ ) \
+)
+INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
+
+# Strip the list in case of any whitespace.
+INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
+ $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
+
+# Assign --ramdisk_name for each vendor ramdisk fragment.
+$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
+ $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
+ $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
+ $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
+ $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
+)
+
+# -----------------------------------------------------------------
# kernel modules
# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
@@ -315,14 +371,34 @@
@echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
endef
+# $(1): source options file
+# $(2): destination pathname
+# Returns a build rule that checks the syntax of and installs a kernel modules
+# options file. Strip and squeeze any extra space and blank lines.
+# For use via $(eval).
+define build-image-kernel-modules-options-file
+$(2): $(1)
+ @echo "libmodprobe options $$(@)"
+ $(hide) mkdir -p "$$(dir $$@)"
+ $(hide) rm -f "$$@"
+ $(hide) awk <"$$<" >"$$@" \
+ '/^#/ { print; next } \
+ NF == 0 { next } \
+ NF < 2 || $$$$1 != "options" \
+ { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
+ exit_status = 1; next } \
+ { $$$$1 = $$$$1; print } \
+ END { exit exit_status }'
+endef
+
# $(1): source blocklist file
# $(2): destination pathname
# Returns a build rule that checks the syntax of and installs a kernel modules
-# blocklist file. Strip and squeeze any extra space in the blocklist.
+# blocklist file. Strip and squeeze any extra space and blank lines.
# For use via $(eval).
define build-image-kernel-modules-blocklist-file
$(2): $(1)
- @echo "modprobe blocklist $$(@)"
+ @echo "libmodprobe blocklist $$(@)"
$(hide) mkdir -p "$$(dir $$@)"
$(hide) rm -f "$$@"
$(hide) awk <"$$<" >"$$@" \
@@ -352,11 +428,19 @@
$(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
$(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
$(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver)))) \
+$(if $(_kver), \
+ $(eval _dir := $(_kver)/), \
+ $(eval _dir :=)) \
+$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
+ $(eval $(call build-image-kernel-modules-options-file, \
+ $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
+ $(2)/lib/modules/$(_dir)modules.options)) \
+ $(2)/lib/modules/$(_dir)modules.options) \
$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
$(eval $(call build-image-kernel-modules-blocklist-file, \
$(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
- $(2)/lib/modules/modules.blocklist)) \
- $(2)/lib/modules/modules.blocklist)
+ $(2)/lib/modules/$(_dir)modules.blocklist)) \
+ $(2)/lib/modules/$(_dir)modules.blocklist)
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
@@ -415,38 +499,24 @@
VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
endif
-# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
-$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
- $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
- $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
- $(error Must not specify KERNEL_MODULE_DIRS for prebuilt vendor ramdisk fragment "$(vendor_ramdisk_fragment)": $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS))) \
- $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-dlkm-$(vendor_ramdisk_fragment))) \
- $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
- $(foreach dir,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
- $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(dir)) \
- $(if $($(kmd_vrf)),$(error Kernel module directory "$(dir)" belongs to multiple vendor ramdisk fragments: "$($(kmd_vrf))" "$(vendor_ramdisk_fragment)", each kernel module directory should belong to exactly one or none vendor ramdisk fragment)) \
- $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
- ) \
-)
-
BOARD_KERNEL_MODULE_DIRS += top
-$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
- $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(dir))) \
+$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(kmd))) \
+ $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
$(if $(vendor_ramdisk_fragment), \
$(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
$(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
$(eval ### else ###), \
$(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
$(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
- $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(dir))) \
+ $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(kmd))) \
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
- $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(kmd)))))
# -----------------------------------------------------------------
# Cert-to-package mapping. Used by the post-build signing tools.
@@ -981,12 +1051,6 @@
my_installed_prebuilt_gki_apex :=
# -----------------------------------------------------------------
-# declare recovery ramdisk files
-ifeq ($(BUILDING_RECOVERY_IMAGE),true)
-INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
-endif
-
-# -----------------------------------------------------------------
# vendor boot image
ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
@@ -1000,10 +1064,14 @@
INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.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_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
endif
+endif
$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
$(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
@@ -1040,13 +1108,13 @@
endif
ifdef INTERNAL_BOOTCONFIG
-ifneq (,$(findstring androidboot.hardware=, $(INTERNAL_BOOTCONFIG)))
-$(error "androidboot.hardware" BOOTCONFIG parameter is not supported due to \
- bootconfig limitations. Use "hardware" instead. INTERNAL_BOOTCONFIG: \
- $(INTERNAL_BOOTCONFIG))
-endif
-INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
-$(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
+ ifneq (,$(findstring androidboot.hardware=, $(INTERNAL_BOOTCONFIG)))
+ $(error "androidboot.hardware" BOOTCONFIG parameter is not supported due \
+ to bootconfig limitations. Use "hardware" instead. INTERNAL_BOOTCONFIG: \
+ $(INTERNAL_BOOTCONFIG))
+ endif
+ INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
+ $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
rm -f $@
$(foreach param,$(INTERNAL_BOOTCONFIG), \
printf "%s\n" $(param) >> $@;)
@@ -1083,17 +1151,12 @@
INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
-$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
+$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
$(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
$(if $(prebuilt_vendor_ramdisk_fragment_file), \
$(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
$(eval ### else ###), \
- $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment))) \
- $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
- $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
- $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
- $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
- $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
+ $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
$(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
$(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
)
@@ -2401,9 +2464,14 @@
$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
+# 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
INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
$(ALL_GENERATED_SOURCES) \
@@ -2509,7 +2577,7 @@
$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
$(call pretty,"Target test harness ramdisk: $@")
- rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
+ rsync --chmod=u+w -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
$(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
$(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
@@ -2527,6 +2595,7 @@
#
# 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.
+ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
@@ -2567,6 +2636,7 @@
$(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
endif # TARGET_NO_KERNEL
+endif # INSTALLED_BOOTIMAGE_TARGET
endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
@@ -3937,6 +4007,9 @@
or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
manually.)
+# Clear their values to indicate that these two files does not exist.
+BUILT_KERNEL_CONFIGS_FILE :=
+BUILT_KERNEL_VERSION_FILE :=
else
# Tools for decompression that is not in PATH.
@@ -3981,8 +4054,10 @@
check_vintf_compatible_deps := $(check_vintf_common_srcs)
ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
+ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
+endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
check_vintf_compatible_args += \
@@ -4621,6 +4696,8 @@
echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
$(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
echo "build_super_partition=true" >> $(1)))
+ $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
+ echo "build_super_empty_partition=true" >> $(1))
$(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
@@ -4794,8 +4871,12 @@
ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))$(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
@# Components of the recovery image
$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
+# Exclude recovery files in the default vendor ramdisk if including a standalone
+# recovery ramdisk in vendor_boot.
+ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
$(hide) $(call package_files-copy-root, \
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
+endif
ifdef INSTALLED_KERNEL_TARGET
ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
@@ -4885,9 +4966,9 @@
echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
endif
echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
-ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
- echo "$(BOARD_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
- $(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
+ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
+ echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
+ $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
$(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
@@ -4897,7 +4978,7 @@
$(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
))
-endif # BOARD_VENDOR_RAMDISK_FRAGMENTS != ""
+endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
ifdef BUILDING_SYSTEM_IMAGE
@# Contents of the system image
@@ -5244,6 +5325,26 @@
$(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
$(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
+DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
+$(DEXPREOPT_CONFIG_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
+ $(INTERNAL_RAMDISK_FILES) \
+ $(INTERNAL_USERDATAIMAGE_FILES) \
+ $(INTERNAL_VENDORIMAGE_FILES) \
+ $(INTERNAL_PRODUCTIMAGE_FILES) \
+ $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
+ $(DEX_PREOPT_CONFIG_FOR_MAKE) \
+ $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)
+
+$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
+ $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
+ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
+ $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+endif
+ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
+ $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+endif
+ $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
+
# -----------------------------------------------------------------
# A zip of the symbols directory. Keep the full paths to make it
# more obvious where these files came from.
@@ -5329,10 +5430,18 @@
# Any dependencies are set up later in build/make/core/main.mk.
JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
+$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
+$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
+$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
+$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
$(JACOCO_REPORT_CLASSES_ALL) :
@echo "Collecting uninstrumented classes"
- find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" -o -name "proguard_usage.zip" 2>/dev/null | sort > $@.list
- $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
+ mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
+ $(SOONG_ZIP) -o $@ -L 0 \
+ -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
+ -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
+ -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
+ -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
@@ -5348,13 +5457,11 @@
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
endif
-$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
+$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
@echo "Packaging Proguard obfuscation dictionary files."
- mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
- find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
- sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
- $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
+ mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR)
+ $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -P out/target/common/obj -D $(PRIVATE_PACKAGING_DIR)
#------------------------------------------------------------------
# A zip of Proguard usage files.
@@ -5375,11 +5482,12 @@
$(INSTALLED_ODM_DLKMIMAGE_TARGET) \
$(updater_dep)
endif
-$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
+$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
+$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
@echo "Packaging Proguard usage files."
- mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
- find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
+ mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
+ find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
$(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
@@ -5490,9 +5598,7 @@
# -----------------------------------------------------------------
# super empty image
-
-ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
-ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
+ifdef BUILDING_SUPER_EMPTY_IMAGE
INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
@@ -5506,8 +5612,7 @@
$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
-endif # BOARD_SUPER_PARTITION_SIZE != ""
-endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
+endif # BUILDING_SUPER_EMPTY_IMAGE
# -----------------------------------------------------------------
diff --git a/core/app_prebuilt_internal.mk b/core/app_prebuilt_internal.mk
index fe04b84..86a4adf 100644
--- a/core/app_prebuilt_internal.mk
+++ b/core/app_prebuilt_internal.mk
@@ -169,12 +169,13 @@
endif
my_dex_jar := $(my_prebuilt_src_file)
-my_manifest_or_apk := $(my_prebuilt_src_file)
dex_preopt_profile_src_file := $(my_prebuilt_src_file)
#######################################
# defines built_odex along with rule to install odex
+my_manifest_or_apk := $(my_prebuilt_src_file)
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+my_manifest_or_apk :=
#######################################
ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
# There is a replacement for the prebuilt .apk we can install without any processing.
@@ -208,7 +209,7 @@
ifeq ($(module_run_appcompat),true)
$(built_module) : $(AAPT2)
endif
-$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR)
+$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR) $(SIGNAPK_JNI_LIBRARY_PATH)
$(transform-prebuilt-to-target)
$(uncompress-prebuilt-embedded-jni-libs)
$(remove-unwanted-prebuilt-embedded-jni-libs)
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 68f880f..5f654a6 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -533,13 +533,17 @@
ifndef LOCAL_IS_HOST_MODULE
# Rule to install the module's companion init.rc.
-my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC)
+ifneq ($(strip $(LOCAL_FULL_INIT_RC)),)
+my_init_rc := $(LOCAL_FULL_INIT_RC)
+else
+my_init_rc := $(foreach rc,$(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC),$(LOCAL_PATH)/$(rc))
+endif
ifneq ($(strip $(my_init_rc)),)
# Make doesn't support recovery as an output partition, but some Soong modules installed in recovery
# have init.rc files that need to be installed alongside them. Manually handle the case where the
# output file is in the recovery partition.
my_init_rc_path := $(if $(filter $(TARGET_RECOVERY_ROOT_OUT)/%,$(my_module_path)),$(TARGET_RECOVERY_ROOT_OUT)/system/etc,$(TARGET_OUT$(partition_tag)_ETC))
-my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(my_init_rc_path)/init/$(notdir $(rc)))
+my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(rc):$(my_init_rc_path)/init/$(notdir $(rc)))
my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc)))
# Make sure we only set up the copy rules once, even if another arch variant
@@ -569,9 +573,14 @@
my_vintf_pairs:=
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ifndef LOCAL_IS_HOST_MODULE
-ifneq ($(strip $(LOCAL_VINTF_FRAGMENTS)),)
+ifneq ($(strip $(LOCAL_FULL_VINTF_FRAGMENTS)),)
+my_vintf_fragments := $(LOCAL_FULL_VINTF_FRAGMENTS)
+else
+my_vintf_fragments := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml))
+endif
+ifneq ($(strip $(my_vintf_fragments)),)
-my_vintf_pairs := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml):$(TARGET_OUT$(partition_tag)_ETC)/vintf/manifest/$(notdir $(xml)))
+my_vintf_pairs := $(foreach xml,$(my_vintf_fragments),$(xml):$(TARGET_OUT$(partition_tag)_ETC)/vintf/manifest/$(notdir $(xml)))
my_vintf_installed := $(foreach xml,$(my_vintf_pairs),$(call word-colon,2,$(xml)))
# Only set up copy rules once, even if another arch variant shares it
@@ -1001,7 +1010,9 @@
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).FILE_CONTEXTS := $(LOCAL_FILE_CONTEXTS)
endif
+ifdef LOCAL_IS_UNIT_TEST
ALL_MODULES.$(my_register_name).IS_UNIT_TEST := $(LOCAL_IS_UNIT_TEST)
+endif
test_config :=
INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
diff --git a/core/binary.mk b/core/binary.mk
index 2c20eed..cf47374 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -266,10 +266,7 @@
endif
endif
- ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant)))
- my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
- endif
-
+ my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
my_ldlibs += -ldl
else # LOCAL_NDK_STL_VARIANT must be none
# Do nothing.
@@ -474,27 +471,6 @@
my_soong_problems += dotdot_incs
endif
-####################################################
-## Add FDO flags if FDO is turned on and supported
-## Please note that we will do option filtering during FDO build.
-## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
-##################################################################
-my_fdo_build :=
-ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
- ifeq ($(BUILD_FDO_INSTRUMENT),true)
- my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
- my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
- my_fdo_build := true
- else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
- my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
- my_fdo_build := true
- endif
- # Disable ccache (or other compiler wrapper) except gomacc, which
- # can handle -fprofile-use properly.
- my_cc_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cc_wrapper))
- my_cxx_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cxx_wrapper))
-endif
-
###########################################################
## Explicitly declare assembly-only __ASSEMBLY__ macro for
## assembly source
@@ -1482,12 +1458,6 @@
my_asflags := $(call convert-to-clang-flags,$(my_asflags))
my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
-ifeq ($(my_fdo_build), true)
- my_cflags := $(patsubst -Os,-O2,$(my_cflags))
- fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
- my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
-endif
-
# No one should ever use this flag. On GCC it's mere presence will disable all
# warnings, even those that are specified after it (contrary to typical warning
# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
diff --git a/core/board_config.mk b/core/board_config.mk
index 57363fb..be37292 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -25,6 +25,7 @@
_board_strip_readonly_list += BOARD_HAVE_BLUETOOTH
_board_strip_readonly_list += BOARD_INSTALLER_CMDLINE
_board_strip_readonly_list += BOARD_KERNEL_CMDLINE
+_board_strip_readonly_list += BOARD_BOOT_HEADER_VERSION
_board_strip_readonly_list += BOARD_BOOTCONFIG
_board_strip_readonly_list += BOARD_KERNEL_BASE
_board_strip_readonly_list += BOARD_USES_GENERIC_AUDIO
@@ -107,6 +108,8 @@
# contains a kernel or not.
# - BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT controls whether ramdisk
# recovery resources are built to vendor_boot.
+# - BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT controls whether recovery
+# resources are built as a standalone recovery ramdisk in vendor_boot.
# - BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT controls whether GSI AVB keys are
# built to vendor_boot.
# - BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES controls whether boot images in $OUT are added
@@ -114,6 +117,7 @@
_board_strip_readonly_list += BOARD_USES_GENERIC_KERNEL_IMAGE
_board_strip_readonly_list += BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE
_board_strip_readonly_list += BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT
+_board_strip_readonly_list += BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT
_board_strip_readonly_list += BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT
_board_strip_readonly_list += BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES
@@ -329,7 +333,8 @@
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_DEBUG_RAMDISK
ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT) \
- $(BOARD_GKI_NONAB_COMPAT) $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
+ $(BOARD_GKI_NONAB_COMPAT) $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT) \
+ $(BOARD_USES_GENERIC_KERNEL_IMAGE)))
TARGET_COPY_OUT_DEBUG_RAMDISK := debug_ramdisk/first_stage_ramdisk
TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK := vendor_debug_ramdisk/first_stage_ramdisk
TARGET_COPY_OUT_TEST_HARNESS_RAMDISK := test_harness_ramdisk/first_stage_ramdisk
@@ -460,6 +465,25 @@
endif
.KATI_READONLY := BUILDING_VBMETA_IMAGE
+# Are we building a super_empty image
+BUILDING_SUPER_EMPTY_IMAGE :=
+ifeq ($(PRODUCT_BUILD_SUPER_EMPTY_IMAGE),)
+ ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
+ ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
+ BUILDING_SUPER_EMPTY_IMAGE := true
+ endif
+ endif
+else ifeq ($(PRODUCT_BUILD_SUPER_EMPTY_IMAGE),true)
+ ifneq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
+ $(error PRODUCT_BUILD_SUPER_EMPTY_IMAGE set to true, but PRODUCT_USE_DYNAMIC_PARTITIONS is not true)
+ endif
+ ifeq ($(BOARD_SUPER_PARTITION_SIZE),)
+ $(error PRODUCT_BUILD_SUPER_EMPTY_IMAGE set to true, but BOARD_SUPER_PARTITION_SIZE is not defined)
+ endif
+ BUILDING_SUPER_EMPTY_IMAGE := true
+endif
+.KATI_READONLY := BUILDING_SUPER_EMPTY_IMAGE
+
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR
ifeq ($(TARGET_COPY_OUT_VENDOR),$(_vendor_path_placeholder))
@@ -808,12 +832,30 @@
ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
$(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if not building vendor_boot image)
endif
-endif
+else # BUILDING_VENDOR_BOOT_IMAGE
+ ifneq (,$(call math_lt,$(BOARD_BOOT_HEADER_VERSION),4))
+ ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
+ $(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if \
+ BOARD_BOOT_HEADER_VERSION is less than 4)
+ endif
+ ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
+ $(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \
+ BOARD_BOOT_HEADER_VERSION is less than 4)
+ endif
+ endif
+endif # BUILDING_VENDOR_BOOT_IMAGE
ifneq ($(words $(BOARD_VENDOR_RAMDISK_FRAGMENTS)),$(words $(sort $(BOARD_VENDOR_RAMDISK_FRAGMENTS))))
$(error BOARD_VENDOR_RAMDISK_FRAGMENTS has duplicate entries: $(BOARD_VENDOR_RAMDISK_FRAGMENTS))
endif
+ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
+ ifneq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
+ $(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \
+ BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is not set)
+ endif
+endif
+
# If BOARD_USES_GENERIC_KERNEL_IMAGE is set, BOARD_USES_RECOVERY_AS_BOOT must not be set.
# Devices without a dedicated recovery partition uses BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT to
# build recovery into vendor_boot.
diff --git a/core/build_id.rbc b/core/build_id.rbc
new file mode 100644
index 0000000..4f33833
--- /dev/null
+++ b/core/build_id.rbc
@@ -0,0 +1,21 @@
+
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file has been manually converted from build_id.mk
+def init(g):
+
+ # BUILD_ID is usually used to specify the branch name (like "MAIN") or a branch name and a release candidate
+ # (like "CRB01"). It must be a single word, and is capitalized by convention.
+ g["BUILD_ID"]="AOSP.MASTER"
\ No newline at end of file
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 019892e..e2acb67 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -100,15 +100,16 @@
LOCAL_EXTRA_FULL_TEST_CONFIGS:=
LOCAL_EXTRACT_APK:=
LOCAL_EXTRACT_DPI_APK:=
-LOCAL_FDO_SUPPORT:=
LOCAL_FILE_CONTEXTS:=
LOCAL_FINDBUGS_FLAGS:=
LOCAL_FORCE_STATIC_EXECUTABLE:=
LOCAL_FULL_CLASSES_JACOCO_JAR:=
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR:=
+LOCAL_FULL_INIT_RC:=
LOCAL_FULL_LIBS_MANIFEST_FILES:=
LOCAL_FULL_MANIFEST_FILE:=
LOCAL_FULL_TEST_CONFIG:=
+LOCAL_FULL_VINTF_FRAGMENTS:=
LOCAL_FUZZ_ENGINE:=
LOCAL_FUZZ_INSTALLED_SHARED_DEPS:=
LOCAL_GCNO_FILES:=
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index e45c1a6..11c1944 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -64,7 +64,6 @@
endif
include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
-include $(BUILD_SYSTEM)/combo/fdo.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index a3f59a7..5d481cb 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -39,7 +39,6 @@
endif
include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
-include $(BUILD_SYSTEM)/combo/fdo.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 2c4614b..acbae51 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -32,7 +32,6 @@
endif
include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
-include $(BUILD_SYSTEM)/combo/fdo.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index d2172d6..9e7e363 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -32,7 +32,6 @@
endif
include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
-include $(BUILD_SYSTEM)/combo/fdo.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
diff --git a/core/combo/fdo.mk b/core/combo/fdo.mk
deleted file mode 100644
index 8fb8fd3..0000000
--- a/core/combo/fdo.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2006 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Setup FDO related flags.
-
-$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=
-
-# Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
-# The profile will be generated on /sdcard/fdo_profile on the device.
-$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
-$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_LDFLAGS := -lgcov -lgcc
-
-# Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
-ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
- $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
-endif
-
-$(combo_2nd_arch_prefix)TARGET_FDO_OPTIMIZE_CFLAGS := \
- -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) \
- -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
diff --git a/core/config.mk b/core/config.mk
index 00b3fcf..d1746ef 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -158,6 +158,7 @@
$(KATI_deprecated_var BOARD_PLAT_PUBLIC_SEPOLICY_DIR,Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead)
$(KATI_deprecated_var BOARD_PLAT_PRIVATE_SEPOLICY_DIR,Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead)
$(KATI_obsolete_var TARGET_NO_VENDOR_BOOT,Use PRODUCT_BUILD_VENDOR_BOOT_IMAGE instead)
+$(KATI_obsolete_var PRODUCT_CHECK_ELF_FILES,Use BUILD_BROKEN_PREBUILT_ELF_FILES instead)
# Used to force goals to build. Only use for conditionally defined goals.
.PHONY: FORCE
@@ -1082,12 +1083,13 @@
# This produces a list like "current/core current/public current/system 4/public"
TARGET_AVAILABLE_SDK_VERSIONS := $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/*/android.jar)
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%,$(TARGET_AVAILABLE_SDK_VERSIONS))
-# Strips and reorganizes the "public", "core" and "system" subdirs.
+# Strips and reorganizes the "public", "core", "system" and "test" subdirs.
TARGET_AVAILABLE_SDK_VERSIONS := $(subst /public,,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/core,core_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/system,system_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
-# No prebuilt for test_current.
-TARGET_AVAILABLE_SDK_VERSIONS += test_current
+TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/test,test_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
+# module-lib and system-server are not supported in Make.
+TARGET_AVAILABLE_SDK_VERSIONS := $(filter-out %/module-lib %/system-server,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAIALBLE_SDK_VERSIONS := $(call numerically_sort,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS))
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 228bad6..90f00c0 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -115,14 +115,17 @@
my_sanitize_diag :=
endif
-# Enable CFI in included paths (for Arm64 only).
+# Enable CFI in included paths.
ifeq ($(filter cfi, $(my_sanitize)),)
- ifneq ($(filter arm64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
- combined_include_paths := $(CFI_INCLUDE_PATHS) \
- $(PRODUCT_CFI_INCLUDE_PATHS)
+ combined_include_paths := $(CFI_INCLUDE_PATHS) \
+ $(PRODUCT_CFI_INCLUDE_PATHS)
+ combined_exclude_paths := $(CFI_EXCLUDE_PATHS) \
+ $(PRODUCT_CFI_EXCLUDE_PATHS)
- ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
- $(filter $(dir)%,$(LOCAL_PATH)))),)
+ ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
+ $(filter $(dir)%,$(LOCAL_PATH)))),)
+ ifeq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
+ $(filter $(dir)%,$(LOCAL_PATH)))),)
my_sanitize := cfi $(my_sanitize)
endif
endif
@@ -135,14 +138,19 @@
$(PRODUCT_MEMTAG_HEAP_SYNC_INCLUDE_PATHS)
combined_async_include_paths := $(MEMTAG_HEAP_ASYNC_INCLUDE_PATHS) \
$(PRODUCT_MEMTAG_HEAP_ASYNC_INCLUDE_PATHS)
+ combined_exclude_paths := $(MEMTAG_HEAP_EXCLUDE_PATHS) \
+ $(PRODUCT_MEMTAG_HEAP_EXCLUDE_PATHS)
- ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_sync_include_paths)),\
- $(filter $(dir)%,$(LOCAL_PATH)))),)
- my_sanitize := memtag_heap $(my_sanitize)
- my_sanitize_diag := memtag_heap $(my_sanitize)
- else ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_async_include_paths)),\
- $(filter $(dir)%,$(LOCAL_PATH)))),)
- my_sanitize := memtag_heap $(my_sanitize)
+ ifeq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
+ $(filter $(dir)%,$(LOCAL_PATH)))),)
+ ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_sync_include_paths)),\
+ $(filter $(dir)%,$(LOCAL_PATH)))),)
+ my_sanitize := memtag_heap $(my_sanitize)
+ my_sanitize_diag := memtag_heap $(my_sanitize_diag)
+ else ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_async_include_paths)),\
+ $(filter $(dir)%,$(LOCAL_PATH)))),)
+ my_sanitize := memtag_heap $(my_sanitize)
+ endif
endif
endif
endif
@@ -211,10 +219,12 @@
ifneq ($(filter memtag_heap,$(my_sanitize)),)
# Add memtag ELF note.
- ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
- my_whole_static_libraries += note_memtag_heap_sync
- else
- my_whole_static_libraries += note_memtag_heap_async
+ ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+ ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
+ my_whole_static_libraries += note_memtag_heap_sync
+ else
+ my_whole_static_libraries += note_memtag_heap_async
+ endif
endif
# This is all that memtag_heap does - it is not an actual -fsanitize argument.
# Remove it from the list.
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index f71ef72..0d557c7 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -82,15 +82,7 @@
endif
endif
else ifeq ($(my_cxx_stl),ndk)
- # Using an NDK STL. Handled in binary.mk, except for the unwinder.
- # TODO: Switch the NDK over to the LLVM unwinder for non-arm32 architectures.
- ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
- my_static_libraries += libunwind_llvm
- my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a
- else
- my_static_libraries += libgcc_stripped
- my_ldflags += -Wl,--exclude-libs,libgcc_stripped.a
- endif
+ # Using an NDK STL. Handled in binary.mk.
else ifeq ($(my_cxx_stl),libstdc++)
$(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported)
else ifeq ($(my_cxx_stl),none)
diff --git a/core/definitions.mk b/core/definitions.mk
index 2883f0d..2951c05 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -745,6 +745,42 @@
endef
###########################################################
+## The packaging directory for a module. Similar to intermedates, but
+## in a location that will be wiped by an m installclean.
+###########################################################
+
+# $(1): subdir in PACKAGING
+# $(2): target class, like "APPS"
+# $(3): target name, like "NotePad"
+# $(4): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
+define packaging-dir-for
+$(strip \
+ $(eval _pdfClass := $(strip $(2))) \
+ $(if $(_pdfClass),, \
+ $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
+ $(eval _pdfName := $(strip $(3))) \
+ $(if $(_pdfName),, \
+ $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
+ $(call intermediates-dir-for,PACKAGING,$(1),$(4))/$(_pdfClass)/$(_pdfName)_intermediates \
+)
+endef
+
+# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
+# to determine the packaging directory.
+#
+# $(1): subdir in PACKAGING
+define local-packaging-dir
+$(strip \
+ $(if $(strip $(LOCAL_MODULE_CLASS)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
+ $(if $(strip $(LOCAL_MODULE)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
+ $(call packaging-dir-for,$(1),$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST)) \
+)
+endef
+
+
+###########################################################
## Convert a list of short module names (e.g., "framework", "Browser")
## into the list of files that are built for those modules.
## NOTE: this won't return reliable results until after all
@@ -1712,7 +1748,6 @@
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
- $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
@@ -1752,7 +1787,6 @@
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
- $(PRIVATE_TARGET_LIBATOMIC) \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
@@ -1787,7 +1821,6 @@
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
- $(PRIVATE_TARGET_LIBATOMIC) \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
@@ -1831,7 +1864,6 @@
$(filter %libc.a %libc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(filter %libc_nomalloc.a %libc_nomalloc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
- $(PRIVATE_TARGET_LIBATOMIC) \
$(filter %libcompiler_rt.a %libcompiler_rt.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
-Wl,--end-group \
@@ -1859,7 +1891,6 @@
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
- $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(foreach path,$(PRIVATE_RPATHS), \
@@ -2734,7 +2765,7 @@
define _symlink-file
$(3): $(1)
@echo "Symlink: $$@ -> $(2)"
- @mkdir -p $(dir $$@)
+ @mkdir -p $$(dir $$@)
@rm -rf $$@
$(hide) ln -sf $(2) $$@
$(3): .KATI_SYMLINK_OUTPUTS := $(3)
diff --git a/core/dex_preopt_config.mk b/core/dex_preopt_config.mk
index 7c45646..51238a3 100644
--- a/core/dex_preopt_config.mk
+++ b/core/dex_preopt_config.mk
@@ -47,9 +47,8 @@
product/app/% \
product/priv-app/% \
-# Global switch control if updatable boot jars are included in dexpreopt.
-# Currently unconditionally set to true, this may change in the future.
-DEX_PREOPT_WITH_UPDATABLE_BCP := false
+# Global switch to control if updatable boot jars are included in dexpreopt.
+DEX_PREOPT_WITH_UPDATABLE_BCP := true
# Conditional to building on linux, as dex2oat currently does not work on darwin.
ifeq ($(HOST_OS),linux)
@@ -106,7 +105,7 @@
$(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR))
$(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS))
$(call add_json_list, UpdatableBootJars, $(PRODUCT_UPDATABLE_BOOT_JARS))
- $(call add_json_list, ArtApexJars, $(ART_APEX_JARS))
+ $(call add_json_list, ArtApexJars, $(filter $(PRODUCT_BOOT_JARS),$(ART_APEX_JARS)))
$(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS))
$(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS))
$(call add_json_list, UpdatableSystemServerJars, $(PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS))
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index 560a555..a23bae2 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -31,9 +31,8 @@
LOCAL_DEX_PREOPT :=
endif
-# Disable <uses-library> checks and preopt for tests.
+# Disable preopt for tests.
ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
- LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT :=
endif
@@ -47,14 +46,8 @@
LOCAL_DEX_PREOPT :=
endif
-# Disable <uses-library> checks and preopt if not WITH_DEXPREOPT
-#
-# Without dexpreopt the check is not necessary, and although it is good to have,
-# it is difficult to maintain on non-linux build platforms where dexpreopt is
-# generally disabled (the check may fail due to various unrelated reasons, such
-# as a failure to get manifest from an APK).
+# Disable preopt if not WITH_DEXPREOPT
ifneq (true,$(WITH_DEXPREOPT))
- LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT :=
endif
@@ -62,9 +55,8 @@
LOCAL_DEX_PREOPT :=
endif
-# Disable <uses-library> checks and preopt if the app contains no java code.
+# Disable preopt if the app contains no java code.
ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR)))
- LOCAL_ENFORCE_USES_LIBRARIES := false
LOCAL_DEX_PREOPT :=
endif
@@ -202,6 +194,38 @@
# Verify <uses-library> coherence between the build system and the manifest.
################################################################################
+# Some libraries do not have a manifest, so there is nothing to check against.
+# Handle it as if the manifest had zero <uses-library> tags: it is ok unless the
+# module has non-empty LOCAL_USES_LIBRARIES or LOCAL_OPTIONAL_USES_LIBRARIES.
+ifndef my_manifest_or_apk
+ ifneq (,$(strip $(LOCAL_USES_LIBRARIES)$(LOCAL_OPTIONAL_USES_LIBRARIES)))
+ $(error $(LOCAL_MODULE) has non-empty <uses-library> list but no manifest)
+ else
+ LOCAL_ENFORCE_USES_LIBRARIES := false
+ endif
+endif
+
+# Disable the check for tests.
+ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
+ LOCAL_ENFORCE_USES_LIBRARIES := false
+endif
+
+# Disable the check if the app contains no java code.
+ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR)))
+ LOCAL_ENFORCE_USES_LIBRARIES := false
+endif
+
+# Disable <uses-library> checks if dexpreopt is globally disabled.
+# Without dexpreopt the check is not necessary, and although it is good to have,
+# it is difficult to maintain on non-linux build platforms where dexpreopt is
+# generally disabled (the check may fail due to various unrelated reasons, such
+# as a failure to get manifest from an APK).
+ifneq (true,$(WITH_DEXPREOPT))
+ LOCAL_ENFORCE_USES_LIBRARIES := false
+else ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
+ LOCAL_ENFORCE_USES_LIBRARIES := false
+endif
+
# Verify LOCAL_USES_LIBRARIES/LOCAL_OPTIONAL_USES_LIBRARIES
# If LOCAL_ENFORCE_USES_LIBRARIES is not set, default to true if either of LOCAL_USES_LIBRARIES or
# LOCAL_OPTIONAL_USES_LIBRARIES are specified.
@@ -354,7 +378,7 @@
$(call add_json_str, ProfileClassListing, $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE)))
$(call add_json_bool, ProfileIsTextListing, $(my_profile_is_text_listing))
$(call add_json_str, EnforceUsesLibrariesStatusFile, $(my_enforced_uses_libraries))
- $(call add_json_bool, EnforceUsesLibraries, $(LOCAL_ENFORCE_USES_LIBRARIES))
+ $(call add_json_bool, EnforceUsesLibraries, $(filter true,$(LOCAL_ENFORCE_USES_LIBRARIES)))
$(call add_json_str, ProvidesUsesLibrary, $(firstword $(LOCAL_PROVIDES_USES_LIBRARY) $(LOCAL_MODULE)))
$(call add_json_map, ClassLoaderContexts)
$(call add_json_class_loader_context, any, $(my_dexpreopt_libs))
@@ -375,6 +399,7 @@
$(call json_end)
my_dexpreopt_config := $(intermediates)/dexpreopt.config
+ my_dexpreopt_config_for_postprocessing := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
my_dexpreopt_script := $(intermediates)/dexpreopt.sh
my_dexpreopt_zip := $(intermediates)/dexpreopt.zip
my_dexpreopt_config_merger := $(BUILD_SYSTEM)/dex_preopt_config_merger.py
@@ -404,6 +429,8 @@
-dexpreopt_script $@ \
-out_dir $(OUT_DIR)
+ $(eval $(call copy-one-file,$(my_dexpreopt_config),$(my_dexpreopt_config_for_postprocessing)))
+
my_dexpreopt_deps := $(my_dex_jar)
my_dexpreopt_deps += $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE))
my_dexpreopt_deps += \
@@ -439,10 +466,12 @@
$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
$(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_zip)
+ $(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_config_for_postprocessing)
$(my_all_targets): $(my_dexpreopt_zip)
my_dexpreopt_config :=
my_dexpreopt_script :=
my_dexpreopt_zip :=
+ my_dexpreopt_config_for_postprocessing :=
endif # LOCAL_DEX_PREOPT
diff --git a/core/envsetup.rbc b/core/envsetup.rbc
new file mode 100644
index 0000000..451623b
--- /dev/null
+++ b/core/envsetup.rbc
@@ -0,0 +1,207 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load(":build_id.rbc|init", _build_id_init = "init")
+
+def _all_versions():
+ """Returns all known versions."""
+ versions = ["OPR1", "OPD1", "OPD2", "OPM1", "OPM2", "PPR1", "PPD1", "PPD2", "PPM1", "PPM2", "QPR1"]
+ for v in ("Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"):
+ for e in ("P1A", "P1B", "P2A", "P2B", "D1A", "D1B", "D2A", "D2B", "Q1A", "Q1B", "Q2A", "Q2B", "Q3A", "Q3B"):
+ versions.append(v + e)
+ return versions
+
+def _allowed_versions(all_versions, min_version, max_version, default_version):
+ """Checks that version range and default versions is valid, returns all versions in range."""
+ for v in (min_version, max_version, default_version):
+ if v not in all_versions:
+ fail("% is invalid" % v)
+
+ min_i = all_versions.index(min_version)
+ max_i = all_versions.index(max_version)
+ def_i = all_versions.index(default_version)
+ if min_i > max_i:
+ fail("%s should come before %s in the version list" % (min_version, max_version))
+ if def_i < min_i or def_i > max_i:
+ fail("%s should come between % and %s" % (default_version, min_version, max_version))
+ return all_versions[min_i:max_i + 1]
+
+# This function is a manual conversion of the version_defaults.mk
+def _versions_default(g, all_versions):
+ """Handle various build version information.
+
+ Guarantees that the following are defined:
+ PLATFORM_VERSION
+ PLATFORM_SDK_VERSION
+ PLATFORM_VERSION_CODENAME
+ DEFAULT_APP_TARGET_SDK
+ BUILD_ID
+ BUILD_NUMBER
+ PLATFORM_SECURITY_PATCH
+ PLATFORM_VNDK_VERSION
+ PLATFORM_SYSTEMSDK_VERSIONS
+ """
+
+ # If build_id.rbc exists, it may override some of the defaults.
+ # Note that build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set if the file exists.
+ if _build_id_init != None:
+ _build_id_init(g)
+ g["INTERNAL_BUILD_ID_MAKEFILE"] = "build/make/core/build_id"
+
+ allowed_versions = _allowed_versions(all_versions, v_min, v_max, v_default)
+ g.setdefault("TARGET_PLATFORM_VERSION", v_default)
+ if g["TARGET_PLATFORM_VERSION"] not in allowed_versions:
+ fail("% is not valid, must be one of %s" % (g["TARGET_PLATFORM_VERSION"], allowed_versions))
+
+ g["DEFAULT_PLATFORM_VERSION"] = v_default
+ g["PLATFORM_VERSION_LAST_STABLE"] = 11
+ g.setdefault("PLATFORM_VERSION_CODENAME", g["TARGET_PLATFORM_VERSION"])
+ # TODO(asmundak): set PLATFORM_VERSION_ALL_CODENAMES
+
+ g.setdefault("PLATFORM_SDK_VERSION", 30)
+ version_codename = g["PLATFORM_VERSION_CODENAME"]
+ if version_codename == "REL":
+ g.setdefault("PLATFORM_VERSION", g["PLATFORM_VERSION_LAST_STABLE"])
+ g["PLATFORM_PREVIEW_SDK_VERSION"] = 0
+ g.setdefault("DEFAULT_APP_TARGET_SDK", g["PLATFORM_SDK_VERSION"])
+ g.setdefault("PLATFORM_VNDK_VERSION", g["PLATFORM_SDK_VERSION"])
+ else:
+ g.setdefault("PLATFORM_VERSION", version_codename)
+ g.setdefault("PLATFORM_PREVIEW_SDK_VERSION", 1)
+ g.setdefault("DEFAULT_APP_TARGET_SDK", version_codename)
+ g.setdefault("PLATFORM_VNDK_VERSION", version_codename)
+
+ g.setdefault("PLATFORM_SYSTEMSDK_MIN_VERSION", 28)
+ versions = [str(i) for i in range(g["PLATFORM_SYSTEMSDK_MIN_VERSION"], g["PLATFORM_SDK_VERSION"] + 1)]
+ versions.append(version_codename)
+ g["PLATFORM_SYSTEMSDK_VERSIONS"] = sorted(versions)
+
+ # Used to indicate the security patch that has been applied to the device.
+ # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin.
+ # It must be of the form "YYYY-MM-DD" on production devices.
+ # It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
+ # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
+ g.setdefault("PLATFORM_SECURITY_PATCH", "2021-03-05")
+ dt = 'TZ="GMT" %s' % g["PLATFORM_SECURITY_PATCH"]
+ g.setdefault("PLATFORM_SECURITY_PATCH_TIMESTAMP", rblf_shell("date -d '%s' +%%s" % dt))
+
+ # Used to indicate the base os applied to the device. Can be an arbitrary string, but must be a single word.
+ # If there is no $PLATFORM_BASE_OS set, keep it empty.
+ g.setdefault("PLATFORM_BASE_OS", "")
+
+ # Used to signify special builds. E.g., branches and/or releases, like "M5-RC7". Can be an arbitrary string, but
+ # must be a single word and a valid file name. If there is no BUILD_ID set, make it obvious.
+ g.setdefault("BUILD_ID", "UNKNOWN")
+
+ # BUILD_NUMBER should be set to the source control value that represents the current state of the source code.
+ # E.g., a perforce changelist number or a git hash. Can be an arbitrary string (to allow for source control that
+ # uses something other than numbers), but must be a single word and a valid file name.
+ #
+ # If no BUILD_NUMBER is set, create a useful "I am an engineering build from this date/time" value. Make it start
+ # with a non-digit so that anyone trying to parse it as an integer will probably get "0".
+ g.setdefault("BUILD_NUMBER", "eng.%s.%s" % (g["USER"], "TIMESTAMP"))
+
+ # Used to set minimum supported target sdk version. Apps targeting SDK version lower than the set value will result
+ # in a warning being shown when any activity from the app is started.
+ g.setdefault("PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION", 23)
+
+def init(g):
+ """Initializes globals.
+
+ The code is the Starlark counterpart of the contents of the
+ envsetup.mk file.
+ Args:
+ g: globals dictionary
+ """
+ all_versions = _all_versions()
+ _versions_default(g, all_versions)
+ for v in all_versions:
+ g["IS_AT_LEAST" + v] = True
+ if v == g["TARGET_PLATFORM_VERSION"]:
+ break
+
+ # ---------------------------------------------------------------
+ # If you update the build system such that the environment setup or buildspec.mk need to be updated,
+ # increment this number, and people who haven't re-run those will have to do so before they can build.
+ # Make sure to also update the corresponding value in buildspec.mk.default and envsetup.sh.
+ g["CORRECT_BUILD_ENV_SEQUENCE_NUMBER"] = 13
+
+ g.setdefault("TARGET_PRODUCT", "aosp_arm")
+ g.setdefault("TARGET_BUILD_VARIANT", "eng")
+
+ g.setdefault("TARGET_BUILD_APPS", [])
+ g["TARGET_BUILD_UNBUNDLED"] = (g["TARGET_BUILD_APPS"] != []) or (getattr(g, "TARGET_BUILD_UNBUNDLED_IMAGE", "") != "")
+
+ # ---------------------------------------------------------------
+ # Set up configuration for host machine. We don't do cross-compiles except for arm, so the HOST
+ # is whatever we are running on.
+ host = rblf_shell("uname -sm")
+ if host.find("Linux") >= 0:
+ g["HOST_OS"] = "linux"
+ elif host.find("Darwin") >= 0:
+ g["HOST_OS"] = "darwin"
+ else:
+ fail("Cannot run on %s OS" % host)
+
+ # TODO(asmundak): set g.HOST_OS_EXTRA
+
+ g["BUILD_OS"] = g["HOST_OS"]
+
+ # TODO(asmundak): check cross-OS build
+
+ if host.find("x86_64") >= 0:
+ g["HOST_ARCH"] = "x86_64"
+ g["HOST_2ND_ARCH"] = "x86"
+ g["HOST_IS_64_BIT"] = True
+ elif host.find("i686") >= 0 or host.find("x86") >= 0:
+ fail("Building on a 32-bit x86 host is not supported: %s" % host)
+ elif g["HOST_OS"] == "darwin":
+ g["HOST_2ND_ARCH"] = ""
+
+ g["HOST_2ND_ARCH_VAR_PREFIX"] = "2ND_"
+ g["HOST_2ND_ARCH_MODULE_SUFFIX"] = "_32"
+ g["HOST_CROSS_2ND_ARCH_VAR_PREFIX"] = "2ND_"
+ g["HOST_CROSS_2ND_ARCH_MODULE_SUFFIX"] = "_64"
+ g["TARGET_2ND_ARCH_VAR_PREFIX"] = "2ND_"
+
+ # TODO(asmundak): envsetup.mk lines 216-226:
+ # convert combo-related stuff from combo/select.mk
+
+ # on windows, the tools have .exe at the end, and we depend on the
+ # host config stuff being done first
+ g["BUILD_ARCH"] = g["HOST_ARCH"]
+ g["BUILD_2ND_ARCH"] = g["HOST_2ND_ARCH"]
+
+ # the host build defaults to release, and it must be release or debug
+ g.setdefault("HOST_BUILD_TYPE", "release")
+ if g["HOST_BUILD_TYPE"] not in ["release", "debug"]:
+ fail("HOST_BUILD_TYPE must be either release or debug, not '%s'" % g["HOST_BUILD_TYPE"])
+
+ # TODO(asmundak): there is more stuff in envsetup.mk lines 249-292, but
+ # it does not seem to affect product configuration. Revisit this.
+
+ g["ART_APEX_JARS"] = [
+ "com.android.art:core-oj",
+ "com.android.art:core-libart",
+ "com.android.art:okhttp",
+ "com.android.art:bouncycastle",
+ "com.android.art:apache-xml",
+ ]
+
+ if g.get("TARGET_BUILD_TYPE", "") != "debug":
+ g["TARGET_BUILD_TYPE"] = "release"
+
+v_default = "SP1A"
+v_min = "SP1A"
+v_max = "SP1A"
diff --git a/core/executable_internal.mk b/core/executable_internal.mk
index c6a8faf..fb14cce 100644
--- a/core/executable_internal.mk
+++ b/core/executable_internal.mk
@@ -41,7 +41,6 @@
else
my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
endif
-my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
ifeq ($(LOCAL_NO_CRT),true)
my_target_crtbegin_dynamic_o :=
my_target_crtbegin_static_o :=
@@ -61,18 +60,17 @@
my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.sdk.$(my_ndk_crt_version))
endif
$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
-$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
-$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libatomic) $(CLANG_CXX)
+$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(CLANG_CXX)
$(transform-o-to-static-executable)
$(PRIVATE_POST_LINK_CMD)
else
-$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libatomic) $(CLANG_CXX)
+$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(CLANG_CXX)
$(transform-o-to-executable)
$(PRIVATE_POST_LINK_CMD)
endif
diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk
index 4a0fcfa..8a4b8c3 100644
--- a/core/fuzz_test.mk
+++ b/core/fuzz_test.mk
@@ -19,35 +19,6 @@
ifeq ($(my_fuzzer),libFuzzer)
LOCAL_STATIC_LIBRARIES += libFuzzer
-else ifeq ($(my_fuzzer),honggfuzz)
-LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz
-LOCAL_REQUIRED_MODULES += honggfuzz
-LOCAL_LDFLAGS += \
- "-Wl,--wrap=strcmp" \
- "-Wl,--wrap=strcasecmp" \
- "-Wl,--wrap=strncmp" \
- "-Wl,--wrap=strncasecmp" \
- "-Wl,--wrap=strstr" \
- "-Wl,--wrap=strcasestr" \
- "-Wl,--wrap=memcmp" \
- "-Wl,--wrap=bcmp" \
- "-Wl,--wrap=memmem" \
- "-Wl,--wrap=ap_cstr_casecmp" \
- "-Wl,--wrap=ap_cstr_casecmpn" \
- "-Wl,--wrap=ap_strcasestr" \
- "-Wl,--wrap=apr_cstr_casecmp" \
- "-Wl,--wrap=apr_cstr_casecmpn" \
- "-Wl,--wrap=CRYPTO_memcmp" \
- "-Wl,--wrap=OPENSSL_memcmp" \
- "-Wl,--wrap=OPENSSL_strcasecmp" \
- "-Wl,--wrap=OPENSSL_strncasecmp" \
- "-Wl,--wrap=xmlStrncmp" \
- "-Wl,--wrap=xmlStrcmp" \
- "-Wl,--wrap=xmlStrEqual" \
- "-Wl,--wrap=xmlStrcasecmp" \
- "-Wl,--wrap=xmlStrncasecmp" \
- "-Wl,--wrap=xmlStrstr" \
- "-Wl,--wrap=xmlStrcasestr"
else
$(call pretty-error, Unknown fuzz engine $(my_fuzzer))
endif
diff --git a/core/jacoco.mk b/core/jacoco.mk
index e8fb89b..e8c74ee 100644
--- a/core/jacoco.mk
+++ b/core/jacoco.mk
@@ -71,7 +71,11 @@
zip -q $@ \
-r $(PRIVATE_UNZIPPED_PATH)
-
+# Make a rule to copy the jacoco-report-classes.jar to a packaging directory.
+$(eval $(call copy-one-file,$(my_classes_to_report_on_path),\
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar))
+$(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)
# make a task that invokes instrumentation
my_instrumented_path := $(my_files)/work/instrumented/classes
diff --git a/core/java.mk b/core/java.mk
index 3f147ba..123cbe8 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -470,6 +470,17 @@
ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
$(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) $(proguard_configuration)
+
+ # Make a rule to copy the proguard_dictionary to a packaging directory.
+ $(eval $(call copy-one-file,$(proguard_dictionary),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
+
+ $(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar))
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar)
endif
endif # LOCAL_PROGUARD_ENABLED defined
diff --git a/core/java_host_unit_test_config_template.xml b/core/java_host_unit_test_config_template.xml
index ff300da..d8795f9 100644
--- a/core/java_host_unit_test_config_template.xml
+++ b/core/java_host_unit_test_config_template.xml
@@ -17,6 +17,7 @@
<configuration description="Runs {MODULE}">
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="apct-unit-tests" />
+ <option name="config-descriptor:metadata" key="component" value="{MODULE}" />
{EXTRA_CONFIGS}
diff --git a/core/java_prebuilt_internal.mk b/core/java_prebuilt_internal.mk
index 990b7d4..be733ff 100644
--- a/core/java_prebuilt_internal.mk
+++ b/core/java_prebuilt_internal.mk
@@ -33,7 +33,6 @@
ifeq ($(prebuilt_module_is_dex_javalib),true)
my_dex_jar := $(my_prebuilt_src_file)
-my_manifest_or_apk := $(my_prebuilt_src_file)
# This is a target shared library, i.e. a jar with classes.dex.
$(foreach pair,$(PRODUCT_BOOT_JARS), \
diff --git a/core/main.mk b/core/main.mk
index 56950ec..c9fa148 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -290,11 +290,25 @@
ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
endif
+ifneq ($(TARGET_BUILD_VARIANT),user)
+ ifdef PRODUCT_SET_DEBUGFS_RESTRICTIONS
+ ADDITIONAL_VENDOR_PROPERTIES += \
+ ro.product.debugfs_restrictions.enabled=$(PRODUCT_SET_DEBUGFS_RESTRICTIONS)
+ endif
+endif
+
# Vendors with GRF must define BOARD_SHIPPING_API_LEVEL for the vendor API level.
# This must not be defined for the non-GRF devices.
ifdef BOARD_SHIPPING_API_LEVEL
ADDITIONAL_VENDOR_PROPERTIES += \
ro.board.first_api_level=$(BOARD_SHIPPING_API_LEVEL)
+
+# To manually set the vendor API level of the vendor modules, BOARD_API_LEVEL can be used.
+# The values of the GRF properties will be verified by post_process_props.py
+ifdef BOARD_API_LEVEL
+ADDITIONAL_VENDOR_PROPERTIES += \
+ ro.board.api_level=$(BOARD_API_LEVEL)
+endif
endif
ADDITIONAL_VENDOR_PROPERTIES += \
@@ -900,7 +914,7 @@
# Scan all modules in general-tests, device-tests and other selected suites and
# flatten the shared library dependencies.
define update-host-shared-libs-deps-for-suites
-$(foreach suite,general-tests device-tests vts art-host-tests host-unit-tests,\
+$(foreach suite,general-tests device-tests vts tvts art-host-tests host-unit-tests,\
$(foreach m,$(COMPATIBILITY.$(suite).MODULES),\
$(eval my_deps := $(call get-all-shared-libs-deps,$(m)))\
$(foreach dep,$(my_deps),\
@@ -1573,6 +1587,8 @@
$(INSTALLED_SUPERIMAGE_EMPTY_TARGET) \
$(INSTALLED_PRODUCTIMAGE_TARGET) \
$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
+ $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
+ $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
$(INSTALLED_FILES_FILE) \
$(INSTALLED_FILES_JSON) \
$(INSTALLED_FILES_FILE_VENDOR) \
@@ -1692,6 +1708,7 @@
$(PROGUARD_USAGE_ZIP) \
$(COVERAGE_ZIP) \
$(APPCOMPAT_ZIP) \
+ $(DEXPREOPT_CONFIG_ZIP) \
$(INSTALLED_FILES_FILE) \
$(INSTALLED_FILES_JSON) \
$(INSTALLED_FILES_FILE_VENDOR) \
@@ -1750,14 +1767,12 @@
$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK) \
$(INSTALLED_DEBUG_RAMDISK_TARGET) \
$(INSTALLED_DEBUG_BOOTIMAGE_TARGET) \
+ $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
+ $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \
$(INSTALLED_VENDOR_RAMDISK_TARGET) \
$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \
)
- $(call dist-for-goals, bootimage_test_harness, \
- $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
- $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
- )
endif
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
diff --git a/core/product.mk b/core/product.mk
index 11a63e3..015fe44 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -341,6 +341,9 @@
# This flag implies PRODUCT_USE_DYNAMIC_PARTITIONS.
_product_single_value_vars += PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
+# When this is true, various build time as well as runtime debugfs restrictions are enabled.
+_product_single_value_vars += PRODUCT_SET_DEBUGFS_RESTRICTIONS
+
# Other dynamic partition feature flags.PRODUCT_USE_DYNAMIC_PARTITION_SIZE and
# PRODUCT_BUILD_SUPER_PARTITION default to the value of PRODUCT_USE_DYNAMIC_PARTITIONS.
_product_single_value_vars += \
@@ -384,13 +387,11 @@
_product_single_value_vars += PRODUCT_BUILD_BOOT_IMAGE
_product_single_value_vars += PRODUCT_BUILD_VENDOR_BOOT_IMAGE
_product_single_value_vars += PRODUCT_BUILD_VBMETA_IMAGE
+_product_single_value_vars += PRODUCT_BUILD_SUPER_EMPTY_IMAGE
# List of boot jars delivered via apex
_product_list_vars += PRODUCT_UPDATABLE_BOOT_JARS
-# Whether the product would like to check prebuilt ELF files.
-_product_single_value_vars += PRODUCT_CHECK_ELF_FILES
-
# If set, device uses virtual A/B.
_product_single_value_vars += PRODUCT_VIRTUAL_AB_OTA
diff --git a/core/product_config.mk b/core/product_config.mk
index d703ee3..eb6f69f 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -359,6 +359,14 @@
endif
endif
+ifeq ($(PRODUCT_SET_DEBUGFS_RESTRICTIONS),)
+ ifdef PRODUCT_SHIPPING_API_LEVEL
+ ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),31))
+ PRODUCT_SET_DEBUGFS_RESTRICTIONS := true
+ endif
+ endif
+endif
+
ifdef PRODUCT_SHIPPING_API_LEVEL
ifneq (,$(call math_gt_or_eq,29,$(PRODUCT_SHIPPING_API_LEVEL)))
PRODUCT_PACKAGES += $(PRODUCT_PACKAGES_SHIPPING_API_LEVEL_29)
diff --git a/core/product_config.rbc b/core/product_config.rbc
new file mode 100644
index 0000000..111e759
--- /dev/null
+++ b/core/product_config.rbc
@@ -0,0 +1,489 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//build/make/core:envsetup.rbc", _envsetup_init = "init")
+
+"""Runtime functions."""
+
+def _global_init():
+ """Returns dict created from the runtime environment."""
+ globals = dict()
+
+ # Environment variables
+ for k in dir(rblf_env):
+ globals[k] = getattr(rblf_env, k)
+
+ # Variables set as var=value command line arguments
+ for k in dir(rblf_cli):
+ globals[k] = getattr(rblf_cli, k)
+
+ globals.setdefault("PRODUCT_SOONG_NAMESPACES", [])
+ _envsetup_init(globals)
+
+ # Variables that should be defined.
+ mandatory_vars = [
+ "PLATFORM_VERSION_CODENAME",
+ "PLATFORM_VERSION",
+ "PRODUCT_SOONG_NAMESPACES",
+ # TODO(asmundak): do we need TARGET_ARCH? AOSP does not reference it
+ "TARGET_BUILD_TYPE",
+ "TARGET_BUILD_VARIANT",
+ "TARGET_PRODUCT",
+ ]
+ for bv in mandatory_vars:
+ if not bv in globals:
+ fail(bv, " is not defined")
+
+ return globals
+
+_globals_base = _global_init()
+
+def __print_attr(attr, value):
+ if not value:
+ return
+ if type(value) == "list":
+ if _options.rearrange:
+ value = __printvars_rearrange_list(value)
+ if _options.format == "pretty":
+ print(attr, "=", repr(value))
+ elif _options.format == "make":
+ print(attr, ":=", " ".join(value))
+ elif _options.format == "pretty":
+ print(attr, "=", repr(value))
+ elif _options.format == "make":
+ print(attr, ":=", value)
+ else:
+ fail("bad output format", _options.format)
+
+def _printvars(globals, cfg):
+ """Prints known configuration variables."""
+ for attr, val in sorted(cfg.items()):
+ __print_attr(attr, val)
+ if _options.print_globals:
+ print()
+ for attr, val in sorted(globals.items()):
+ if attr not in _globals_base:
+ __print_attr(attr, val)
+
+def __printvars_rearrange_list(value_list):
+ """Rearrange value list: return only distinct elements, maybe sorted."""
+ seen = {item: 0 for item in value_list}
+ return sorted(seen.keys()) if _options.rearrange == "sort" else seen.keys()
+
+def _product_configuration(top_pcm_name, top_pcm):
+ """Creates configuration."""
+
+ # Product configuration is created by traversing product's inheritance
+ # tree. It is traversed twice.
+ # First, beginning with top-level module we execute a module and find
+ # its ancestors, repeating this recursively. At the end of this phase
+ # we get the full inheritance tree.
+ # Second, we traverse the tree in the postfix order (i.e., visiting a
+ # node after its ancestors) to calculate the product configuration.
+ #
+ # PCM means "Product Configuration Module", i.e., a Starlark file
+ # whose body consists of a single init function.
+
+ globals = dict(**_globals_base)
+
+ config_postfix = [] # Configs in postfix order
+
+ # Each PCM is represented by a quadruple of function, config, children names
+ # and readyness (that is, the configurations from inherited PCMs have been
+ # substituted).
+ configs = {top_pcm_name: (top_pcm, None, [], False)} # All known PCMs
+
+ stash = [] # Configs to push once their descendants are done
+
+ # Stack containing PCMs to be processed. An item in the stack
+ # is a pair of PCMs name and its height in the product inheritance tree.
+ pcm_stack = [(top_pcm_name, 0)]
+ pcm_count = 0
+
+ # Run it until pcm_stack is exhausted, but no more than N times
+ for n in range(1000):
+ if not pcm_stack:
+ break
+ (name, height) = pcm_stack.pop()
+ pcm, cfg, c, _ = configs[name]
+
+ # cfg is set only after PCM has been called, leverage this
+ # to prevent calling the same PCM twice
+ if cfg != None:
+ continue
+
+ # Push ancestors until we reach this node's height
+ config_postfix.extend([stash.pop() for i in range(len(stash) - height)])
+
+ # Run this one, obtaining its configuration and child PCMs.
+ if _options.trace_modules:
+ print("%d:" % n)
+
+ # Run PCM.
+ handle = __h_new()
+ pcm(globals, handle)
+
+ # Now we know everything about this PCM, record it in 'configs'.
+ children = __h_inherited_modules(handle)
+ if _options.trace_modules:
+ print(" ", " ".join(children.keys()))
+ configs[name] = (pcm, __h_cfg(handle), children.keys(), False)
+ pcm_count = pcm_count + 1
+
+ if len(children) == 0:
+ # Leaf PCM goes straight to the config_postfix
+ config_postfix.append(name)
+ continue
+
+ # Stash this PCM, process children in the sorted order
+ stash.append(name)
+ for child_name in sorted(children, reverse = True):
+ if child_name not in configs:
+ configs[child_name] = (children[child_name], None, [], False)
+ pcm_stack.append((child_name, len(stash)))
+ if pcm_stack:
+ fail("Inheritance processing took too many iterations")
+
+ # Flush the stash
+ config_postfix.extend([stash.pop() for i in range(len(stash))])
+ if len(config_postfix) != pcm_count:
+ fail("Ran %d modules but postfix tree has only %d entries" % (pcm_count, len(config_postfix)))
+
+ if _options.trace_modules:
+ print("\n---Postfix---")
+ for x in config_postfix:
+ print(" ", x)
+
+ # Traverse the tree from the bottom, evaluating inherited values
+ for pcm_name in config_postfix:
+ pcm, cfg, children_names, ready = configs[pcm_name]
+
+ # Should run
+ if cfg == None:
+ fail("%s: has not been run" % pcm_name)
+
+ # Ready once
+ if ready:
+ continue
+
+ # Children should be ready
+ for child_name in children_names:
+ if not configs[child_name][3]:
+ fail("%s: child is not ready" % child_name)
+
+ _substitute_inherited(configs, pcm_name, cfg)
+ _percolate_inherited(configs, pcm_name, cfg, children_names)
+ configs[pcm_name] = pcm, cfg, children_names, True
+
+ return globals, configs[top_pcm_name][1]
+
+def _substitute_inherited(configs, pcm_name, cfg):
+ """Substitutes inherited values in all the attributes.
+
+ When a value of an attribute is a list, some of its items may be
+ references to a value of a same attribute in an inherited product,
+ e.g., for a given module PRODUCT_PACKAGES can be
+ ["foo", (submodule), "bar"]
+ and for 'submodule' PRODUCT_PACKAGES may be ["baz"]
+ (we use a tuple to distinguish submodule references).
+ After the substitution the value of PRODUCT_PACKAGES for the module
+ will become ["foo", "baz", "bar"]
+ """
+ for attr, val in cfg.items():
+ # TODO(asmundak): should we handle single vars?
+ if type(val) != "list":
+ continue
+
+ if attr not in _options.trace_variables:
+ cfg[attr] = _value_expand(configs, attr, val)
+ else:
+ old_val = val
+ new_val = _value_expand(configs, attr, val)
+ if new_val != old_val:
+ print("%s(i): %s=%s (was %s)" % (pcm_name, attr, new_val, old_val))
+ cfg[attr] = new_val
+
+def _value_expand(configs, attr, values_list):
+ """Expands references to inherited values in a given list."""
+ result = []
+ expanded = {}
+ for item in values_list:
+ # Inherited values are 1-tuples
+ if type(item) != "tuple":
+ result.append(item)
+ continue
+ child_name = item[0]
+ if child_name in expanded:
+ continue
+ expanded[child_name] = True
+ child = configs[child_name]
+ if not child[3]:
+ fail("%s should be ready" % child_name)
+ __move_items(result, child[1], attr)
+
+ return result
+
+def _percolate_inherited(configs, cfg_name, cfg, children_names):
+ """Percolates the settings that are present only in children."""
+ percolated_attrs = {}
+ for child_name in children_names:
+ child_cfg = configs[child_name][1]
+ for attr, value in child_cfg.items():
+ if type(value) != "list":
+ if attr in percolated_attrs or not attr in cfg:
+ cfg[attr] = value
+ percolated_attrs[attr] = True
+ continue
+ if attr in percolated_attrs:
+ # We already are percolating this one, just add this list
+ __move_items(cfg[attr], child_cfg, attr)
+ elif not attr in cfg:
+ percolated_attrs[attr] = True
+ cfg[attr] = []
+ __move_items(cfg[attr], child_cfg, attr)
+
+ for attr in _options.trace_variables:
+ if attr in percolated_attrs:
+ print("%s: %s^=%s" % (cfg_name, attr, cfg[attr]))
+
+def __move_items(to_list, from_cfg, attr):
+ value = from_cfg.get(attr, [])
+ if value:
+ to_list.extend(value)
+ from_cfg[attr] = []
+
+def _indirect(pcm_name):
+ """Returns configuration item for the inherited module."""
+ return (pcm_name,)
+
+def _addprefix(prefix, string_or_list):
+ """Adds prefix and returns a list.
+
+ If string_or_list is a list, prepends prefix to each element.
+ Otherwise, string_or_list is considered to be a string which
+ is split into words and then prefix is prepended to each one.
+
+ Args:
+ prefix
+ string_or_list
+
+ """
+ return [prefix + x for x in __words(string_or_list)]
+
+def _addsuffix(suffix, string_or_list):
+ """Adds suffix and returns a list.
+
+ If string_or_list is a list, appends suffix to each element.
+ Otherwise, string_or_list is considered to be a string which
+ is split into words and then suffix is appended to each one.
+
+ Args:
+ suffix
+ string_or_list
+ """
+ return [x + suffix for x in __words(string_or_list)]
+
+def __words(string_or_list):
+ if type(string_or_list) == "list":
+ return string_or_list
+ return string_or_list.split()
+
+# Handle manipulation functions.
+# A handle passed to a PCM consists of:
+# product attributes dict ("cfg")
+# inherited modules dict (maps module name to PCM)
+# default value list (initially empty, modified by inheriting)
+def __h_new():
+ """Constructs a handle which is passed to PCM."""
+ return (dict(), dict(), list())
+
+def __h_inherited_modules(handle):
+ """Returns PCM's inherited modules dict."""
+ return handle[1]
+
+def __h_cfg(handle):
+ """Returns PCM's product configuration attributes dict.
+
+ This function is also exported as rblf.cfg, and every PCM
+ calls it at the beginning.
+ """
+ return handle[0]
+
+def _setdefault(handle, attr):
+ """If attribute has not been set, assigns default value to it.
+
+ This function is exported as rblf.setdefault().
+ Only list attributes are initialized this way. The default
+ value is kept in the PCM's handle. Calling inherit() updates it.
+ """
+ cfg = handle[0]
+ if cfg.get(attr) == None:
+ cfg[attr] = list(handle[2])
+ return cfg[attr]
+
+def _inherit(handle, pcm_name, pcm):
+ """Records inheritance.
+
+ This function is exported as rblf.inherit, PCM calls it when
+ a module is inherited.
+ """
+ cfg, inherited, default_lv = handle
+ inherited[pcm_name] = pcm
+ default_lv.append(_indirect(pcm_name))
+
+ # Add inherited module reference to all configuration values
+ for attr, val in cfg.items():
+ if type(val) == "list":
+ val.append(_indirect(pcm_name))
+
+def _copy_if_exists(path_pair):
+ """If from file exists, returns [from:to] pair."""
+ value = path_pair.split(":", 2)
+
+ # Check that l[0] exists
+ return [":".join(value)] if rblf_file_exists(value[0]) else []
+
+def _enforce_product_packages_exist(pkg_string_or_list):
+ """Makes including non-existent modules in PRODUCT_PACKAGES an error."""
+
+ #TODO(asmundak)
+ pass
+
+def _file_wildcard_exists(file_pattern):
+ """Return True if there are files matching given bash pattern."""
+ return len(rblf_wildcard(file_pattern)) > 0
+
+def _find_and_copy(pattern, from_dir, to_dir):
+ """Return a copy list for the files matching the pattern."""
+ return ["%s/%s:%s/%s" % (from_dir, f, to_dir, f) for f in rblf_wildcard(pattern, from_dir)]
+
+def _filter_out(pattern, text):
+ """Return all the words from `text' that do not match any word in `pattern'.
+
+ Args:
+ pattern: string or list of words. '%' stands for wildcard (in regex terms, '.*')
+ text: string or list of words
+ Return:
+ list of words
+ """
+ rex = __mk2regex(__words(pattern))
+ res = []
+ for w in __words(text):
+ if not _regex_match(rex, w):
+ res.append(w)
+ return res
+
+def _filter(pattern, text):
+ """Return all the words in `text` that match `pattern`.
+
+ Args:
+ pattern: strings of words or a list. A word can contain '%',
+ which stands for any sequence of characters.
+ text: string or list of words.
+ """
+ rex = __mk2regex(__words(pattern))
+ res = []
+ for w in __words(text):
+ if _regex_match(rex, w):
+ res.append(w)
+ return res
+
+def __mk2regex(words):
+ """Returns regular expression equivalent to Make pattern."""
+
+ # TODO(asmundak): this will mishandle '\%'
+ return "^(" + "|".join([w.replace("%", ".*", 1) for w in words]) + ")"
+
+def _regex_match(regex, w):
+ return rblf_regex(regex, w)
+
+def _require_artifacts_in_path(paths, allowed_paths):
+ """TODO."""
+ pass
+
+def _require_artifacts_in_path_relaxed(paths, allowed_paths):
+ """TODO."""
+ pass
+
+def _expand_wildcard(pattern):
+ """Expands shell wildcard pattern."""
+ return rblf_wildcard(pattern)
+
+def _mkerror(file, message = ""):
+ """Prints error and stops."""
+ fail("%s: %s. Stop" % (file, message))
+
+def _mkwarning(file, message = ""):
+ """Prints warning."""
+ print("%s: warning: %s" % (file, message))
+
+def _mkinfo(file, message = ""):
+ """Prints info."""
+ print(message)
+
+def __get_options():
+ """Returns struct containing runtime global settings."""
+ settings = dict(
+ format = "pretty",
+ print_globals = False,
+ rearrange = "",
+ trace_modules = False,
+ trace_variables = [],
+ )
+ for x in getattr(rblf_cli, "RBC_OUT", "").split(","):
+ if x == "sort" or x == "unique":
+ if settings["rearrange"]:
+ fail("RBC_OUT: either sort or unique is allowed (and sort implies unique)")
+ settings["rearrange"] = x
+ elif x == "pretty" or x == "make":
+ settings["format"] = x
+ elif x == "global":
+ settings["print_globals"] = True
+ elif x != "":
+ fail("RBC_OUT: got %s, should be one of: [pretty|make] [sort|unique]" % x)
+ for x in getattr(rblf_cli, "RBC_DEBUG", "").split(","):
+ if x == "!trace":
+ settings["trace_modules"] = True
+ elif x != "":
+ settings["trace_variables"].append(x)
+ return struct(**settings)
+
+# Settings used during debugging.
+_options = __get_options()
+rblf = struct(
+ addprefix = _addprefix,
+ addsuffix = _addsuffix,
+ copy_if_exists = _copy_if_exists,
+ cfg = __h_cfg,
+ enforce_product_packages_exist = _enforce_product_packages_exist,
+ expand_wildcard = _expand_wildcard,
+ file_exists = rblf_file_exists,
+ file_wildcard_exists = _file_wildcard_exists,
+ filter = _filter,
+ filter_out = _filter_out,
+ find_and_copy = _find_and_copy,
+ global_init = _global_init,
+ inherit = _inherit,
+ indirect = _indirect,
+ mkinfo = _mkinfo,
+ mkerror = _mkerror,
+ mkwarning = _mkwarning,
+ printvars = _printvars,
+ product_configuration = _product_configuration,
+ require_artifacts_in_path = _require_artifacts_in_path,
+ require_artifacts_in_path_relaxed = _require_artifacts_in_path_relaxed,
+ setdefault = _setdefault,
+ shell = rblf_shell,
+ warning = _mkwarning,
+)
diff --git a/core/rust_device_benchmark_config_template.xml b/core/rust_device_benchmark_config_template.xml
new file mode 100644
index 0000000..2055df2
--- /dev/null
+++ b/core/rust_device_benchmark_config_template.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- This test config file is auto-generated. -->
+<configuration description="Config to run {MODULE} rust benchmark tests.">
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="false" />
+ <option name="push" value="{MODULE}->/data/local/tmp/{MODULE}" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.rust.RustBinaryTest" >
+ <option name="test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="{MODULE}" />
+ <option name="is-benchmark" value="true" />
+ </test>
+</configuration>
diff --git a/core/rust_host_benchmark_config_template.xml b/core/rust_host_benchmark_config_template.xml
new file mode 100644
index 0000000..bb7c1b5
--- /dev/null
+++ b/core/rust_host_benchmark_config_template.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Config to run {MODULE} rust benchmark host tests">
+ <test class="com.android.tradefed.testtype.rust.RustBinaryHostTest" >
+ <option name="test-file" value="{MODULE}" />
+ <option name="test-timeout" value="5m" />
+ <option name="is-benchmark" value="true" />
+ </test>
+</configuration>
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index 12b7f44..139de10 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -39,7 +39,6 @@
else
my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
endif
-my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
ifeq ($(LOCAL_NO_CRT),true)
my_target_crtbegin_so_o :=
my_target_crtend_so_o :=
@@ -55,7 +54,6 @@
my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so.sdk.$(my_ndk_crt_version))
endif
$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
-$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
@@ -65,7 +63,6 @@
$(my_target_crtbegin_so_o) \
$(my_target_crtend_so_o) \
$(my_target_libcrt_builtins) \
- $(my_target_libatomic) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(CLANG_CXX)
$(transform-o-to-shared-lib)
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
index 50ac93a..b7c21b8 100644
--- a/core/soong_app_prebuilt.mk
+++ b/core/soong_app_prebuilt.mk
@@ -7,12 +7,13 @@
# LOCAL_SOONG_HEADER_JAR
# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
# LOCAL_SOONG_PROGUARD_DICT
-# LOCAL_SOONG_PROGUARD_USAGE
+# LOCAL_SOONG_PROGUARD_USAGE_ZIP
# LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
# LOCAL_SOONG_RRO_DIRS
# LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
# LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
# LOCAL_SOONG_JNI_LIBS_SYMBOLS
+# LOCAL_SOONG_DEXPREOPT_CONFIG
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call pretty-error,soong_app_prebuilt.mk may only be used from Soong)
@@ -49,6 +50,14 @@
.PHONY: javac-check-$(LOCAL_MODULE)
endif
+ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
+ my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
+ $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
+endif
+
+
+
# Run veridex on product, system_ext and vendor modules.
# We skip it for unbundled app builds where we cannot build veridex.
module_run_appcompat :=
@@ -74,23 +83,31 @@
ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
$(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
- $(intermediates.COMMON)/jacoco-report-classes.jar))
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar))
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
- $(intermediates.COMMON)/jacoco-report-classes.jar)
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)
endif
ifdef LOCAL_SOONG_PROGUARD_DICT
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
$(intermediates.COMMON)/proguard_dictionary))
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar))
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
$(intermediates.COMMON)/proguard_dictionary)
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar)
endif
ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\
- $(intermediates.COMMON)/proguard_usage.zip))
+ $(call local-packaging-dir,proguard_usage)/proguard_usage.zip))
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
- $(intermediates.COMMON)/proguard_usage.zip)
+ $(call local-packaging-dir,proguard_usage)/proguard_usage.zip)
endif
ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 79ec22c..ec67560 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -166,8 +166,6 @@
$(call add_json_bool, Treble_linker_namespaces, $(filter true,$(PRODUCT_TREBLE_LINKER_NAMESPACES)))
$(call add_json_bool, Enforce_vintf_manifest, $(filter true,$(PRODUCT_ENFORCE_VINTF_MANIFEST)))
-$(call add_json_bool, Check_elf_files, $(filter true,$(PRODUCT_CHECK_ELF_FILES)))
-
$(call add_json_bool, Uml, $(filter true,$(TARGET_USER_MODE_LINUX)))
$(call add_json_str, VendorPath, $(TARGET_COPY_OUT_VENDOR))
$(call add_json_str, OdmPath, $(TARGET_COPY_OUT_ODM))
@@ -242,7 +240,7 @@
$(call add_json_bool, InstallExtraFlattenedApexes, $(PRODUCT_INSTALL_EXTRA_FLATTENED_APEXES))
-$(call add_json_bool, CompressedApex, $(PRODUCT_COMPRESSED_APEX))
+$(call add_json_bool, CompressedApex, $(filter true,$(PRODUCT_COMPRESSED_APEX)))
$(call add_json_bool, BoardUsesRecoveryAsBoot, $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
@@ -258,6 +256,8 @@
$(call add_json_bool, BuildBrokenTrebleSyspropNeverallow, $(filter true,$(BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW)))
$(call add_json_bool, BuildBrokenVendorPropertyNamespace, $(filter true,$(BUILD_BROKEN_VENDOR_PROPERTY_NAMESPACE)))
+$(call add_json_bool, BuildDebugfsRestrictionsEnabled, $(filter true,$(PRODUCT_SET_DEBUGFS_RESTRICTIONS)))
+
$(call add_json_bool, RequiresInsecureExecmemForSwiftshader, $(filter true,$(PRODUCT_REQUIRES_INSECURE_EXECMEM_FOR_SWIFTSHADER)))
$(call add_json_bool, SelinuxIgnoreNeverallows, $(filter true,$(SELINUX_IGNORE_NEVERALLOWS)))
diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk
index c600178..1ebbf14 100644
--- a/core/soong_java_prebuilt.mk
+++ b/core/soong_java_prebuilt.mk
@@ -47,23 +47,31 @@
ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
$(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
- $(intermediates.COMMON)/jacoco-report-classes.jar))
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar))
$(call add-dependency,$(common_javalib.jar),\
- $(intermediates.COMMON)/jacoco-report-classes.jar)
+ $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)
endif
ifdef LOCAL_SOONG_PROGUARD_DICT
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
$(intermediates.COMMON)/proguard_dictionary))
- $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar))
+ $(call add-dependency,$(common_javalib.jar),\
$(intermediates.COMMON)/proguard_dictionary)
+ $(call add-dependency,$(common_javalib.jar),\
+ $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
+ $(call add-dependency,$(common_javalib.jar),\
+ $(call local-packaging-dir,proguard_dictionary)/classes.jar)
endif
-ifdef LOCAL_SOONG_PROGUARD_USAGE
+ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\
- $(intermediates.COMMON)/proguard_usage.zip))
- $(call add-dependency,$(LOCAL_BUILT_MODULE),\
- $(intermediates.COMMON)/proguard_usage.zip)
+ $(call local-packaging-dir,proguard_usage)/proguard_usage.zip))
+ $(call add-dependency,$(common_javalib.jar),\
+ $(call local-packaging-dir,proguard_usage)/proguard_usage.zip)
endif
@@ -120,9 +128,11 @@
$(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar)))
$(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(common_javalib.jar)))
- $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar)))
- ifneq ($(TURBINE_ENABLED),false)
- $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar)))
+ ifdef LOCAL_SOONG_CLASSES_JAR
+ $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar)))
+ ifneq ($(TURBINE_ENABLED),false)
+ $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar)))
+ endif
endif
endif
@@ -151,10 +161,15 @@
# modules can find them.
ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
$(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(call local-intermediates-dir,)/dexpreopt.config))
+ my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
+ $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
endif
+ifdef LOCAL_SOONG_CLASSES_JAR
javac-check : $(full_classes_jar)
javac-check-$(LOCAL_MODULE) : $(full_classes_jar)
+endif
.PHONY: javac-check-$(LOCAL_MODULE)
ifndef LOCAL_IS_HOST_MODULE
diff --git a/core/soong_rust_prebuilt.mk b/core/soong_rust_prebuilt.mk
index 4cfb01f..c382f6a 100644
--- a/core/soong_rust_prebuilt.mk
+++ b/core/soong_rust_prebuilt.mk
@@ -40,17 +40,58 @@
include $(BUILD_SYSTEM)/base_rules.mk
#######################################
+ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES RLIB_LIBRARIES DYLIB_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+ # Soong module is a static or shared library
+ EXPORTS_LIST += $(intermediates)
+ EXPORTS.$(intermediates).FLAGS := $(LOCAL_EXPORT_CFLAGS)
+ EXPORTS.$(intermediates).DEPS := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
+
+ 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
+ ifneq ($(LOCAL_VNDK_DEPEND_ON_CORE_VARIANT),true)
+ name_without_suffix := $(patsubst %.vendor,%,$(LOCAL_MODULE))
+ ifneq ($(name_without_suffix),$(LOCAL_MODULE))
+ SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1
+ else
+ name_without_suffix := $(patsubst %.product,%,$(LOCAL_MODULE))
+ ifneq ($(name_without_suffix),$(LOCAL_MODULE))
+ SPLIT_PRODUCT.$(LOCAL_MODULE_CLASS).$(name_without_suffix) := 1
+ endif
+ endif
+ name_without_suffix :=
+ endif
+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))
endif
ifdef LOCAL_DYLIB_LIBRARIES
my_dylibs := $(LOCAL_DYLIB_LIBRARIES)
# Treat these as shared library dependencies for installation purposes.
+ ifdef LOCAL_USE_VNDK
+ my_dylibs := $(foreach l,$(my_dylibs),\
+ $(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_dylibs))
endif
diff --git a/core/sysprop.mk b/core/sysprop.mk
index 359d3d2..daebdd3 100644
--- a/core/sysprop.mk
+++ b/core/sysprop.mk
@@ -122,7 +122,7 @@
echo "$$(line)" >> $$@;\
)\
)
- $(hide) $(POST_PROCESS_PROPS) $$(_option) $$@ $(5)
+ $(hide) $(POST_PROCESS_PROPS) $$(_option) --sdk-version $(PLATFORM_SDK_VERSION) $$@ $(5)
$(hide) $(foreach file,$(strip $(6)),\
if [ -f "$(file)" ]; then\
cat $(file) >> $$@;\
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index c9e3e80..4138277 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -240,7 +240,7 @@
# It must be of the form "YYYY-MM-DD" on production devices.
# It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
# If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
- PLATFORM_SECURITY_PATCH := 2021-03-05
+ PLATFORM_SECURITY_PATCH := 2021-04-05
endif
.KATI_READONLY := PLATFORM_SECURITY_PATCH
diff --git a/envsetup.sh b/envsetup.sh
index 344a01a..b5c729d 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -9,6 +9,9 @@
build, and stores those selections in the environment to be read by subsequent
invocations of 'm' etc.
- tapas: tapas [<App1> <App2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
+ Sets up the build environment for building unbundled apps (APKs).
+- banchan: banchan <module1> [<module2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
+ Sets up the build environment for building unbundled modules (APEXes).
- croot: Changes directory to the top of the tree, or a subdirectory thereof.
- m: Makes from the top of the tree.
- mm: Builds and installs all of the modules in the current directory, and their
@@ -108,7 +111,7 @@
if [ "$BUILD_VAR_CACHE_READY" = "true" ]
then
eval "echo \"\${abs_var_cache_$1}\""
- return
+ return
fi
local T=$(gettop)
@@ -605,7 +608,7 @@
{
local uname=$(uname)
local choices
- choices=$(TARGET_BUILD_APPS= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null)
+ choices=$(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_BUILD_VARIANT= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null)
local ret=$?
echo
@@ -791,6 +794,60 @@
destroy_build_var_cache
}
+# Configures the build to build unbundled Android modules (APEXes).
+# Run banchan with one or more module names (from apex{} modules).
+function banchan()
+{
+ local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)"
+ local product="$(echo $* | xargs -n 1 echo | \grep -E '^(.*_)?(arm|x86|arm64|x86_64)$' | xargs)"
+ local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
+ local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|(.*_)?(arm|x86|arm64|x86_64))$' | xargs)"
+
+ if [ "$showHelp" != "" ]; then
+ $(gettop)/build/make/banchanHelp.sh
+ return
+ fi
+
+ if [ -z "$product" ]; then
+ product=arm
+ elif [ $(echo $product | wc -w) -gt 1 ]; then
+ echo "banchan: Error: Multiple build archs or products supplied: $products"
+ return
+ fi
+ if [ $(echo $variant | wc -w) -gt 1 ]; then
+ echo "banchan: Error: Multiple build variants supplied: $variant"
+ return
+ fi
+ if [ -z "$apps" ]; then
+ echo "banchan: Error: No modules supplied"
+ return
+ fi
+
+ case $product in
+ arm) product=module_arm;;
+ x86) product=module_x86;;
+ arm64) product=module_arm64;;
+ x86_64) product=module_x86_64;;
+ esac
+ if [ -z "$variant" ]; then
+ variant=eng
+ fi
+
+ export TARGET_PRODUCT=$product
+ export TARGET_BUILD_VARIANT=$variant
+ export TARGET_BUILD_DENSITY=alldpi
+ export TARGET_BUILD_TYPE=release
+
+ # This setup currently uses TARGET_BUILD_APPS just like tapas, but the use
+ # case is different and it may diverge in the future.
+ export TARGET_BUILD_APPS=$apps
+
+ build_build_var_cache
+ set_stuff_for_environment
+ printconfig
+ destroy_build_var_cache
+}
+
function gettop
{
local TOPFILE=build/make/core/envsetup.mk
diff --git a/help.sh b/help.sh
index bdb078f..06a9056 100755
--- a/help.sh
+++ b/help.sh
@@ -18,7 +18,7 @@
See '"${SCRIPT_DIR}"'/Usage.txt for more info about build usage and concepts.
The parallelism of the build can be set with a -jN argument to "m". If you
-don't provide a -j argument, the build system automatically selects a parallel
+don'\''t provide a -j argument, the build system automatically selects a parallel
task count that it thinks is optimal for your system.
Common goals are:
diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk
index 342abd7..845225d 100644
--- a/target/board/BoardConfigEmuCommon.mk
+++ b/target/board/BoardConfigEmuCommon.mk
@@ -74,7 +74,7 @@
#vendor boot
BOARD_INCLUDE_DTB_IN_BOOTIMG := false
-BOARD_BOOT_HEADER_VERSION := 3
+BOARD_BOOT_HEADER_VERSION := 4
BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE := 0x06000000
BOARD_RAMDISK_USE_LZ4 := true
diff --git a/target/board/BoardConfigModuleCommon.mk b/target/board/BoardConfigModuleCommon.mk
index 24c01a5..9832474 100644
--- a/target/board/BoardConfigModuleCommon.mk
+++ b/target/board/BoardConfigModuleCommon.mk
@@ -4,3 +4,7 @@
# 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/board/emulator_arm64/BoardConfig.mk b/target/board/emulator_arm64/BoardConfig.mk
index 9293625..963e558 100644
--- a/target/board/emulator_arm64/BoardConfig.mk
+++ b/target/board/emulator_arm64/BoardConfig.mk
@@ -57,9 +57,6 @@
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x02000000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
-BOARD_BOOT_HEADER_VERSION := 3
-BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
-
# Wifi.
BOARD_WLAN_DEVICE := emulator
BOARD_HOSTAPD_DRIVER := NL80211
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 30c033d..15c311c 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -74,9 +74,13 @@
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
BOARD_RAMDISK_USE_LZ4 := true
-BOARD_BOOT_HEADER_VERSION := 3
+BOARD_BOOT_HEADER_VERSION := 4
BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
+# Enable GKI 2.0 signing.
+BOARD_GKI_SIGNING_KEY_PATH := build/make/target/product/gsi/testkey_rsa2048.pem
+BOARD_GKI_SIGNING_ALGORITHM := SHA256_RSA2048
+
BOARD_KERNEL_BINARIES := \
kernel-4.19-gz \
kernel-5.4 kernel-5.4-gz kernel-5.4-lz4 \
diff --git a/target/board/generic_arm64/device.mk b/target/board/generic_arm64/device.mk
index 37c0f25..27dc158 100644
--- a/target/board/generic_arm64/device.mk
+++ b/target/board/generic_arm64/device.mk
@@ -24,7 +24,12 @@
kernel/prebuilts/5.10/arm64/kernel-5.10-lz4:kernel-5.10-lz4 \
kernel/prebuilts/mainline/arm64/kernel-mainline-allsyms:kernel-mainline \
kernel/prebuilts/mainline/arm64/kernel-mainline-gz-allsyms:kernel-mainline-gz \
- kernel/prebuilts/mainline/arm64/kernel-mainline-lz4-allsyms:kernel-mainline-lz4
+ kernel/prebuilts/mainline/arm64/kernel-mainline-lz4-allsyms:kernel-mainline-lz4 \
+
+$(call dist-for-goals, dist_files, kernel/prebuilts/4.19/arm64/prebuilt-info.txt:kernel/4.19/prebuilt-info.txt)
+$(call dist-for-goals, dist_files, kernel/prebuilts/5.4/arm64/prebuilt-info.txt:kernel/5.4/prebuilt-info.txt)
+$(call dist-for-goals, dist_files, kernel/prebuilts/5.10/arm64/prebuilt-info.txt:kernel/5.10/prebuilt-info.txt)
+$(call dist-for-goals, dist_files, kernel/prebuilts/mainline/arm64/prebuilt-info.txt:kernel/mainline/prebuilt-info.txt)
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
PRODUCT_COPY_FILES += \
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index c87fb73..21beda9 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -116,7 +116,6 @@
iptables \
ip-up-vpn \
javax.obex \
- keystore \
keystore2 \
credstore \
ld.mc \
@@ -292,10 +291,16 @@
ifeq ($(EMMA_INSTRUMENT),true)
ifneq ($(EMMA_INSTRUMENT_STATIC),true)
# For instrumented build, if Jacoco is not being included statically
- # in instrumented packages then include Jacoco classes into the
- # bootclasspath.
+ # in instrumented packages then include Jacoco classes in the product
+ # packages.
PRODUCT_PACKAGES += jacocoagent
- PRODUCT_BOOT_JARS += jacocoagent
+ ifneq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
+ # For instrumented build, if Jacoco is not being included statically
+ # in instrumented packages and has not already been included in the
+ # bootclasspath via ART_APEX_JARS then include Jacoco classes into the
+ # bootclasspath.
+ PRODUCT_BOOT_JARS += jacocoagent
+ endif # EMMA_INSTRUMENT_FRAMEWORK
endif # EMMA_INSTRUMENT_STATIC
endif # EMMA_INSTRUMENT
@@ -385,11 +390,6 @@
SettingsProvider \
WallpaperBackup
-# Packages included only for eng/userdebug builds, when building with SANITIZE_TARGET=address
-PRODUCT_PACKAGES_DEBUG_ASAN := \
- fuzz \
- honggfuzz
-
PRODUCT_PACKAGES_DEBUG_JAVA_COVERAGE := \
libdumpcoverage
@@ -401,8 +401,4 @@
PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\
frameworks/base/config/dirty-image-objects:system/etc/dirty-image-objects)
-# This property allows enabling Keystore 2.0 selectively for testing.
-# TODO Remove when Keystore 2.0 migration is complete. b/171563717
-PRODUCT_SYSTEM_PROPERTIES += persist.android.security.keystore2.enable=true
-
$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk
index 1545780..bb17dda 100644
--- a/target/product/default_art_config.mk
+++ b/target/product/default_art_config.mk
@@ -39,16 +39,6 @@
com.android.tethering:framework-tethering \
com.android.ipsec:android.net.ipsec.ike
-# Add the compatibility library that is needed when android.test.base
-# is removed from the bootclasspath.
-# Default to excluding android.test.base from the bootclasspath.
-ifneq ($(REMOVE_ATB_FROM_BCP),false)
- PRODUCT_PACKAGES += framework-atb-backward-compatibility
- PRODUCT_BOOT_JARS += framework-atb-backward-compatibility
-else
- PRODUCT_BOOT_JARS += android.test.base
-endif
-
# Minimal configuration for running dex2oat (default argument values).
# PRODUCT_USES_DEFAULT_ART_CONFIG must be true to enable boot image compilation.
PRODUCT_USES_DEFAULT_ART_CONFIG := true
diff --git a/target/product/gsi/gsi_skip_mount.cfg b/target/product/gsi/gsi_skip_mount.cfg
index ad3c7d9..28f4349 100644
--- a/target/product/gsi/gsi_skip_mount.cfg
+++ b/target/product/gsi/gsi_skip_mount.cfg
@@ -1,3 +1,9 @@
+# Skip "system" mountpoints.
/oem
/product
/system_ext
+# Skip sub-mountpoints of system mountpoints.
+/oem/*
+/product/*
+/system_ext/*
+/system/*
diff --git a/target/product/gsi/testkey_rsa2048.pem b/target/product/gsi/testkey_rsa2048.pem
new file mode 100644
index 0000000..64de31c
--- /dev/null
+++ b/target/product/gsi/testkey_rsa2048.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEA3fDgwU4JKVRHhAfofi/g8daTNplB2mTJCX9fIMy9FnZDXNij
+1zijRQ8HKbt3bAGImQvb3GxSV4M5eIdiLDUF7RsUpE7K+s939i/AaTtcuyqimQbJ
+QjP9emTsgngHzuKWMg1mwlRZYDfdv62zIQmZcbM9a0CZE36hAYvEBiDB8qT4ob++
+godGAx3rpF2Wi7mhIYDINvkCw8/16Qi9CZgvOUrEolt3mz8Sps41z9j7YAsPbAa8
+fg7dUu61s6NkZEykl4G67loOaf7h+SyP//LpFZ0gV+STZ+EMGofL0SXb8A+hdIYE
+QxsnKUYo8e+GaQg92FLxVZqcfyG3AZuMB04R1QIDAQABAoIBAQDGj3/1UaSepjlJ
+ZW3an2lH1Cpm2ZxyEGNQLPVluead1vaTdXq3zYM9AKHu8zp3lbOpAVQVk4/jnZJo
+Q+9QD6waonTIP3oYBE+WIMirHSHsjctkzw52PV9VBkAWxd5ueIfZheXejGpdy/2H
+RJcTQqxWbf7QGr4ZE9xmLq4UsW/zbXwy8qGEp9eMQIIaWBua43FkqmWYLSnVFVJI
+Gl8mfVJctLNSZHhS3tKiV8up6NxZlDjO8o7kYVFCkv0xJ9yzQNBc3P2MEmvfZ06D
+QnimHBqSxr0M9X6hqP43CnqtCbpsHS8A12Dm4l6fkXfkrAY0UNrEaCSDb8aN7TEc
+7bc1MB4NAoGBAPK7xSuvQE9CH05Iy+G6mEQTtNmpfcQosqhi6dF60h4bqlkeGzUu
+gF/PKHwwffHAxQSv4V831P3A/IoJFa9IFkg218mYPNfzpj4vJA4aNCDp+SYZAIYm
+h6hMOmuByI97wds2yCBGt4mP0eow5B3A1b3UQeqW6LVSuobZ22QVlSk/AoGBAOoS
+L82yda9hUa7vuXtqTraf9EGjSXhyjoPqWxa+a1ooI9l24f7mokS5Iof+a/SLfPUj
+pwj8eOeOZksjAaWJIdrRb3TaYLaqhDkWQeV5N5XxYbn3+TvVJQyR+OSBfGoEpVP/
+IS6fusvpT3eULJDax10By+gDcoLT5M1FNs4rBIvrAoGBAM8yJP5DHDwLjzl9vjsy
+0iLaR3e8zBQTQV2nATvFAXKd3u0vW74rsX0XEdHgesFP8V0s3M4wlGj+wRL66j2y
+5QJDfjMg9l7IJlHSX46CI5ks33X7xYy9evLYDs4R/Kct1q5OtsmGU8jisSadETus
+jUb61kFvC7krovjVIgbuvWJ1AoGAVikzp4gVgeVU6AwePqu3JcpjYvX0SX4Br9VI
+imq1oY49BAOa1PWYratoZp7kpjPiX2osRkaJStNEHExagtCjwaRuXpk0GIlT+p+S
+yiGAsJUV4BrDh57B8IqbD6IKZgwnv2+ei0cIv562PdIxRXEDCd1rbZA3SqktA9KC
+hgmXttkCgYBPU1lqRpwoHP9lpOBTDa6/Xi6WaDEWrG/tUF/wMlvrZ4hEVMDJRs1d
+9JCXBxL/O4TMvpmyVKBZW15iZOcLM3EpiZ00UD+ChcAaFstup+oYKrs8gL9hgyTd
+cvWMxGQm13KwSj2CLzEQpPAN5xG14njXaee5ksshxkzBz9z3MVWiiw==
+-----END RSA PRIVATE KEY-----
diff --git a/target/product/gsi_release.mk b/target/product/gsi_release.mk
index 539dbfa..25fa68b 100644
--- a/target/product/gsi_release.mk
+++ b/target/product/gsi_release.mk
@@ -31,8 +31,10 @@
system/product/% \
system/system_ext/%
-# Split selinux policy
-PRODUCT_FULL_TREBLE_OVERRIDE := true
+# GSI should always support up-to-date platform features.
+# Keep this value at the latest API level to ensure latest build system
+# default configs are applied.
+PRODUCT_SHIPPING_API_LEVEL := 30
# Enable dynamic partitions to facilitate mixing onto Cuttlefish
PRODUCT_USE_DYNAMIC_PARTITIONS := true
@@ -65,3 +67,4 @@
PRODUCT_BUILD_USERDATA_IMAGE := false
PRODUCT_BUILD_VENDOR_IMAGE := false
PRODUCT_BUILD_SUPER_PARTITION := false
+PRODUCT_BUILD_SUPER_EMPTY_IMAGE := false
diff --git a/target/product/media_system.mk b/target/product/media_system.mk
index 143131e..c7ac907 100644
--- a/target/product/media_system.mk
+++ b/target/product/media_system.mk
@@ -57,6 +57,7 @@
# system server jars which are updated via apex modules.
# The values should be of the format <apex name>:<jar name>
PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS := \
+ com.android.art:service-art \
com.android.permission:service-permission \
PRODUCT_COPY_FILES += \
diff --git a/target/product/module_common.mk b/target/product/module_common.mk
index eedd479..03340db 100644
--- a/target/product/module_common.mk
+++ b/target/product/module_common.mk
@@ -16,3 +16,8 @@
$(call inherit-product, $(SRC_TARGET_DIR)/product/default_art_config.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_default.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/cfi-common.mk)
+
+# Enables treble, which enabled certain -D compilation flags. In particular, libhidlbase
+# uses -DENFORCE_VINTF_MANIFEST. See b/185759877
+PRODUCT_SHIPPING_API_LEVEL := 29
diff --git a/target/product/security/Android.bp b/target/product/security/Android.bp
index 98698c5..99f7742 100644
--- a/target/product/security/Android.bp
+++ b/target/product/security/Android.bp
@@ -13,7 +13,16 @@
certificate: "testkey",
}
-// Google-owned certificate for CTS testing, since we can't trust arbitrary keys on release devices.
+// Certificate for CTS tests that rely on UICC hardware conforming to the
+// updated CTS UICC card specification introduced in 2021. See
+// //cts/tests/tests/carrierapi/Android.bp for more details.
+android_app_certificate {
+ name: "cts-uicc-2021-testkey",
+ certificate: "cts_uicc_2021",
+}
+
+// Google-owned certificate for CTS testing, since we can't trust arbitrary keys
+// on release devices.
prebuilt_etc {
name: "fsverity-release-cert-der",
src: "fsverity-release.x509.der",
diff --git a/target/product/security/README b/target/product/security/README
index 6e75e4d..2b161bb 100644
--- a/target/product/security/README
+++ b/target/product/security/README
@@ -11,10 +11,11 @@
The following commands were used to generate the test key pairs:
- development/tools/make_key testkey '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
- development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
- 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 testkey '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+ development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+ 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'
signing using the openssl commandline (for boot/system images)
--------------------------------------------------------------
diff --git a/target/product/security/cts_uicc_2021.pk8 b/target/product/security/cts_uicc_2021.pk8
new file mode 100644
index 0000000..3b2a7fa
--- /dev/null
+++ b/target/product/security/cts_uicc_2021.pk8
Binary files differ
diff --git a/target/product/security/cts_uicc_2021.x509.pem b/target/product/security/cts_uicc_2021.x509.pem
new file mode 100644
index 0000000..744afea
--- /dev/null
+++ b/target/product/security/cts_uicc_2021.x509.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIECzCCAvOgAwIBAgIUHYLIIL60vWPD6aOBwZUcdbsae+cwDQYJKoZIhvcNAQEL
+BQAwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH
+DA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRy
+b2lkMRAwDgYDVQQDDAdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFu
+ZHJvaWQuY29tMB4XDTIxMDEyNjAwMjAyMVoXDTQ4MDYxMzAwMjAyMVowgZQxCzAJ
+BgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFp
+biBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRyb2lkMRAwDgYD
+VQQDDAdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29t
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlOMSHqBu0ihUDfFgwMfO
+pJtpyxHe0KKfHRndUQcYU/1v6/auy2YqkgKv+AraoukuU3gJeOiWoaqaWFNcm6md
+WfGRNT4oABhhNS43n5PI4NlLjI4yeUJJppZn5LPpc/8vZ0P8ZFE9CJmtckCh+hES
+BzqnxkCnq1PoxlcF3S/f8lOtd6ymaMDf3sYcePaoU8yTWFksl7EWRVwhBUIf7/r8
+epbNiV14/aH2cQfHVfpf54TIdk7s0/ehVA70A5gQp7Utn6mY2zEJlMrTKWRqA/a5
+oYiob3y+v2JWNcljHY6twwDOGwW7G0NWJVtaWj76Z3o9RpIhAglivhOrHTflIU3+
+2QIDAQABo1MwUTAdBgNVHQ4EFgQUZJ1oGb33n/OY+Mm8ykci4I6c9OcwHwYDVR0j
+BBgwFoAUZJ1oGb33n/OY+Mm8ykci4I6c9OcwDwYDVR0TAQH/BAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEASajvU0KCN2kfATPV95LQVE3N/URPi/lX9MfQptE54E+R
+6dHwHQIwU/fBFapAHfGgrpwUZftJO+Bad2iu5s1IhTJ0Q5v0yHdvWfo4EzVeMzPV
++/DWU786pPEomFkb9ZKhgVkFNPcbXlkUm/9HxRHPRTm8x+BE/75PKI+kh+pDmM+P
+5v4W0qDKPgFzIY/D4F++gVyPZ3O+/GhunjsJozO+dvN+50FH6o/kBHm2+QqQNYPW
+f232F3CYtH4uWI0TkbwmSvVGW8iOqh330Cef5zqwSdOkzybUirXFsHUu1Zad1aLT
+t0mu6RgNEmX8efOQCcz2Z/on8lkIAxCBwLX7wkH5JA==
+-----END CERTIFICATE-----
diff --git a/tests/device.rbc b/tests/device.rbc
new file mode 100644
index 0000000..5d4e70c
--- /dev/null
+++ b/tests/device.rbc
@@ -0,0 +1,42 @@
+
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Top-level test configuration.
+# Converted from the following makefile
+### PRODUCT_PACKAGES += dev
+### PRODUCT_HOST_PACKAGES += host
+### $(call inherit-product, $(LOCAL_PATH)/part1.mk)
+### PRODUCT_COPY_FILES += device_from:device_to
+### include $(LOCAL_PATH)/include1.mk
+### PRODUCT_PACKAGES += dev_after
+### PRODUCT_COPY_FILES += $(call find-copy-subdir-files,audio_platform_info*.xml,device/google/redfin/audio,$(TARGET_COPY_OUT_VENDOR)/etc) xyz
+
+load("//build/make/core:product_config.rbc", "rblf")
+load(":part1.rbc", _part1_init = "init")
+load(":include1.rbc", _include1_init = "init")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ rblf.setdefault(handle, "PRODUCT_PACKAGES")
+ cfg["PRODUCT_PACKAGES"] += ["dev"]
+ rblf.setdefault(handle, "PRODUCT_HOST_PACKAGES")
+ cfg["PRODUCT_HOST_PACKAGES"] += ["host"]
+ rblf.inherit(handle, "test/part1", _part1_init)
+ rblf.setdefault(handle, "PRODUCT_COPY_FILES")
+ cfg["PRODUCT_COPY_FILES"] += ["device_from:device_to"]
+ _include1_init(g, handle)
+ cfg["PRODUCT_PACKAGES"] += ["dev_after"]
+ cfg["PRODUCT_COPY_FILES"] += (rblf.find_and_copy("audio_platform_info*.xml", "device/google/redfin/audio", "||VENDOR-PATH-PH||/etc") +
+ ["xyz"])
diff --git a/tests/include1.rbc b/tests/include1.rbc
new file mode 100644
index 0000000..c0c9b3b
--- /dev/null
+++ b/tests/include1.rbc
@@ -0,0 +1,25 @@
+
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Included file (not inherited)
+# Converted from makefile
+### PRODUCT_PACKAGES += inc
+
+load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ rblf.setdefault(handle, "PRODUCT_PACKAGES")
+ cfg["PRODUCT_PACKAGES"] += ["inc"]
diff --git a/tests/part1.rbc b/tests/part1.rbc
new file mode 100644
index 0000000..3e50751
--- /dev/null
+++ b/tests/part1.rbc
@@ -0,0 +1,28 @@
+
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Part configuration
+# Converted from
+### PRODUCT_COPY_FILES += part_from:part_to
+### PRODUCT_PRODUCT_PROPERTIES += part_properties
+
+load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ rblf.setdefault(handle, "PRODUCT_COPY_FILES")
+ cfg["PRODUCT_COPY_FILES"] += ["part_from:part_to"]
+ rblf.setdefault(handle, "PRODUCT_PRODUCT_PROPERTIES")
+ cfg["PRODUCT_PRODUCT_PROPERTIES"] += ["part_properties"]
diff --git a/tests/run.rbc b/tests/run.rbc
new file mode 100644
index 0000000..b13f835
--- /dev/null
+++ b/tests/run.rbc
@@ -0,0 +1,50 @@
+
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Run test configuration and verify its result.
+# The main configuration file is device.rbc.
+# It inherits part1.rbc and also includes include1.rbc
+# TODO(asmundak): more tests are needed to verify that:
+# * multi-level inheritance works as expected
+# * all runtime functions (wildcard, regex, etc.) work
+
+load("//build/make/core:product_config.rbc", "rblf")
+load(":device.rbc", "init")
+
+def assert_eq(expected, actual):
+ if expected != actual:
+ fail("Expected %s, got %s" % (expected, actual))
+
+
+globals, config = rblf.product_configuration("test/device", init)
+assert_eq(
+ {
+ "PRODUCT_COPY_FILES": [
+ "part_from:part_to",
+ "device_from:device_to",
+ "device/google/redfin/audio/audio_platform_info_noextcodec_snd.xml:||VENDOR-PATH-PH||/etc/audio_platform_info_noextcodec_snd.xml",
+ "xyz"
+ ],
+ "PRODUCT_HOST_PACKAGES": ["host"],
+ "PRODUCT_PACKAGES": [
+ "dev",
+ "inc",
+ "dev_after"
+ ],
+ "PRODUCT_PRODUCT_PROPERTIES": ["part_properties"]
+ },
+ { k:v for k, v in sorted(config.items()) }
+)
diff --git a/tools/build-license-metadata.sh b/tools/build-license-metadata.sh
index 3bad358..a138dbe 100755
--- a/tools/build-license-metadata.sh
+++ b/tools/build-license-metadata.sh
@@ -201,6 +201,7 @@
for d in ${depfiles}; do
if cat "${d}" | egrep -q 'effective_condition\s*:.*restricted' ; then
lconditions="${lconditions}${lconditions:+ }restricted"
+ break
fi
done
;;
diff --git a/tools/generate-notice-files.py b/tools/generate-notice-files.py
index 18f2166..bf958fb 100755
--- a/tools/generate-notice-files.py
+++ b/tools/generate-notice-files.py
@@ -231,8 +231,8 @@
input_dirs = [os.path.normpath(source_dir) for source_dir in args.source_dir]
# Find all the notice files and md5 them
+ files_with_same_hash = defaultdict(list)
for input_dir in input_dirs:
- files_with_same_hash = defaultdict(list)
for root, dir, files in os.walk(input_dir):
for file in files:
matched = True
@@ -254,8 +254,7 @@
file_md5sum = md5sum(filename)
files_with_same_hash[file_md5sum].append(filename)
- filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())]
-
+ filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())]
combine_notice_files_text(filesets, input_dirs, txt_output_file, file_title)
if html_output_file is not None:
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index d8c9cb1..efbf614 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -42,7 +42,46 @@
# default to "adb". That might not the right policy there, but it's better
# to be explicit.
if not prop_list.get_value("persist.sys.usb.config"):
- prop_list.put("persist.sys.usb.config", "none");
+ prop_list.put("persist.sys.usb.config", "none")
+
+def validate_grf_props(prop_list, sdk_version):
+ """Validate GRF properties if exist.
+
+ If ro.board.first_api_level is defined, check if its value is valid for the
+ sdk version.
+ Also, validate the value of ro.board.api_level if defined.
+
+ Returns:
+ True if the GRF properties are valid.
+ """
+ grf_api_level = prop_list.get_value("ro.board.first_api_level")
+ board_api_level = prop_list.get_value("ro.board.api_level")
+
+ if not grf_api_level:
+ if board_api_level:
+ sys.stderr.write("error: non-GRF device must not define "
+ "ro.board.api_level\n")
+ return False
+ # non-GRF device skips the GRF validation test
+ return True
+
+ grf_api_level = int(grf_api_level)
+ if grf_api_level > sdk_version:
+ sys.stderr.write("error: ro.board.first_api_level(%d) must be less than "
+ "or equal to ro.build.version.sdk(%d)\n"
+ % (grf_api_level, sdk_version))
+ return False
+
+ if board_api_level:
+ board_api_level = int(board_api_level)
+ if board_api_level < grf_api_level or board_api_level > sdk_version:
+ sys.stderr.write("error: ro.board.api_level(%d) must be neither less "
+ "than ro.board.first_api_level(%d) nor greater than "
+ "ro.build.version.sdk(%d)\n"
+ % (board_api_level, grf_api_level, sdk_version))
+ return False
+
+ return True
def validate(prop_list):
"""Validate the properties.
@@ -215,6 +254,7 @@
default=False)
parser.add_argument("filename")
parser.add_argument("disallowed_keys", metavar="KEY", type=str, nargs="*")
+ parser.add_argument("--sdk-version", type=int, required=True)
args = parser.parse_args()
if not args.filename.endswith("/build.prop"):
@@ -225,6 +265,8 @@
mangle_build_prop(props)
if not override_optional_props(props, args.allow_dup):
sys.exit(1)
+ if not validate_grf_props(props, args.sdk_version):
+ sys.exit(1)
if not validate(props):
sys.exit(1)
diff --git a/tools/rbcrun/Android.bp b/tools/rbcrun/Android.bp
new file mode 100644
index 0000000..90173ac
--- /dev/null
+++ b/tools/rbcrun/Android.bp
@@ -0,0 +1,40 @@
+//
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+blueprint_go_binary {
+ name: "rbcrun",
+ srcs: ["cmd/rbcrun.go"],
+ deps: ["rbcrun-module"],
+}
+
+bootstrap_go_package {
+ name: "rbcrun-module",
+ srcs: [
+ "host.go",
+ ],
+ testSrcs: [
+ "host_test.go",
+ ],
+ pkgPath: "rbcrun",
+ deps: [
+ "go-starlark-starlark",
+ "go-starlark-starlarkstruct",
+ "go-starlark-starlarktest",
+ ],
+}
diff --git a/tools/rbcrun/README.md b/tools/rbcrun/README.md
new file mode 100644
index 0000000..fb58c89
--- /dev/null
+++ b/tools/rbcrun/README.md
@@ -0,0 +1,84 @@
+# Roboleaf configuration files interpreter
+
+Reads and executes Roboleaf product configuration files.
+
+## Usage
+
+`rbcrun` *options* *VAR=value*... [ *file* ]
+
+A Roboleaf configuration file is a Starlark script. Usually it is read from *file*. The option `-c` allows to provide a
+script directly on the command line. The option `-f` is there to allow the name of a file script to contain (`=`).
+(i.e., `my=file.rbc` sets `my` to `file.rbc`, `-f my=file.rbc` runs the script from `my=file.rbc`).
+
+### Options
+
+`-d` *dir*\
+Root directory for load("//path",...)
+
+`-c` *text*\
+Read script from *text*
+
+`--perf` *file*\
+Gather performance statistics and save it to *file*. Use \
+` go tool prof -top`*file*\
+to show top CPU users
+
+`-f` *file*\
+File to run.
+
+## Extensions
+
+The runner allows Starlark scripts to use the following features that Bazel's Starlark interpreter does not support:
+
+### Load statement URI
+
+Starlark does not define the format of the load statement's first argument.
+The Roboleaf configuration interpreter supports the format that Bazel uses
+(`":file"` or `"//path:file"`). In addition, it allows the URI to end with
+`"|symbol"` which defines a single variable `symbol` with `None` value if a
+module does not exist. Thus,
+
+```
+load(":mymodule.rbc|init", mymodule_init="init")
+```
+
+will load the module `mymodule.rbc` and export a symbol `init` in it as
+`mymodule_init` if `mymodule.rbc` exists. If `mymodule.rbc` is missing,
+`mymodule_init` will be set to `None`
+
+### Predefined Symbols
+
+#### rblf_env
+
+A `struct` containing environment variables. E.g., `rblf_env.USER` is the username when running on Unix.
+
+#### rblf_cli
+
+A `struct` containing the variable set by the interpreter's command line. That is, running
+
+```
+rbcrun FOO=bar myfile.rbc
+```
+
+will have the value of `rblf_cli.FOO` be `"bar"`
+
+### Predefined Functions
+
+#### rblf_file_exists(*file*)
+
+Returns `True` if *file* exists
+
+#### rblf_wildcard(*glob*, *top* = None)
+
+Expands *glob*. If *top* is supplied, expands "*top*/*glob*", then removes
+"*top*/" prefix from the matching file names.
+
+#### rblf_regex(*pattern*, *text*)
+
+Returns *True* if *text* matches *pattern*.
+
+#### rblf_shell(*command*)
+
+Runs `sh -c "`*command*`"`, reads its output, converts all newlines into spaces, chops trailing newline returns this
+string. This is equivalent to Make's
+`shell` builtin function. *This function will be eventually removed*.
diff --git a/tools/rbcrun/cmd/rbcrun.go b/tools/rbcrun/cmd/rbcrun.go
new file mode 100644
index 0000000..7848562
--- /dev/null
+++ b/tools/rbcrun/cmd/rbcrun.go
@@ -0,0 +1,98 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "flag"
+ "fmt"
+ "go.starlark.net/starlark"
+ "os"
+ "rbcrun"
+ "strings"
+)
+
+var (
+ execprog = flag.String("c", "", "execute program `prog`")
+ rootdir = flag.String("d", ".", "the value of // for load paths")
+ file = flag.String("f", "", "file to execute")
+ perfFile = flag.String("perf", "", "save performance data")
+)
+
+func main() {
+ flag.Parse()
+ filename := *file
+ var src interface{}
+ var env []string
+
+ rc := 0
+ for _, arg := range flag.Args() {
+ if strings.Contains(arg, "=") {
+ env = append(env, arg)
+ } else if filename == "" {
+ filename = arg
+ } else {
+ quit("only one file can be executed\n")
+ }
+ }
+ if *execprog != "" {
+ if filename != "" {
+ quit("either -c or file name should be present\n")
+ }
+ filename = "<cmdline>"
+ src = *execprog
+ }
+ if filename == "" {
+ if len(env) > 0 {
+ fmt.Fprintln(os.Stderr,
+ "no file to run -- if your file's name contains '=', use -f to specify it")
+ }
+ flag.Usage()
+ os.Exit(1)
+ }
+ if stat, err := os.Stat(*rootdir); os.IsNotExist(err) || !stat.IsDir() {
+ quit("%s is not a directory\n", *rootdir)
+ }
+ if *perfFile != "" {
+ pprof, err := os.Create(*perfFile)
+ if err != nil {
+ quit("%s: err", *perfFile)
+ }
+ defer pprof.Close()
+ if err := starlark.StartProfile(pprof); err != nil {
+ quit("%s\n", err)
+ }
+ }
+ rbcrun.LoadPathRoot = *rootdir
+ err := rbcrun.Run(filename, src, env)
+ if *perfFile != "" {
+ if err2 := starlark.StopProfile(); err2 != nil {
+ fmt.Fprintln(os.Stderr, err2)
+ rc = 1
+ }
+ }
+ if err != nil {
+ if evalErr, ok := err.(*starlark.EvalError); ok {
+ quit("%s\n", evalErr.Backtrace())
+ } else {
+ quit("%s\n", err)
+ }
+ }
+ os.Exit(rc)
+}
+
+func quit(format string, s ...interface{}) {
+ fmt.Fprintln(os.Stderr, format, s)
+ os.Exit(2)
+}
diff --git a/tools/rbcrun/go.mod b/tools/rbcrun/go.mod
new file mode 100644
index 0000000..a029eb4
--- /dev/null
+++ b/tools/rbcrun/go.mod
@@ -0,0 +1,10 @@
+module rbcrun
+
+require (
+ github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
+ go.starlark.net v0.0.0-20201006213952-227f4aabceb5
+)
+
+replace go.starlark.net => ../../../../external/starlark-go
+
+go 1.15
diff --git a/tools/rbcrun/go.sum b/tools/rbcrun/go.sum
new file mode 100644
index 0000000..db4d51e
--- /dev/null
+++ b/tools/rbcrun/go.sum
@@ -0,0 +1,75 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
+github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
+github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
+golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/tools/rbcrun/host.go b/tools/rbcrun/host.go
new file mode 100644
index 0000000..1e43334
--- /dev/null
+++ b/tools/rbcrun/host.go
@@ -0,0 +1,267 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package rbcrun
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "strings"
+
+ "go.starlark.net/starlark"
+ "go.starlark.net/starlarkstruct"
+)
+
+const callerDirKey = "callerDir"
+
+var LoadPathRoot = "."
+var shellPath string
+
+type modentry struct {
+ globals starlark.StringDict
+ err error
+}
+
+var moduleCache = make(map[string]*modentry)
+
+var builtins starlark.StringDict
+
+func moduleName2AbsPath(moduleName string, callerDir string) (string, error) {
+ path := moduleName
+ if ix := strings.LastIndex(path, ":"); ix >= 0 {
+ path = path[0:ix] + string(os.PathSeparator) + path[ix+1:]
+ }
+ if strings.HasPrefix(path, "//") {
+ return filepath.Abs(filepath.Join(LoadPathRoot, path[2:]))
+ } else if strings.HasPrefix(moduleName, ":") {
+ return filepath.Abs(filepath.Join(callerDir, path[1:]))
+ } else {
+ return filepath.Abs(path)
+ }
+}
+
+// loader implements load statement. The format of the loaded module URI is
+// [//path]:base[|symbol]
+// The file path is $ROOT/path/base if path is present, <caller_dir>/base otherwise.
+// The presence of `|symbol` indicates that the loader should return a single 'symbol'
+// bound to None if file is missing.
+func loader(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ pipePos := strings.LastIndex(module, "|")
+ mustLoad := pipePos < 0
+ var defaultSymbol string
+ if !mustLoad {
+ defaultSymbol = module[pipePos+1:]
+ module = module[:pipePos]
+ }
+ modulePath, err := moduleName2AbsPath(module, thread.Local(callerDirKey).(string))
+ if err != nil {
+ return nil, err
+ }
+ e, ok := moduleCache[modulePath]
+ if e == nil {
+ if ok {
+ return nil, fmt.Errorf("cycle in load graph")
+ }
+
+ // Add a placeholder to indicate "load in progress".
+ moduleCache[modulePath] = nil
+
+ // Decide if we should load.
+ if !mustLoad {
+ if _, err := os.Stat(modulePath); err == nil {
+ mustLoad = true
+ }
+ }
+
+ // Load or return default
+ if mustLoad {
+ childThread := &starlark.Thread{Name: "exec " + module, Load: thread.Load}
+ // Cheating for the sake of testing:
+ // propagate starlarktest's Reporter key, otherwise testing
+ // the load function may cause panic in starlarktest code.
+ const testReporterKey = "Reporter"
+ if v := thread.Local(testReporterKey); v != nil {
+ childThread.SetLocal(testReporterKey, v)
+ }
+
+ childThread.SetLocal(callerDirKey, filepath.Dir(modulePath))
+ globals, err := starlark.ExecFile(childThread, modulePath, nil, builtins)
+ e = &modentry{globals, err}
+ } else {
+ e = &modentry{starlark.StringDict{defaultSymbol: starlark.None}, nil}
+ }
+
+ // Update the cache.
+ moduleCache[modulePath] = e
+ }
+ return e.globals, e.err
+}
+
+// fileExists returns True if file with given name exists.
+func fileExists(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
+ kwargs []starlark.Tuple) (starlark.Value, error) {
+ var path string
+ if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 1, &path); err != nil {
+ return starlark.None, err
+ }
+ if stat, err := os.Stat(path); err != nil || stat.IsDir() {
+ return starlark.False, nil
+ }
+ return starlark.True, nil
+}
+
+// regexMatch(pattern, s) returns True if s matches pattern (a regex)
+func regexMatch(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
+ kwargs []starlark.Tuple) (starlark.Value, error) {
+ var pattern, s string
+ if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 2, &pattern, &s); err != nil {
+ return starlark.None, err
+ }
+ match, err := regexp.MatchString(pattern, s)
+ if err != nil {
+ return starlark.None, err
+ }
+ if match {
+ return starlark.True, nil
+ }
+ return starlark.False, nil
+}
+
+// wildcard(pattern, top=None) expands shell's glob pattern. If 'top' is present,
+// the 'top/pattern' is globbed and then 'top/' prefix is removed.
+func wildcard(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
+ kwargs []starlark.Tuple) (starlark.Value, error) {
+ var pattern string
+ var top string
+
+ if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 1, &pattern, &top); err != nil {
+ return starlark.None, err
+ }
+
+ var files []string
+ var err error
+ if top == "" {
+ if files, err = filepath.Glob(pattern); err != nil {
+ return starlark.None, err
+ }
+ } else {
+ prefix := top + string(filepath.Separator)
+ if files, err = filepath.Glob(prefix + pattern); err != nil {
+ return starlark.None, err
+ }
+ for i := range files {
+ files[i] = strings.TrimPrefix(files[i], prefix)
+ }
+ }
+ return makeStringList(files), nil
+}
+
+// shell(command) runs OS shell with given command and returns back
+// its output the same way as Make's $(shell ) function. The end-of-lines
+// ("\n" or "\r\n") are replaced with " " in the result, and the trailing
+// end-of-line is removed.
+func shell(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
+ kwargs []starlark.Tuple) (starlark.Value, error) {
+ var command string
+ if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 1, &command); err != nil {
+ return starlark.None, err
+ }
+ if shellPath == "" {
+ return starlark.None,
+ fmt.Errorf("cannot run shell, /bin/sh is missing (running on Windows?)")
+ }
+ cmd := exec.Command(shellPath, "-c", command)
+ // We ignore command's status
+ bytes, _ := cmd.Output()
+ output := string(bytes)
+ if strings.HasSuffix(output, "\n") {
+ output = strings.TrimSuffix(output, "\n")
+ } else {
+ output = strings.TrimSuffix(output, "\r\n")
+ }
+
+ return starlark.String(
+ strings.ReplaceAll(
+ strings.ReplaceAll(output, "\r\n", " "),
+ "\n", " ")), nil
+}
+
+func makeStringList(items []string) *starlark.List {
+ elems := make([]starlark.Value, len(items))
+ for i, item := range items {
+ elems[i] = starlark.String(item)
+ }
+ return starlark.NewList(elems)
+}
+
+// propsetFromEnv constructs a propset from the array of KEY=value strings
+func structFromEnv(env []string) *starlarkstruct.Struct {
+ sd := make(map[string]starlark.Value, len(env))
+ for _, x := range env {
+ kv := strings.SplitN(x, "=", 2)
+ sd[kv[0]] = starlark.String(kv[1])
+ }
+ return starlarkstruct.FromStringDict(starlarkstruct.Default, sd)
+}
+
+func setup(env []string) {
+ // Create the symbols that aid makefile conversion. See README.md
+ builtins = starlark.StringDict{
+ "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
+ "rblf_cli": structFromEnv(env),
+ "rblf_env": structFromEnv(os.Environ()),
+ // To convert makefile's $(wildcard foo)
+ "rblf_file_exists": starlark.NewBuiltin("rblf_file_exists", fileExists),
+ // To convert makefile's $(filter ...)/$(filter-out)
+ "rblf_regex": starlark.NewBuiltin("rblf_regex", regexMatch),
+ // To convert makefile's $(shell cmd)
+ "rblf_shell": starlark.NewBuiltin("rblf_shell", shell),
+ // To convert makefile's $(wildcard foo*)
+ "rblf_wildcard": starlark.NewBuiltin("rblf_wildcard", wildcard),
+ }
+
+ // NOTE(asmundak): OS-specific. Behave similar to Linux `system` call,
+ // which always uses /bin/sh to run the command
+ shellPath = "/bin/sh"
+ if _, err := os.Stat(shellPath); err != nil {
+ shellPath = ""
+ }
+}
+
+// Parses, resolves, and executes a Starlark file.
+// filename and src parameters are as for starlark.ExecFile:
+// * filename is the name of the file to execute,
+// and the name that appears in error messages;
+// * src is an optional source of bytes to use instead of filename
+// (it can be a string, or a byte array, or an io.Reader instance)
+// * commandVars is an array of "VAR=value" items. They are accessible from
+// the starlark script as members of the `rblf_cli` propset.
+func Run(filename string, src interface{}, commandVars []string) error {
+ setup(commandVars)
+
+ mainThread := &starlark.Thread{
+ Name: "main",
+ Print: func(_ *starlark.Thread, msg string) { fmt.Println(msg) },
+ Load: loader,
+ }
+ absPath, err := filepath.Abs(filename)
+ if err == nil {
+ mainThread.SetLocal(callerDirKey, filepath.Dir(absPath))
+ _, err = starlark.ExecFile(mainThread, absPath, src, builtins)
+ }
+ return err
+}
diff --git a/tools/rbcrun/host_test.go b/tools/rbcrun/host_test.go
new file mode 100644
index 0000000..3be5ee6
--- /dev/null
+++ b/tools/rbcrun/host_test.go
@@ -0,0 +1,159 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package rbcrun
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "runtime"
+ "testing"
+
+ "go.starlark.net/resolve"
+ "go.starlark.net/starlark"
+ "go.starlark.net/starlarktest"
+)
+
+// In order to use "assert.star" from go/starlark.net/starlarktest in the tests,
+// provide:
+// * load function that handles "assert.star"
+// * starlarktest.DataFile function that finds its location
+
+func init() {
+ starlarktestSetup()
+}
+
+func starlarktestSetup() {
+ resolve.AllowLambda = true
+ starlarktest.DataFile = func(pkgdir, filename string) string {
+ // The caller expects this function to return the path to the
+ // data file. The implementation assumes that the source file
+ // containing the caller and the data file are in the same
+ // directory. It's ugly. Not sure what's the better way.
+ // TODO(asmundak): handle Bazel case
+ _, starlarktestSrcFile, _, _ := runtime.Caller(1)
+ if filepath.Base(starlarktestSrcFile) != "starlarktest.go" {
+ panic(fmt.Errorf("this function should be called from starlarktest.go, got %s",
+ starlarktestSrcFile))
+ }
+ return filepath.Join(filepath.Dir(starlarktestSrcFile), filename)
+ }
+}
+
+// Common setup for the tests: create thread, change to the test directory
+func testSetup(t *testing.T, env []string) *starlark.Thread {
+ setup(env)
+ thread := &starlark.Thread{
+ Load: func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ if module == "assert.star" {
+ return starlarktest.LoadAssertModule()
+ }
+ return nil, fmt.Errorf("load not implemented")
+ }}
+ starlarktest.SetReporter(thread, t)
+ if err := os.Chdir(dataDir()); err != nil {
+ t.Fatal(err)
+ }
+ return thread
+}
+
+func dataDir() string {
+ _, thisSrcFile, _, _ := runtime.Caller(0)
+ return filepath.Join(filepath.Dir(thisSrcFile), "testdata")
+
+}
+
+func exerciseStarlarkTestFile(t *testing.T, starFile string) {
+ // In order to use "assert.star" from go/starlark.net/starlarktest in the tests, provide:
+ // * load function that handles "assert.star"
+ // * starlarktest.DataFile function that finds its location
+ setup(nil)
+ thread := &starlark.Thread{
+ Load: func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ if module == "assert.star" {
+ return starlarktest.LoadAssertModule()
+ }
+ return nil, fmt.Errorf("load not implemented")
+ }}
+ starlarktest.SetReporter(thread, t)
+ _, thisSrcFile, _, _ := runtime.Caller(0)
+ filename := filepath.Join(filepath.Dir(thisSrcFile), starFile)
+ if _, err := starlark.ExecFile(thread, filename, nil, builtins); err != nil {
+ if err, ok := err.(*starlark.EvalError); ok {
+ t.Fatal(err.Backtrace())
+ }
+ t.Fatal(err)
+ }
+}
+
+func TestCliAndEnv(t *testing.T) {
+ // TODO(asmundak): convert this to use exerciseStarlarkTestFile
+ if err := os.Setenv("TEST_ENVIRONMENT_FOO", "test_environment_foo"); err != nil {
+ t.Fatal(err)
+ }
+ thread := testSetup(t, []string{"CLI_FOO=foo"})
+ if _, err := starlark.ExecFile(thread, "cli_and_env.star", nil, builtins); err != nil {
+ if err, ok := err.(*starlark.EvalError); ok {
+ t.Fatal(err.Backtrace())
+ }
+ t.Fatal(err)
+ }
+}
+
+func TestFileOps(t *testing.T) {
+ // TODO(asmundak): convert this to use exerciseStarlarkTestFile
+ if err := os.Setenv("TEST_DATA_DIR", dataDir()); err != nil {
+ t.Fatal(err)
+ }
+ thread := testSetup(t, nil)
+ if _, err := starlark.ExecFile(thread, "file_ops.star", nil, builtins); err != nil {
+ if err, ok := err.(*starlark.EvalError); ok {
+ t.Fatal(err.Backtrace())
+ }
+ t.Fatal(err)
+ }
+}
+
+func TestLoad(t *testing.T) {
+ // TODO(asmundak): convert this to use exerciseStarlarkTestFile
+ thread := testSetup(t, nil)
+ thread.Load = func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
+ if module == "assert.star" {
+ return starlarktest.LoadAssertModule()
+ } else {
+ return loader(thread, module)
+ }
+ }
+ dir := dataDir()
+ thread.SetLocal(callerDirKey, dir)
+ LoadPathRoot = filepath.Dir(dir)
+ if _, err := starlark.ExecFile(thread, "load.star", nil, builtins); err != nil {
+ if err, ok := err.(*starlark.EvalError); ok {
+ t.Fatal(err.Backtrace())
+ }
+ t.Fatal(err)
+ }
+}
+
+func TestRegex(t *testing.T) {
+ exerciseStarlarkTestFile(t, "testdata/regex.star")
+}
+
+func TestShell(t *testing.T) {
+ if err := os.Setenv("TEST_DATA_DIR", dataDir()); err != nil {
+ t.Fatal(err)
+ }
+ exerciseStarlarkTestFile(t, "testdata/shell.star")
+}
diff --git a/tools/rbcrun/testdata/cli_and_env.star b/tools/rbcrun/testdata/cli_and_env.star
new file mode 100644
index 0000000..d6f464a
--- /dev/null
+++ b/tools/rbcrun/testdata/cli_and_env.star
@@ -0,0 +1,11 @@
+# Tests rblf_env access
+load("assert.star", "assert")
+
+
+def test():
+ assert.eq(rblf_env.TEST_ENVIRONMENT_FOO, "test_environment_foo")
+ assert.fails(lambda: rblf_env.FOO_BAR_BAZ, ".*struct has no .FOO_BAR_BAZ attribute$")
+ assert.eq(rblf_cli.CLI_FOO, "foo")
+
+
+test()
diff --git a/tools/rbcrun/testdata/file_ops.star b/tools/rbcrun/testdata/file_ops.star
new file mode 100644
index 0000000..e1f1ac2
--- /dev/null
+++ b/tools/rbcrun/testdata/file_ops.star
@@ -0,0 +1,18 @@
+# Tests file ops builtins
+load("assert.star", "assert")
+
+
+def test():
+ myname = "file_ops.star"
+ assert.true(rblf_file_exists(myname), "the file %s does exist" % myname)
+ assert.true(not rblf_file_exists("no_such_file"), "the file no_such_file does not exist")
+ files = rblf_wildcard("*.star")
+ assert.true(myname in files, "expected %s in %s" % (myname, files))
+ # RBCDATADIR is set by the caller to the path where this file resides
+ files = rblf_wildcard("*.star", rblf_env.TEST_DATA_DIR)
+ assert.true(myname in files, "expected %s in %s" % (myname, files))
+ files = rblf_wildcard("*.xxx")
+ assert.true(len(files) == 0, "expansion should be empty but contains %s" % files)
+
+
+test()
diff --git a/tools/rbcrun/testdata/load.star b/tools/rbcrun/testdata/load.star
new file mode 100644
index 0000000..b14f2bb
--- /dev/null
+++ b/tools/rbcrun/testdata/load.star
@@ -0,0 +1,14 @@
+# Test load, simple and conditional
+load("assert.star", "assert")
+load(":module1.star", test1="test")
+load("//testdata:module2.star", test2="test")
+load(":module3|test", test3="test")
+
+
+def test():
+ assert.eq(test1, "module1")
+ assert.eq(test2, "module2")
+ assert.eq(test3, None)
+
+
+test()
diff --git a/tools/rbcrun/testdata/module1.star b/tools/rbcrun/testdata/module1.star
new file mode 100644
index 0000000..913fb7d
--- /dev/null
+++ b/tools/rbcrun/testdata/module1.star
@@ -0,0 +1,7 @@
+# Module loaded my load.star
+load("assert.star", "assert")
+
+# Make sure that builtins are defined for the loaded module, too
+assert.true(rblf_file_exists("module1.star"))
+assert.true(not rblf_file_exists("no_such file"))
+test = "module1"
diff --git a/tools/rbcrun/testdata/module2.star b/tools/rbcrun/testdata/module2.star
new file mode 100644
index 0000000..f6818a2
--- /dev/null
+++ b/tools/rbcrun/testdata/module2.star
@@ -0,0 +1,2 @@
+# Module loaded my load.star
+test = "module2"
diff --git a/tools/rbcrun/testdata/regex.star b/tools/rbcrun/testdata/regex.star
new file mode 100644
index 0000000..04e1d42
--- /dev/null
+++ b/tools/rbcrun/testdata/regex.star
@@ -0,0 +1,13 @@
+# Tests rblf_regex
+load("assert.star", "assert")
+
+
+def test():
+ pattern = "^(foo.*bar|abc.*d|1.*)$"
+ for w in ("foobar", "fooxbar", "abcxd", "123"):
+ assert.true(rblf_regex(pattern, w), "%s should match %s" % (w, pattern))
+ for w in ("afoobar", "abcde"):
+ assert.true(not rblf_regex(pattern, w), "%s should not match %s" % (w, pattern))
+
+
+test()
diff --git a/tools/rbcrun/testdata/shell.star b/tools/rbcrun/testdata/shell.star
new file mode 100644
index 0000000..ad10697
--- /dev/null
+++ b/tools/rbcrun/testdata/shell.star
@@ -0,0 +1,5 @@
+# Tests "queue" data type
+load("assert.star", "assert")
+
+assert.eq("load.star shell.star", rblf_shell("cd %s && ls -1 shell.star load.star 2>&1" % rblf_env.TEST_DATA_DIR))
+assert.eq("shell.star", rblf_shell("cd %s && echo shell.sta*" % rblf_env.TEST_DATA_DIR))
diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp
index 3b0c070..65c035e 100644
--- a/tools/releasetools/Android.bp
+++ b/tools/releasetools/Android.bp
@@ -133,6 +133,7 @@
required: [
"brillo_update_payload",
"checkvintf",
+ "minigzip",
"lz4",
"toybox",
"unpack_bootimg",
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 900c7b5..00bbb21 100644
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -59,12 +59,11 @@
import build_image
import build_super_image
import common
-import rangelib
-import sparse_img
import verity_utils
import ota_metadata_pb2
-from apex_utils import GetSystemApexInfoFromTargetFiles
+from apex_utils import GetApexInfoFromTargetFiles
+from common import AddCareMapForAbOta
if sys.hexversion < 0x02070000:
print("Python 2.7 or newer is required.", file=sys.stderr)
@@ -110,45 +109,6 @@
common.ZipWrite(self._output_zip, self.name, self._zip_name)
-def GetCareMap(which, imgname):
- """Returns the care_map string for the given partition.
-
- Args:
- which: The partition name, must be listed in PARTITIONS_WITH_CARE_MAP.
- imgname: The filename of the image.
-
- Returns:
- (which, care_map_ranges): care_map_ranges is the raw string of the care_map
- RangeSet; or None.
- """
- assert which in common.PARTITIONS_WITH_CARE_MAP
-
- # which + "_image_size" contains the size that the actual filesystem image
- # resides in, which is all that needs to be verified. The additional blocks in
- # the image file contain verity metadata, by reading which would trigger
- # invalid reads.
- image_size = OPTIONS.info_dict.get(which + "_image_size")
- if not image_size:
- return None
-
- image_blocks = int(image_size) // 4096 - 1
- assert image_blocks > 0, "blocks for {} must be positive".format(which)
-
- # For sparse images, we will only check the blocks that are listed in the care
- # map, i.e. the ones with meaningful data.
- if "extfs_sparse_flag" in OPTIONS.info_dict:
- simg = sparse_img.SparseImage(imgname)
- care_map_ranges = simg.care_map.intersect(
- rangelib.RangeSet("0-{}".format(image_blocks)))
-
- # Otherwise for non-sparse images, we read all the blocks in the filesystem
- # image.
- else:
- care_map_ranges = rangelib.RangeSet("0-{}".format(image_blocks))
-
- return [which, care_map_ranges.to_string_raw()]
-
-
def AddSystem(output_zip, recovery_img=None, boot_img=None):
"""Turn the contents of SYSTEM into a system image and store it in
output_zip. Returns the name of the system image file."""
@@ -644,72 +604,6 @@
assert available, "Failed to find " + img_name
-def AddCareMapForAbOta(output_zip, ab_partitions, image_paths):
- """Generates and adds care_map.pb for a/b partition that has care_map.
-
- Args:
- output_zip: The output zip file (needs to be already open), or None to
- write care_map.pb to OPTIONS.input_tmp/.
- ab_partitions: The list of A/B partitions.
- image_paths: A map from the partition name to the image path.
- """
- care_map_list = []
- for partition in ab_partitions:
- partition = partition.strip()
- if partition not in common.PARTITIONS_WITH_CARE_MAP:
- continue
-
- verity_block_device = "{}_verity_block_device".format(partition)
- avb_hashtree_enable = "avb_{}_hashtree_enable".format(partition)
- if (verity_block_device in OPTIONS.info_dict or
- OPTIONS.info_dict.get(avb_hashtree_enable) == "true"):
- image_path = image_paths[partition]
- assert os.path.exists(image_path)
-
- care_map = GetCareMap(partition, image_path)
- if not care_map:
- continue
- care_map_list += care_map
-
- # adds fingerprint field to the care_map
- # TODO(xunchang) revisit the fingerprint calculation for care_map.
- partition_props = OPTIONS.info_dict.get(partition + ".build.prop")
- prop_name_list = ["ro.{}.build.fingerprint".format(partition),
- "ro.{}.build.thumbprint".format(partition)]
-
- present_props = [x for x in prop_name_list if
- partition_props and partition_props.GetProp(x)]
- if not present_props:
- logger.warning("fingerprint is not present for partition %s", partition)
- property_id, fingerprint = "unknown", "unknown"
- else:
- property_id = present_props[0]
- fingerprint = partition_props.GetProp(property_id)
- care_map_list += [property_id, fingerprint]
-
- if not care_map_list:
- return
-
- # Converts the list into proto buf message by calling care_map_generator; and
- # writes the result to a temp file.
- temp_care_map_text = common.MakeTempFile(prefix="caremap_text-",
- suffix=".txt")
- with open(temp_care_map_text, 'w') as text_file:
- text_file.write('\n'.join(care_map_list))
-
- temp_care_map = common.MakeTempFile(prefix="caremap-", suffix=".pb")
- care_map_gen_cmd = ["care_map_generator", temp_care_map_text, temp_care_map]
- common.RunAndCheckOutput(care_map_gen_cmd)
-
- care_map_path = "META/care_map.pb"
- if output_zip and care_map_path not in output_zip.namelist():
- common.ZipWrite(output_zip, temp_care_map, arcname=care_map_path)
- else:
- shutil.copy(temp_care_map, os.path.join(OPTIONS.input_tmp, care_map_path))
- if output_zip:
- OPTIONS.replace_updated_files_list.append(care_map_path)
-
-
def AddPackRadioImages(output_zip, images):
"""Copies images listed in META/pack_radioimages.txt from RADIO/ to IMAGES/.
@@ -792,7 +686,7 @@
"{}.img".format(partition_name))))
def AddApexInfo(output_zip):
- apex_infos = GetSystemApexInfoFromTargetFiles(OPTIONS.input_tmp)
+ apex_infos = GetApexInfoFromTargetFiles(OPTIONS.input_tmp, 'system')
apex_metadata_proto = ota_metadata_pb2.ApexMetadata()
apex_metadata_proto.apex_info.extend(apex_infos)
apex_info_bytes = apex_metadata_proto.SerializeToString()
@@ -1027,8 +921,9 @@
AddVBMeta(output_zip, partitions, "vbmeta", vbmeta_partitions)
if OPTIONS.info_dict.get("use_dynamic_partitions") == "true":
- banner("super_empty")
- AddSuperEmpty(output_zip)
+ if OPTIONS.info_dict.get("build_super_empty_partition") == "true":
+ banner("super_empty")
+ AddSuperEmpty(output_zip)
if OPTIONS.info_dict.get("build_super_partition") == "true":
if OPTIONS.info_dict.get(
@@ -1049,7 +944,9 @@
# Generate care_map.pb for ab_partitions, then write this file to
# target_files package.
- AddCareMapForAbOta(output_zip, ab_partitions, partitions)
+ output_care_map = os.path.join(OPTIONS.input_tmp, "META", "care_map.pb")
+ AddCareMapForAbOta(output_zip if output_zip else output_care_map,
+ ab_partitions, partitions)
# Radio images that need to be packed into IMAGES/, and product-img.zip.
pack_radioimages_txt = os.path.join(
diff --git a/tools/releasetools/apex_utils.py b/tools/releasetools/apex_utils.py
index 1c88053..893266f 100644
--- a/tools/releasetools/apex_utils.py
+++ b/tools/releasetools/apex_utils.py
@@ -516,7 +516,7 @@
raise ApexInfoError(
'Failed to get type for {}:\n{}'.format(apex_file, e))
-def GetSystemApexInfoFromTargetFiles(input_file):
+def GetApexInfoFromTargetFiles(input_file, partition, compressed_only=True):
"""
Get information about system APEX stored in the input_file zip
@@ -532,15 +532,17 @@
if not isinstance(input_file, str):
raise RuntimeError("must pass filepath to target-files zip or directory")
+ apex_subdir = os.path.join(partition.upper(), 'apex')
if os.path.isdir(input_file):
tmp_dir = input_file
else:
- tmp_dir = UnzipTemp(input_file, ["SYSTEM/apex/*"])
- target_dir = os.path.join(tmp_dir, "SYSTEM/apex/")
+ tmp_dir = UnzipTemp(input_file, [os.path.join(apex_subdir, '*')])
+ target_dir = os.path.join(tmp_dir, apex_subdir)
# Partial target-files packages for vendor-only builds may not contain
# a system apex directory.
if not os.path.exists(target_dir):
+ logger.info('No APEX directory at path: %s', target_dir)
return []
apex_infos = []
@@ -585,6 +587,7 @@
'--output', decompressed_file_path])
apex_info.decompressed_size = os.path.getsize(decompressed_file_path)
+ if not compressed_only or apex_info.is_compressed:
apex_infos.append(apex_info)
return apex_infos
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 3726df6..301d0da 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -73,9 +73,9 @@
"""
cmd = ["find", path, "-print"]
output = common.RunAndCheckOutput(cmd, verbose=False)
- # increase by > 4% as number of files and directories is not whole picture.
+ # increase by > 6% as number of files and directories is not whole picture.
inodes = output.count('\n')
- spare_inodes = inodes * 4 // 100
+ spare_inodes = inodes * 6 // 100
min_spare_inodes = 12
if spare_inodes < min_spare_inodes:
spare_inodes = min_spare_inodes
diff --git a/tools/releasetools/build_super_image.py b/tools/releasetools/build_super_image.py
index fb31415..ac61e60 100755
--- a/tools/releasetools/build_super_image.py
+++ b/tools/releasetools/build_super_image.py
@@ -194,10 +194,8 @@
return BuildSuperImageFromTargetFiles(inp, out)
if os.path.isfile(inp):
- with open(inp) as f:
- lines = f.read()
logger.info("Building super image from info dict...")
- return BuildSuperImageFromDict(common.LoadDictionaryFromLines(lines.split("\n")), out)
+ return BuildSuperImageFromDict(common.LoadDictionaryFromFile(inp), out)
raise ValueError("{} is not a dictionary or a valid path".format(inp))
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 414ab97..83425cc 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -41,6 +41,7 @@
from hashlib import sha1, sha256
import images
+import rangelib
import sparse_img
from blockimgdiff import BlockImageDiff
@@ -651,6 +652,16 @@
raise KeyError(fn)
return file
+class RamdiskFormat(object):
+ LZ4 = 1
+ GZ = 2
+
+def _GetRamdiskFormat(info_dict):
+ if info_dict.get('lz4_ramdisks') == 'true':
+ ramdisk_format = RamdiskFormat.LZ4
+ else:
+ ramdisk_format = RamdiskFormat.GZ
+ return ramdisk_format
def LoadInfoDict(input_file, repacking=False):
"""Loads the key/value pairs from the given input target_files.
@@ -753,13 +764,14 @@
# Load recovery fstab if applicable.
d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper)
+ ramdisk_format = _GetRamdiskFormat(d)
# Tries to load the build props for all partitions with care_map, including
# system and vendor.
for partition in PARTITIONS_WITH_BUILD_PROP:
partition_prop = "{}.build.prop".format(partition)
d[partition_prop] = PartitionBuildProps.FromInputFile(
- input_file, partition)
+ input_file, partition, ramdisk_format=ramdisk_format)
d["build.prop"] = d["system.build.prop"]
# Set up the salt (based on fingerprint) that will be used when adding AVB
@@ -818,6 +830,9 @@
placeholder_values: A dict of runtime variables' values to replace the
placeholders in the build.prop file. We expect exactly one value for
each of the variables.
+ ramdisk_format: If name is "boot", the format of ramdisk inside the
+ boot image. Otherwise, its value is ignored.
+ Use lz4 to decompress by default. If its value is gzip, use minigzip.
"""
def __init__(self, input_file, name, placeholder_values=None):
@@ -840,11 +855,11 @@
return props
@staticmethod
- def FromInputFile(input_file, name, placeholder_values=None):
+ def FromInputFile(input_file, name, placeholder_values=None, ramdisk_format=RamdiskFormat.LZ4):
"""Loads the build.prop file and builds the attributes."""
if name == "boot":
- data = PartitionBuildProps._ReadBootPropFile(input_file)
+ data = PartitionBuildProps._ReadBootPropFile(input_file, ramdisk_format=ramdisk_format)
else:
data = PartitionBuildProps._ReadPartitionPropFile(input_file, name)
@@ -853,7 +868,7 @@
return props
@staticmethod
- def _ReadBootPropFile(input_file):
+ def _ReadBootPropFile(input_file, ramdisk_format):
"""
Read build.prop for boot image from input_file.
Return empty string if not found.
@@ -863,7 +878,7 @@
except KeyError:
logger.warning('Failed to read IMAGES/boot.img')
return ''
- prop_file = GetBootImageBuildProp(boot_img)
+ prop_file = GetBootImageBuildProp(boot_img, ramdisk_format=ramdisk_format)
if prop_file is None:
return ''
with open(prop_file, "r") as f:
@@ -1436,7 +1451,8 @@
AddAftlInclusionProof(image_path)
-def _MakeRamdisk(sourcedir, fs_config_file=None, lz4_ramdisks=False):
+def _MakeRamdisk(sourcedir, fs_config_file=None,
+ ramdisk_format=RamdiskFormat.GZ):
ramdisk_img = tempfile.NamedTemporaryFile()
if fs_config_file is not None and os.access(fs_config_file, os.F_OK):
@@ -1445,11 +1461,13 @@
else:
cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")]
p1 = Run(cmd, stdout=subprocess.PIPE)
- if lz4_ramdisks:
+ if ramdisk_format == RamdiskFormat.LZ4:
p2 = Run(["lz4", "-l", "-12", "--favor-decSpeed"], stdin=p1.stdout,
stdout=ramdisk_img.file.fileno())
- else:
+ elif ramdisk_format == RamdiskFormat.GZ:
p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno())
+ else:
+ raise ValueError("Only support lz4 or minigzip ramdisk format.")
p2.wait()
p1.wait()
@@ -1496,8 +1514,9 @@
img = tempfile.NamedTemporaryFile()
if has_ramdisk:
- use_lz4 = info_dict.get("lz4_ramdisks") == 'true'
- ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file, lz4_ramdisks=use_lz4)
+ ramdisk_format = _GetRamdiskFormat(info_dict)
+ ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file,
+ ramdisk_format=ramdisk_format)
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@@ -1685,8 +1704,8 @@
img = tempfile.NamedTemporaryFile()
- use_lz4 = info_dict.get("lz4_ramdisks") == 'true'
- ramdisk_img = _MakeRamdisk(sourcedir, lz4_ramdisks=use_lz4)
+ ramdisk_format = _GetRamdiskFormat(info_dict)
+ ramdisk_img = _MakeRamdisk(sourcedir, ramdisk_format=ramdisk_format)
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@@ -1742,7 +1761,8 @@
ramdisk_fragment_pathname = fn
else:
ramdisk_fragment_root = os.path.join(sourcedir, "RAMDISK_FRAGMENTS", ramdisk_fragment)
- ramdisk_fragment_img = _MakeRamdisk(ramdisk_fragment_root, lz4_ramdisks=use_lz4)
+ ramdisk_fragment_img = _MakeRamdisk(ramdisk_fragment_root,
+ ramdisk_format=ramdisk_format)
ramdisk_fragment_imgs.append(ramdisk_fragment_img)
ramdisk_fragment_pathname = ramdisk_fragment_img.name
cmd.extend(["--vendor_ramdisk_fragment", ramdisk_fragment_pathname])
@@ -3661,12 +3681,12 @@
append('move %s %s' % (p, u.tgt_group))
-def GetBootImageBuildProp(boot_img):
+def GetBootImageBuildProp(boot_img, ramdisk_format=RamdiskFormat.LZ4):
"""
Get build.prop from ramdisk within the boot image
Args:
- boot_img: the boot image file. Ramdisk must be compressed with lz4 format.
+ boot_img: the boot image file. Ramdisk must be compressed with lz4 or minigzip format.
Return:
An extracted file that stores properties in the boot image.
@@ -3679,7 +3699,16 @@
logger.warning('Unable to get boot image timestamp: no ramdisk in boot')
return None
uncompressed_ramdisk = os.path.join(tmp_dir, 'uncompressed_ramdisk')
- RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
+ if ramdisk_format == RamdiskFormat.LZ4:
+ RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
+ elif ramdisk_format == RamdiskFormat.GZ:
+ with open(ramdisk, 'rb') as input_stream:
+ with open(uncompressed_ramdisk, 'wb') as output_stream:
+ p2 = Run(['minigzip', '-d'], stdin=input_stream.fileno(), stdout=output_stream.fileno())
+ p2.wait()
+ else:
+ logger.error('Only support lz4 or minigzip ramdisk format.')
+ return None
abs_uncompressed_ramdisk = os.path.abspath(uncompressed_ramdisk)
extracted_ramdisk = MakeTempDir('extracted_ramdisk')
@@ -3731,3 +3760,124 @@
except ExternalError as e:
logger.warning('Unable to get boot image timestamp: %s', e)
return None
+
+
+def GetCareMap(which, imgname):
+ """Returns the care_map string for the given partition.
+
+ Args:
+ which: The partition name, must be listed in PARTITIONS_WITH_CARE_MAP.
+ imgname: The filename of the image.
+
+ Returns:
+ (which, care_map_ranges): care_map_ranges is the raw string of the care_map
+ RangeSet; or None.
+ """
+ assert which in PARTITIONS_WITH_CARE_MAP
+
+ # which + "_image_size" contains the size that the actual filesystem image
+ # resides in, which is all that needs to be verified. The additional blocks in
+ # the image file contain verity metadata, by reading which would trigger
+ # invalid reads.
+ image_size = OPTIONS.info_dict.get(which + "_image_size")
+ if not image_size:
+ return None
+
+ image_blocks = int(image_size) // 4096 - 1
+ assert image_blocks > 0, "blocks for {} must be positive".format(which)
+
+ # For sparse images, we will only check the blocks that are listed in the care
+ # map, i.e. the ones with meaningful data.
+ if "extfs_sparse_flag" in OPTIONS.info_dict:
+ simg = sparse_img.SparseImage(imgname)
+ care_map_ranges = simg.care_map.intersect(
+ rangelib.RangeSet("0-{}".format(image_blocks)))
+
+ # Otherwise for non-sparse images, we read all the blocks in the filesystem
+ # image.
+ else:
+ care_map_ranges = rangelib.RangeSet("0-{}".format(image_blocks))
+
+ return [which, care_map_ranges.to_string_raw()]
+
+
+def AddCareMapForAbOta(output_file, ab_partitions, image_paths):
+ """Generates and adds care_map.pb for a/b partition that has care_map.
+
+ Args:
+ output_file: The output zip file (needs to be already open),
+ or file path to write care_map.pb.
+ ab_partitions: The list of A/B partitions.
+ image_paths: A map from the partition name to the image path.
+ """
+ if not output_file:
+ raise ExternalError('Expected output_file for AddCareMapForAbOta')
+
+ care_map_list = []
+ for partition in ab_partitions:
+ partition = partition.strip()
+ if partition not in PARTITIONS_WITH_CARE_MAP:
+ continue
+
+ verity_block_device = "{}_verity_block_device".format(partition)
+ avb_hashtree_enable = "avb_{}_hashtree_enable".format(partition)
+ if (verity_block_device in OPTIONS.info_dict or
+ OPTIONS.info_dict.get(avb_hashtree_enable) == "true"):
+ if partition not in image_paths:
+ logger.warning('Potential partition with care_map missing from images: %s',
+ partition)
+ continue
+ image_path = image_paths[partition]
+ if not os.path.exists(image_path):
+ raise ExternalError('Expected image at path {}'.format(image_path))
+
+ care_map = GetCareMap(partition, image_path)
+ if not care_map:
+ continue
+ care_map_list += care_map
+
+ # adds fingerprint field to the care_map
+ # TODO(xunchang) revisit the fingerprint calculation for care_map.
+ partition_props = OPTIONS.info_dict.get(partition + ".build.prop")
+ prop_name_list = ["ro.{}.build.fingerprint".format(partition),
+ "ro.{}.build.thumbprint".format(partition)]
+
+ present_props = [x for x in prop_name_list if
+ partition_props and partition_props.GetProp(x)]
+ if not present_props:
+ logger.warning(
+ "fingerprint is not present for partition %s", partition)
+ property_id, fingerprint = "unknown", "unknown"
+ else:
+ property_id = present_props[0]
+ fingerprint = partition_props.GetProp(property_id)
+ care_map_list += [property_id, fingerprint]
+
+ if not care_map_list:
+ return
+
+ # Converts the list into proto buf message by calling care_map_generator; and
+ # writes the result to a temp file.
+ temp_care_map_text = MakeTempFile(prefix="caremap_text-",
+ suffix=".txt")
+ with open(temp_care_map_text, 'w') as text_file:
+ text_file.write('\n'.join(care_map_list))
+
+ temp_care_map = MakeTempFile(prefix="caremap-", suffix=".pb")
+ care_map_gen_cmd = ["care_map_generator", temp_care_map_text, temp_care_map]
+ RunAndCheckOutput(care_map_gen_cmd)
+
+ if not isinstance(output_file, zipfile.ZipFile):
+ shutil.copy(temp_care_map, output_file)
+ return
+ # output_file is a zip file
+ care_map_path = "META/care_map.pb"
+ if care_map_path in output_file.namelist():
+ # Copy the temp file into the OPTIONS.input_tmp dir and update the
+ # replace_updated_files_list used by add_img_to_target_files
+ if not OPTIONS.replace_updated_files_list:
+ OPTIONS.replace_updated_files_list = []
+ shutil.copy(temp_care_map, os.path.join(OPTIONS.input_tmp, care_map_path))
+ OPTIONS.replace_updated_files_list.append(care_map_path)
+ else:
+ ZipWrite(output_file, temp_care_map, arcname=care_map_path)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 5409194..cbb51e1 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -187,6 +187,9 @@
Raises:
ValueError: On invalid input.
"""
+ if not os.path.exists(input_file):
+ raise ValueError('%s is not exist' % input_file)
+
if not zipfile.is_zipfile(input_file):
raise ValueError('%s is not a valid zipfile' % input_file)
diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py
index 16cab4f..5e6c42d 100755
--- a/tools/releasetools/merge_target_files.py
+++ b/tools/releasetools/merge_target_files.py
@@ -96,12 +96,18 @@
from xml.etree import ElementTree
import add_img_to_target_files
+import apex_utils
+import build_image
import build_super_image
import check_target_files_vintf
import common
import img_from_target_files
import find_shareduid_violation
import ota_from_target_files
+import sparse_img
+import verity_utils
+
+from common import AddCareMapForAbOta, ExternalError, PARTITIONS_WITH_CARE_MAP
logger = logging.getLogger(__name__)
@@ -355,8 +361,9 @@
' includes %s.', partition, partition)
has_error = True
- if ('dynamic_partition_list' in framework_misc_info_keys) or (
- 'super_partition_groups' in framework_misc_info_keys):
+ if ('dynamic_partition_list'
+ in framework_misc_info_keys) or ('super_partition_groups'
+ in framework_misc_info_keys):
logger.error('Dynamic partition misc info keys should come from '
'the vendor instance of META/misc_info.txt.')
has_error = True
@@ -447,8 +454,8 @@
merged_dict[key] = framework_dict[key]
# Merge misc info keys used for Dynamic Partitions.
- if (merged_dict.get('use_dynamic_partitions') == 'true') and (
- framework_dict.get('use_dynamic_partitions') == 'true'):
+ if (merged_dict.get('use_dynamic_partitions')
+ == 'true') and (framework_dict.get('use_dynamic_partitions') == 'true'):
merged_dynamic_partitions_dict = common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dict, vendor_dict=merged_dict)
merged_dict.update(merged_dynamic_partitions_dict)
@@ -733,6 +740,71 @@
return cmd
+def validate_merged_apex_info(output_target_files_dir, partitions):
+ """Validates the APEX files in the merged target files directory.
+
+ Checks the APEX files in all possible preinstalled APEX directories.
+ Depends on the <partition>/apex/* APEX files within partitions.
+
+ Args:
+ output_target_files_dir: Output directory containing merged partition directories.
+ partitions: A list of all the partitions in the output directory.
+
+ Raises:
+ RuntimeError: if apex_utils fails to parse any APEX file.
+ ExternalError: if the same APEX package is provided by multiple partitions.
+ """
+ apex_packages = set()
+
+ apex_partitions = ('system', 'system_ext', 'product', 'vendor')
+ for partition in filter(lambda p: p in apex_partitions, partitions):
+ apex_info = apex_utils.GetApexInfoFromTargetFiles(
+ output_target_files_dir, partition, compressed_only=False)
+ partition_apex_packages = set([info.package_name for info in apex_info])
+ duplicates = apex_packages.intersection(partition_apex_packages)
+ if duplicates:
+ raise ExternalError(
+ 'Duplicate APEX packages found in multiple partitions: %s' %
+ ' '.join(duplicates))
+ apex_packages.update(partition_apex_packages)
+
+
+def generate_care_map(partitions, output_target_files_dir):
+ """Generates a merged META/care_map.pb file in the output target files dir.
+
+ Depends on the info dict from META/misc_info.txt, as well as built images
+ within IMAGES/.
+
+ Args:
+ partitions: A list of partitions to potentially include in the care map.
+ output_target_files_dir: The name of a directory that will be used to create
+ the output target files package after all the special cases are processed.
+ """
+ OPTIONS.info_dict = common.LoadInfoDict(output_target_files_dir)
+ partition_image_map = {}
+ for partition in partitions:
+ image_path = os.path.join(output_target_files_dir, 'IMAGES',
+ '{}.img'.format(partition))
+ if os.path.exists(image_path):
+ partition_image_map[partition] = image_path
+ # Regenerated images should have their image_size property already set.
+ image_size_prop = '{}_image_size'.format(partition)
+ if image_size_prop not in OPTIONS.info_dict:
+ # Images copied directly from input target files packages will need
+ # their image sizes calculated.
+ partition_size = sparse_img.GetImagePartitionSize(image_path)
+ image_props = build_image.ImagePropFromGlobalDict(
+ OPTIONS.info_dict, partition)
+ verity_image_builder = verity_utils.CreateVerityImageBuilder(
+ image_props)
+ image_size = verity_image_builder.CalculateMaxImageSize(partition_size)
+ OPTIONS.info_dict[image_size_prop] = image_size
+
+ AddCareMapForAbOta(
+ os.path.join(output_target_files_dir, 'META', 'care_map.pb'),
+ PARTITIONS_WITH_CARE_MAP, partition_image_map)
+
+
def process_special_cases(framework_target_files_temp_dir,
vendor_target_files_temp_dir,
output_target_files_temp_dir,
@@ -1074,6 +1146,9 @@
common.RunAndCheckOutput(split_sepolicy_cmd)
# TODO(b/178864050): Run tests on the combined.policy file.
+ # Run validation checks on the pre-installed APEX files.
+ validate_merged_apex_info(output_target_files_temp_dir, partition_map.keys())
+
generate_images(output_target_files_temp_dir, rebuild_recovery)
generate_super_empty_image(output_target_files_temp_dir, output_super_empty)
@@ -1087,12 +1162,14 @@
if not output_target_files:
return
+ # Create the merged META/care_map.bp
+ generate_care_map(partition_map.keys(), output_target_files_temp_dir)
+
output_zip = create_target_files_archive(output_target_files,
output_target_files_temp_dir,
temp_dir)
# Create the IMG package from the merged target files package.
-
if output_img:
img_from_target_files.main([output_zip, output_img])
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 3d0fc67..02b2b4d 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -1052,8 +1052,10 @@
target_info = common.BuildInfo(OPTIONS.target_info_dict, OPTIONS.oem_dicts)
source_info = common.BuildInfo(OPTIONS.source_info_dict, OPTIONS.oem_dicts)
vendor_prop = source_info.info_dict.get("vendor.build.prop")
- if vendor_prop and \
- vendor_prop.GetProp("ro.virtual_ab.compression.enabled") == "true":
+ vabc_used = vendor_prop and \
+ vendor_prop.GetProp("ro.virtual_ab.compression.enabled") == "true" and \
+ not OPTIONS.disable_vabc
+ if vabc_used:
# TODO(zhangkelvin) Remove this once FEC on VABC is supported
logger.info("Virtual AB Compression enabled, disabling FEC")
OPTIONS.disable_fec_computation = True
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 3db5559..313d1e6 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -799,7 +799,7 @@
value = "/".join(pieces)
elif key == "ro.build.description":
pieces = value.split(" ")
- assert len(pieces) == 5
+ assert pieces[-1].endswith("-keys")
pieces[-1] = EditTags(pieces[-1])
value = " ".join(pieces)
elif key.startswith("ro.") and key.endswith(".build.tags"):
@@ -1383,6 +1383,6 @@
main(sys.argv[1:])
except common.ExternalError as e:
print("\n ERROR: %s\n" % (e,))
- sys.exit(1)
+ raise
finally:
common.Cleanup()
diff --git a/tools/releasetools/test_add_img_to_target_files.py b/tools/releasetools/test_add_img_to_target_files.py
index 6b7a7db..a5850d3 100644
--- a/tools/releasetools/test_add_img_to_target_files.py
+++ b/tools/releasetools/test_add_img_to_target_files.py
@@ -21,9 +21,10 @@
import common
import test_utils
from add_img_to_target_files import (
- AddCareMapForAbOta, AddPackRadioImages,
- CheckAbOtaImages, GetCareMap)
+ AddPackRadioImages,
+ CheckAbOtaImages)
from rangelib import RangeSet
+from common import AddCareMapForAbOta, GetCareMap
OPTIONS = common.OPTIONS
@@ -174,9 +175,9 @@
def test_AddCareMapForAbOta(self):
image_paths = self._test_AddCareMapForAbOta()
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
"ro.system.build.fingerprint",
"google/sailfish/12345:user/dev-keys",
@@ -191,10 +192,10 @@
"""Partitions without care_map should be ignored."""
image_paths = self._test_AddCareMapForAbOta()
- AddCareMapForAbOta(
- None, ['boot', 'system', 'vendor', 'vbmeta'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(
+ care_map_file, ['boot', 'system', 'vendor', 'vbmeta'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
"ro.system.build.fingerprint",
"google/sailfish/12345:user/dev-keys",
@@ -226,9 +227,9 @@
),
}
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
"ro.system.build.fingerprint",
"google/sailfish/12345:user/dev-keys",
@@ -250,9 +251,9 @@
'vendor_verity_block_device': '/dev/block/vendor',
}
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(), "unknown",
"unknown", 'vendor', RangeSet("0-9").to_string_raw(), "unknown",
"unknown"]
@@ -281,9 +282,9 @@
),
}
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
"ro.system.build.thumbprint",
"google/sailfish/123:user/dev-keys",
@@ -300,9 +301,9 @@
# Remove vendor_image_size to invalidate the care_map for vendor.img.
del OPTIONS.info_dict['vendor_image_size']
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
"ro.system.build.fingerprint",
"google/sailfish/12345:user/dev-keys"]
@@ -317,25 +318,26 @@
del OPTIONS.info_dict['system_image_size']
del OPTIONS.info_dict['vendor_image_size']
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
+ care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
- self.assertFalse(
- os.path.exists(os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')))
+ self.assertFalse(os.path.exists(care_map_file))
def test_AddCareMapForAbOta_verityNotEnabled(self):
"""No care_map.pb should be generated if verity not enabled."""
image_paths = self._test_AddCareMapForAbOta()
OPTIONS.info_dict = {}
- AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
-
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ AddCareMapForAbOta(care_map_file, ['system', 'vendor'], image_paths)
+
self.assertFalse(os.path.exists(care_map_file))
def test_AddCareMapForAbOta_missingImageFile(self):
"""Missing image file should be considered fatal."""
image_paths = self._test_AddCareMapForAbOta()
image_paths['vendor'] = ''
- self.assertRaises(AssertionError, AddCareMapForAbOta, None,
+ care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
+ self.assertRaises(common.ExternalError, AddCareMapForAbOta, care_map_file,
['system', 'vendor'], image_paths)
@test_utils.SkipIfExternalToolsUnavailable()
diff --git a/tools/releasetools/test_merge_target_files.py b/tools/releasetools/test_merge_target_files.py
index 072bb01..4f61472 100644
--- a/tools/releasetools/test_merge_target_files.py
+++ b/tools/releasetools/test_merge_target_files.py
@@ -15,6 +15,7 @@
#
import os.path
+import shutil
import common
import test_utils
@@ -22,7 +23,7 @@
validate_config_lists, DEFAULT_FRAMEWORK_ITEM_LIST,
DEFAULT_VENDOR_ITEM_LIST, DEFAULT_FRAMEWORK_MISC_INFO_KEYS, copy_items,
item_list_to_partition_set, process_apex_keys_apk_certs_common,
- compile_split_sepolicy)
+ compile_split_sepolicy, validate_merged_apex_info)
class MergeTargetFilesTest(test_utils.ReleaseToolsTestCase):
@@ -274,3 +275,36 @@
'{OTP}/vendor/etc/selinux/plat_pub_versioned.cil '
'{OTP}/product/etc/selinux/mapping/30.0.cil').format(
OTP=product_out_dir))
+
+ def _copy_apex(self, source, output_dir, partition):
+ shutil.copy(
+ source,
+ os.path.join(output_dir, partition, 'apex', os.path.basename(source)))
+
+ @test_utils.SkipIfExternalToolsUnavailable()
+ def test_validate_merged_apex_info(self):
+ output_dir = common.MakeTempDir()
+ os.makedirs(os.path.join(output_dir, 'SYSTEM/apex'))
+ os.makedirs(os.path.join(output_dir, 'VENDOR/apex'))
+
+ self._copy_apex(
+ os.path.join(self.testdata_dir, 'has_apk.apex'), output_dir, 'SYSTEM')
+ self._copy_apex(
+ os.path.join(test_utils.get_current_dir(),
+ 'com.android.apex.compressed.v1.capex'), output_dir,
+ 'VENDOR')
+ validate_merged_apex_info(output_dir, ('system', 'vendor'))
+
+ @test_utils.SkipIfExternalToolsUnavailable()
+ def test_validate_merged_apex_info_RaisesOnPackageInMultiplePartitions(self):
+ output_dir = common.MakeTempDir()
+ os.makedirs(os.path.join(output_dir, 'SYSTEM/apex'))
+ os.makedirs(os.path.join(output_dir, 'VENDOR/apex'))
+
+ same_apex_package = os.path.join(self.testdata_dir, 'has_apk.apex')
+ self._copy_apex(same_apex_package, output_dir, 'SYSTEM')
+ self._copy_apex(same_apex_package, output_dir, 'VENDOR')
+ self.assertRaisesRegexp(
+ common.ExternalError,
+ 'Duplicate APEX packages found in multiple partitions: com.android.wifi',
+ validate_merged_apex_info, output_dir, ('system', 'vendor'))
diff --git a/tools/releasetools/test_ota_from_target_files.py b/tools/releasetools/test_ota_from_target_files.py
index 9f64849..661712a 100644
--- a/tools/releasetools/test_ota_from_target_files.py
+++ b/tools/releasetools/test_ota_from_target_files.py
@@ -33,7 +33,7 @@
GetTargetFilesZipWithoutPostinstallConfig,
Payload, PayloadSigner, POSTINSTALL_CONFIG,
StreamingPropertyFiles, AB_PARTITIONS)
-from apex_utils import GetSystemApexInfoFromTargetFiles
+from apex_utils import GetApexInfoFromTargetFiles
from test_utils import PropertyFilesTestCase
@@ -281,9 +281,9 @@
metadata)
@test_utils.SkipIfExternalToolsUnavailable()
- def test_GetSystemApexInfoFromTargetFiles(self):
+ def test_GetApexInfoFromTargetFiles(self):
target_files = construct_target_files(compressedApex=True)
- apex_infos = GetSystemApexInfoFromTargetFiles(target_files)
+ apex_infos = GetApexInfoFromTargetFiles(target_files, 'system')
self.assertEqual(len(apex_infos), 1)
self.assertEqual(apex_infos[0].package_name, "com.android.apex.compressed")
self.assertEqual(apex_infos[0].version, 1)
diff --git a/tools/test_post_process_props.py b/tools/test_post_process_props.py
index 12d52e5..236f9ed 100644
--- a/tools/test_post_process_props.py
+++ b/tools/test_post_process_props.py
@@ -53,7 +53,7 @@
p.make_as_comment()
self.assertTrue(p.is_comment())
- self.assertTrue("# a comment\n#a=b", str(p))
+ self.assertEqual("# a comment\n#a=b", str(p))
class PropListTestcase(unittest.TestCase):
def setUp(self):
@@ -251,5 +251,27 @@
# because it's explicitly allowed
self.assertTrue(override_optional_props(props, allow_dup=True))
+ def test_validateGrfProps(self):
+ stderr_redirect = io.StringIO()
+ with contextlib.redirect_stderr(stderr_redirect):
+ props = PropList("hello")
+ props.put("ro.board.first_api_level","25")
+
+ # ro.board.first_api_level must be less than or equal to the sdk version
+ self.assertFalse(validate_grf_props(props, 20))
+ self.assertTrue(validate_grf_props(props, 26))
+ self.assertTrue(validate_grf_props(props, 35))
+
+ # manually set ro.board.api_level to an invalid value
+ props.put("ro.board.api_level","20")
+ self.assertFalse(validate_grf_props(props, 26))
+
+ props.get_all_props()[-1].make_as_comment()
+ # manually set ro.board.api_level to a valid value
+ props.put("ro.board.api_level","26")
+ self.assertTrue(validate_grf_props(props, 26))
+ # ro.board.api_level must be less than or equal to the sdk version
+ self.assertFalse(validate_grf_props(props, 25))
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/tools/warn.py b/tools/warn.py
index 22ac872..5f796f5 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Copyright (C) 2019 The Android Open Source Project
#
@@ -28,7 +28,7 @@
def main():
os.environ['PYTHONPATH'] = os.path.dirname(os.path.abspath(__file__))
- subprocess.check_call(['/usr/bin/python', '-m', 'warn.warn'] + sys.argv[1:])
+ subprocess.check_call(['/usr/bin/python3', '-m', 'warn.warn'] + sys.argv[1:])
if __name__ == '__main__':
diff --git a/tools/warn/html_writer.py b/tools/warn/html_writer.py
index 026a6d0..be71b55 100644
--- a/tools/warn/html_writer.py
+++ b/tools/warn/html_writer.py
@@ -52,8 +52,8 @@
# emit_js_data():
from __future__ import print_function
-import cgi
import csv
+import html
import sys
# pylint:disable=relative-beyond-top-level
@@ -582,10 +582,7 @@
def emit_const_html_string_array(name, array, writer):
writer('const ' + name + ' = [')
for s in array:
- # Not using html.escape yet, to work for both python 2 and 3,
- # until all users switch to python 3.
- # pylint:disable=deprecated-method
- writer('"' + cgi.escape(strip_escape_string(s)) + '",')
+ writer('"' + html.escape(strip_escape_string(s)) + '",')
writer('];')
diff --git a/tools/warn/warn.py b/tools/warn/warn.py
index 56e8787..cb5daec 100755
--- a/tools/warn/warn.py
+++ b/tools/warn/warn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Copyright (C) 2019 The Android Open Source Project
#
diff --git a/tools/zipalign/ZipAlignMain.cpp b/tools/zipalign/ZipAlignMain.cpp
index 49be916..47ebd12 100644
--- a/tools/zipalign/ZipAlignMain.cpp
+++ b/tools/zipalign/ZipAlignMain.cpp
@@ -39,7 +39,7 @@
" <align>: alignment in bytes, e.g. '4' provides 32-bit alignment\n");
fprintf(stderr, " -c: check alignment only (does not modify file)\n");
fprintf(stderr, " -f: overwrite existing outfile.zip\n");
- fprintf(stderr, " -p: memory page alignment for stored shared object files\n");
+ fprintf(stderr, " -p: page-align uncompressed .so files\n");
fprintf(stderr, " -v: verbose output\n");
fprintf(stderr, " -z: recompress using Zopfli\n");
}