summaryrefslogtreecommitdiff
path: root/java/org/gnu/emacs/EmacsNative.java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2024-04-22 16:27:30 +0800
committerPo Lu <luangruo@yahoo.com>2024-04-22 16:30:15 +0800
commit3bcdf010a9f2576bac0d7f23af70fa9dff81ef95 (patch)
tree600a98286f5469579cf87dac7c920590b5af4082 /java/org/gnu/emacs/EmacsNative.java
parent4d9629b087fe6df941b553c6931b2f8996901e21 (diff)
Generate Android shared library list automatically
* .gitignore: Ignore new generated files. * cross/Makefile.in (src/Makefile): Remove leftover specification of the source Gnulib directory. * cross/ndk-build/ndk-build.mk.in (NDK_BUILD_READELF): New variable. * java/Makefile.in (CONFIG_FILE, ALL_DEPENDENCIES, READELF) (cf-stamp-1, cf-stamp): New variables and rules; compute the set of library files in the order of loading and generate a file with this information. (ALL_CLASS_FILES): New variable; if builddir is not srcdir, $($(CONFIG_FILE), $(CLASS_FILES)): Depend on EmacsConfig.java. add generated files in the build directory. (classes.dex): Adjust to match. * java/org/gnu/emacs/EmacsNative.java (EmacsNative) <static initializer>: Load shared libraries from EMACS_SHARED_LIBRARIES rather than a hard-coded list. * m4/ndk-build.m4 (ndk_INIT): Search for readelf... (ndk_CHECK_MODULES): ...and substitute its path as NDK_BUILD_READELF.
Diffstat (limited to 'java/org/gnu/emacs/EmacsNative.java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 567242f2ec3..9b3e60e1a84 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -321,39 +321,35 @@ public final class EmacsNative
static
{
- /* Older versions of Android cannot link correctly with shared
- libraries that link with other shared libraries built along
- Emacs unless all requisite shared libraries are explicitly
- loaded from Java.
+ /* A library search path misconfiguration prevents older versions of
+ Android from successfully loading application shared libraries
+ unless all requisite shared libraries provided by the application
+ are explicitly loaded from Java. The build process arranges that
+ EmacsConfig.EMACS_SHARED_LIBRARIES hold the names of each of
+ these libraries in the correct order, so load them now. */
- Every time you add a new shared library dependency to Emacs,
- please insert it here as well, before other shared libraries of
- which it might be a dependency. */
-
- libraryDeps = new String[] { "c++_shared", "gnustl_shared",
- "stlport_shared", "gabi++_shared",
- "png_emacs", "pcre_emacs",
- "selinux_emacs", "crypto_emacs",
- "packagelistparser_emacs",
- "gmp_emacs", "nettle_emacs",
- "p11-kit_emacs", "tasn1_emacs",
- "hogweed_emacs", "gnutls_emacs",
- "jpeg_emacs", "tiff_emacs",
- "icuuc_emacs", "xml2_emacs",
- "harfbuzz_emacs", "tree-sitter_emacs", };
+ libraryDeps = EmacsConfig.EMACS_SHARED_LIBRARIES;
for (String dependency : libraryDeps)
{
- try
- {
- System.loadLibrary (dependency);
- }
- catch (UnsatisfiedLinkError exception)
- {
- /* Ignore this exception. */
- }
+ /* Remove the "lib" prefix, if any. */
+ if (dependency.startsWith ("lib"))
+ dependency = dependency.substring (3);
+
+ /* If this library is provided by the operating system, don't
+ link to it. */
+ if (dependency.equals ("z")
+ || dependency.equals ("c")
+ || dependency.equals ("m")
+ || dependency.equals ("dl")
+ || dependency.equals ("log")
+ || dependency.equals ("android"))
+ continue;
+
+ System.loadLibrary (dependency);
}
+ /* At this point, it should be alright to load Emacs. */
System.loadLibrary ("emacs");
};
};