Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d44f2d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use symlinks in the build graph for jni libs"

parents 8da546b2 b195e7ab
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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 $$@
+8 −16
Original line number Diff line number Diff line
@@ -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
    $(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.