Merge "Add /file_contexts.bin only to devices which need it"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 9d3fc23..e0c826c 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -400,6 +400,11 @@
$(call add-clean-step, rm -rf $(TARGET_OUT_ETC)/init)
+# Libraries are moved from {system|vendor}/lib to ./lib/framework, ./lib/vndk, etc.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/core/base_rules.mk b/core/base_rules.mk
index c65d3ce..1fb516b 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -78,6 +78,8 @@
endif
endif
+my_module_is_soong := $(if $(filter $(OUT_DIR)/soong/%,$(LOCAL_MODULE_MAKEFILE)),true,false)
+
# Ninja has an implicit dependency on the command being run, and kati will
# regenerate the ninja manifest if any read makefile changes, so there is no
# need to have dependencies on makefiles.
@@ -163,6 +165,14 @@
endif
my_module_path := $(patsubst %/,%,$(my_module_path))
my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
+
+# my_module_default_path is the path that is automatically chosen according to the attributes of
+# a module. It is used when the module does not explicitly specify install path using LOCAL_MODULE_PATH.
+# If LOCAL_MODULE_PATH is specified, it is always respected and my_module_default_path is
+# ignored. However, for shared libraries, such conflict generates warning so that module owner
+# can place the library in the correct location (, stop using LOCAL_MODULE_PATH, or migrate to Soong to
+# be better).
+my_module_default_path :=
ifdef LOCAL_IS_HOST_MODULE
partition_tag :=
else
@@ -180,20 +190,135 @@
partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
endif
endif
-ifeq ($(my_module_path),)
- install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
- ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
- install_path_var := $(install_path_var)_PRIVILEGED
- endif
+install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
+ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
+ install_path_var := $(install_path_var)_PRIVILEGED
+endif
- my_module_path := $($(install_path_var))
- ifeq ($(strip $(my_module_path)),)
- $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
+my_module_default_path := $($(install_path_var))
+ifeq ($(strip $(my_module_path)$(my_module_default_path)),)
+ $(call pretty-error,internal error in base_rules.mk; $(install_path_var) is not defined.)
+endif
+
+# Determine lib_type and do some sanity checks.
+ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ ifneq ($(filter $(LOCAL_MODULE),$(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))),)
+ ifneq ($(partition_tag),)
+ $(call pretty-error,"NDK library must be installed at system partition, where other libraries will look for it. It cannot be moved.")
+ endif
+ lib_type := ndk
+ else ifneq ($(filter $(LOCAL_MODULE),$(VNDK_LIBRARIES) $(VNDK_INDIRECT_LIBRARIES)),)
+ ifneq ($(partition_tag),)
+ $(call pretty-error,"VNDK library must be installed at system partition. DO NOT modify VNDK_LIBRARIES or VNDK_LIBRARIES. \
+If your library needs to be shared between system.img and vendor.img then define it as a VNDK-ext library. Use vndk_ext_library {...} \
+in Android.bp to do so.")
+ endif
+ lib_type := vndk
+ else ifneq ($(filter $(LOCAL_MODULE),$(BOARD_SAME_PROCESS_HAL_DEPS)),)
+ # List of libraries implementing same-process HALs (and their internal sub-libraries) is
+ # defined by vendors.
+ ifeq ($(partition_tag),)
+ $(call pretty-error,Sameprocess HAL must not be installed at system partition)
+ endif
+ lib_type := sameprocess_hal
+ else ifeq ($(LOCAL_IS_HOST_MODULE)$(partition_tag),)
+ lib_type := framework
+ else ifneq ($(partition_tag),_DATA)
+ # Here, vendor means vendor/oem/odm
+ lib_type := vendor_provided
+ else
+ # Test, samples lib falls into this. No lib_type required for them.
+ ifeq ($(filter tests samples,$(LOCAL_MODULE_TAGS)),)
+ $(call pretty-warning,Cannot determine the type of this library)
+ endif
+ lib_type :=
+ endif
+else
+ lib_type :=
+endif
+
+# This is the default path until N. From O, the default path is changed.
+# Let's save the old default path in case we need a symlink to it later.
+my_module_pre_o_default_path := $(my_module_default_path)
+
+# Special case for pre_o_default_path of Soong defined modules.
+# For those modules, we guess their pre_o_default_path by removing /ndk, /vndk, etc.
+# from their LOCAL_MODULE_PATH. This is because relative_install_path is already
+# embedded to my_module_path.
+ifeq ($(my_module_is_soong),true)
+ifndef LOCAL_IS_HOST_MODULE
+ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ my_module_pre_o_default_path := $(my_module_path)
+ my_module_pre_o_default_path := $(subst /vndk-ext,,$(my_module_pre_o_default_path))
+ my_module_pre_o_default_path := $(subst /vndk,,$(my_module_pre_o_default_path))
+ my_module_pre_o_default_path := $(subst /ndk,,$(my_module_pre_o_default_path))
+ my_module_pre_o_default_path := $(subst /sameprocess,,$(my_module_pre_o_default_path))
+endif
+endif
+endif
+
+# Amend the default_path once again depending on lib_type. This is new from O.
+ifeq ($(lib_type),vndk)
+ my_module_default_path := $(my_module_default_path)/vndk
+ # TODO(b/35020246): before P, we should support installing two snapshots of VNDK
+ # libraries. One for framework libs and execs and the other for vendor libs and execs.
+else ifeq ($(lib_type),ndk)
+ my_module_default_path := $(my_module_default_path)/ndk
+else ifeq ($(lib_type),sameprocess_hal)
+ my_module_default_path := $(my_module_default_path)/sameprocess
+endif
+
+# Relative path is appended to path resolved so far
+ifneq ($(my_module_relative_path),)
+ my_module_default_path := $(my_module_default_path)/$(my_module_relative_path)
+ my_module_pre_o_default_path := $(my_module_pre_o_default_path)/$(my_module_relative_path)
+ ifneq ($(my_module_path),)
+ my_module_path := $(my_module_path)/$(my_module_relative_path)
endif
endif
-ifneq ($(my_module_relative_path),)
- my_module_path := $(my_module_path)/$(my_module_relative_path)
+
+_lib_moved :=
+ifeq ($(my_module_path),)
+ # If LOCAL_MODULE_PATH is not specified, use the automatically determined path.
+ my_module_path := $(my_module_default_path)
+
+ # Mark if the lib is installed to a different path than before. With this hint,
+ # a symlink is created if BOARD_SYMLINK_FOR_LIBS is true.
+ ifneq ($(my_module_path),$(my_module_pre_o_default_path))
+ _lib_moved := true
+ endif
+else
+ # If LOCAL_MODULE_PATH is specified, we respect it.
+ ifndef LOCAL_IS_HOST_MODULE
+ ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ ifeq ($(filter $(TARGET_OUT_DATA)%,$(my_module_path)),)
+ # However, we are kind enough to warn if it seems to be wrong.
+ # Warn only for Android.mk defined shared libraries that will be installed
+ # to system or vendor partition. For other types of files - especially
+ # Soong-defined libs -, we don't warn because Soong always gives us correct
+ # paths.
+ ifeq ($(my_module_is_soong),false)
+ ifneq ($(my_module_path),$(my_module_default_path))
+ # TODO(b/35020635): s/warning/error/
+ $(call pretty-warning,$(lib_type) library must be installed to \
+$(subst $(PRODUCT_OUT)/,,$(my_module_default_path)) but requested to be installed at \
+$(subst $(PRODUCT_OUT)/,,$(my_module_path)). Please fix.)
+ endif
+ else
+ # For Soong-defined module, symlink is provided if the path has been amended
+ # ...except for vndk-ext libraries because there already is a symlink for the
+ # vndk (unmodified) version of the vndk-ext library.
+ ifneq ($(my_module_path),$(my_module_pre_o_default_path))
+ ifeq ($(filter vndk-ext,$(subst /,$(space),$(my_module_path))),)
+ _lib_moved := true
+ endif
+ endif
+ endif
+ endif
+ endif
+ endif
endif
+
endif # not LOCAL_UNINSTALLABLE_MODULE
ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
@@ -384,8 +509,30 @@
# Rule to install the module's companion symlinks
my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
+
+# If this lib is installed to the different directory than before,
+# make a symlink from the old path to the new path.
+# This symlink is required because there are so many plances that expect the old
+# path (e.g. systemproperty rild.libpath). Until that places are all fixed,
+# we keep this symlink.
+# TODO(b/34917183): remove symlinks after everything migrations to the new paths;
+# this should be done before O launch unless it will be a security hole that
+# we can't restrict access to a certain set of libraries by using the directory
+# path.
+ifneq ($(BOARD_SYMLINK_FOR_LIBS),false)
+ifeq ($(_lib_moved),true)
+ my_installed_symlinks += $(my_module_pre_o_default_path)/$(my_installed_module_stem)
+endif
+else
+# Symlinks for ndk libs are permanent.
+ifeq ($(lib_type)$(_lib_moved),ndktrue)
+ my_installed_symlinks += $(my_module_pre_o_default_path)/$(my_installed_module_stem)
+endif
+endif
+
+# Make a symlink $(symlink) -> $(LOCAL_INSTALLED_MODULE)
$(foreach symlink,$(my_installed_symlinks),\
- $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
+ $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(LOCAL_INSTALLED_MODULE),$(symlink),true))
$(my_all_targets) : | $(my_installed_symlinks)
diff --git a/core/definitions.mk b/core/definitions.mk
index 1a7cc50..aae269b 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2845,8 +2845,10 @@
# Define a rule to create a symlink to a file.
# $(1): full path to source
-# $(2): source (may be relative)
-# $(3): full path to destination
+# $(2): target of the link
+# $(3): full path of the symlink
+# $(4): (optional) when set to true, $(2) is recognized as a path from the build root and
+# thus -r option is used to link $(3) to $(2). Off by default.
define symlink-file
$(eval $(_symlink-file))
endef
@@ -2858,7 +2860,9 @@
@echo "Symlink: $$@ -> $(2)"
@mkdir -p $(dir $$@)
@rm -rf $$@
- $(hide) ln -sf $(2) $$@
+ $(if $(filter true,$(4)),\
+ $(hide) python -c "import os.path; import os; os.symlink(os.path.relpath('$(2)','$(dir $(3))'), '$$@')",\
+ $(hide) ln -sf $(2) $$@)
endef
###########################################################
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 576c8ab..ff8a51d 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -69,7 +69,9 @@
echo ''; \
echo ' "ArtUseReadBarrier": $(if $(filter false,$(PRODUCT_ART_USE_READ_BARRIER)),false,true),'; \
echo ''; \
- echo ' "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)"'; \
+ echo ' "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)",'; \
+ echo ''; \
+ echo ' "SameProcessHalDeps": [$(if $(BOARD_SAME_PROCESS_HAL_DEPS),"$(subst $(space),"$(comma)",$(BOARD_SAME_PROCESS_HAL_DEPS))")]'; \
echo '}') > $(SOONG_VARIABLES_TMP); \
if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk
index d8f900e..1455a44 100644
--- a/core/tasks/tools/compatibility.mk
+++ b/core/tasks/tools/compatibility.mk
@@ -37,13 +37,14 @@
$(compatibility_zip): PRIVATE_TOOLS := $(test_tools)
$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name)
$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config)
-$(compatibility_zip): $(test_artifacts) $(test_tools) $(test_suite_dynamic_config) | $(ADB) $(ACP)
+$(compatibility_zip): $(test_artifacts) $(test_tools) $(test_suite_dynamic_config) $(SOONG_ZIP) | $(ADB) $(ACP)
# Make dir structure
$(hide) mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases
# Copy tools
$(hide) $(ACP) -fp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools
$(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) $(ACP) -fp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic)
- $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
+ $(hide) find $(dir $@)/$(PRIVATE_NAME) | sort >$@.list
+ $(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@) -l $@.list
# Reset all input variables
test_suite_name :=
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 51adbdb..cd33693 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -20,6 +20,8 @@
PRODUCT_PACKAGES += \
adb \
adbd \
+ android.hardware.configstore@1.0-impl \
+ android.hardware.configstore@1.0-service \
android.hidl.allocator@1.0-service \
android.hidl.memory@1.0-impl \
atrace \
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index ed087c1..d8fcc41 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -718,6 +718,9 @@
diff_total = len(diff_queue)
patches = [None] * diff_total
+ if sys.stdout.isatty():
+ global diff_done
+ diff_done = 0
# Using multiprocessing doesn't give additional benefits, due to the
# pattern of the code. The diffing work is done by subprocess.call, which
@@ -758,7 +761,9 @@
with lock:
patches[patch_index] = (xf_index, patch)
if sys.stdout.isatty():
- progress = len(patches) * 100 / diff_total
+ global diff_done
+ diff_done += 1
+ progress = diff_done * 100 / diff_total
# '\033[K' is to clear to EOL.
print(' [%d%%] %s\033[K' % (progress, xf.tgt_name), end='\r')
sys.stdout.flush()