diff --git a/core/definitions.mk b/core/definitions.mk index 20b8cf64eb..ff435e20c9 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2628,17 +2628,15 @@ $(foreach t,$(1),\ endef # Define a rule to create a symlink to a file. -# $(1): full path to source +# $(1): any dependencies # $(2): source (may be relative) # $(3): full path to destination define symlink-file $(eval $(_symlink-file)) endef -# Order-only dependency because make/ninja will follow the link when checking -# the timestamp, so the file must exist define _symlink-file -$(3): | $(1) +$(3): $(1) @echo "Symlink: $$@ -> $(2)" @mkdir -p $(dir $$@) @rm -rf $$@ diff --git a/core/install_jni_libs_internal.mk b/core/install_jni_libs_internal.mk index eac0414130..25a16a373f 100644 --- a/core/install_jni_libs_internal.mk +++ b/core/install_jni_libs_internal.mk @@ -49,29 +49,21 @@ else ifneq ($(my_jni_shared_libraries),) # not my_embed_jni my_shared_library_path := $(call get_non_asan_path,\ $($(my_2nd_arch_prefix)TARGET_OUT$(partition_tag)_SHARED_LIBRARIES)) my_installed_library := $(addprefix $(my_shared_library_path)/, $(my_jni_filenames)) - # Do not use order-only dependency, because we want to rebuild the image if an jni is updated. - $(LOCAL_INSTALLED_MODULE) : $(my_installed_library) ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(my_installed_library) # Create symlink in the app specific lib path # Skip creating this symlink when running the second part of a target sanitization build. ifeq ($(filter address,$(SANITIZE_TARGET)),) - ifdef LOCAL_POST_INSTALL_CMD - # Add a shell command separator - LOCAL_POST_INSTALL_CMD += ; - endif - my_symlink_target_dir := $(patsubst $(PRODUCT_OUT)%,%,\ - $(my_shared_library_path)) - LOCAL_POST_INSTALL_CMD += \ - mkdir -p $(my_app_lib_path) \ - $(foreach lib, $(my_jni_filenames), ;ln -sf $(my_symlink_target_dir)/$(lib) $(my_app_lib_path)/$(lib)) - $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) - else - ifdef LOCAL_POST_INSTALL_CMD - $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) - endif + $(my_shared_library_path)) + $(foreach lib,$(my_jni_filenames),\ + $(call symlink-file, \ + $(my_shared_library_path)/$(lib), \ + $(my_symlink_target_dir)/$(lib), \ + $(my_app_lib_path)/$(lib)) \ + $(eval $$(LOCAL_INSTALLED_MODULE) : $$(my_app_lib_path)/$$(lib)) \ + $(eval ALL_MODULES.$$(LOCAL_MODULE).INSTALLED += $$(my_app_lib_path)/$$(lib))) endif # Clear jni_shared_libraries to not embed it into the apk.