1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-26 15:21:51 -08:00

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.
This commit is contained in:
Po Lu 2024-04-22 16:27:30 +08:00
parent 4d9629b087
commit 3bcdf010a9
6 changed files with 125 additions and 34 deletions

View file

@ -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");
};
};