From 120d418b7e604e466ca0ad9aa9dee75ee3ba7000 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 2 Oct 2024 09:19:57 +0200 Subject: [PATCH] android: switch to monolibtic mode (#12576) We can get rid of the `libs` and `sdcv` symlink in application files. Depend on koreader/koreader-base#1920. Close #12348. --- base | 2 +- .../apps/reader/modules/readerdictionary.lua | 16 ++++++++++++---- make/android.mk | 1 - 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/base b/base index bca8dc25a..168d001c3 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit bca8dc25ac9ccb7e410644cdcb8b791e79d1553e +Subproject commit 168d001c3b9c6374633564a7dff78d7dbe1d8e50 diff --git a/frontend/apps/reader/modules/readerdictionary.lua b/frontend/apps/reader/modules/readerdictionary.lua index 377d2b43b..d550d360d 100644 --- a/frontend/apps/reader/modules/readerdictionary.lua +++ b/frontend/apps/reader/modules/readerdictionary.lua @@ -26,6 +26,7 @@ local util = require("util") local _ = require("gettext") local Input = Device.input local T = ffiUtil.template +local android = Device:isAndroid() and require("android") -- We'll store the list of available dictionaries as a module local -- so we only have to look for them on the first :init() @@ -785,7 +786,14 @@ function ReaderDictionary:rawSdcv(words, dict_names, fuzzy_search, lookup_progre break -- don't do any more lookup on additional dict_dirs end - local args = {"./sdcv", "--utf8-input", "--utf8-output", "--json-output", "--non-interactive", "--data-dir", dict_dir} + local args = { + android and (android.nativeLibraryDir .. "/libsdcv.so") or "./sdcv", + "--utf8-input", + "--utf8-output", + "--json-output", + "--non-interactive", + "--data-dir", dict_dir, + } if not fuzzy_search then table.insert(args, "--exact-search") end @@ -820,11 +828,11 @@ function ReaderDictionary:rawSdcv(words, dict_names, fuzzy_search, lookup_progre cmd = cmd .. "; echo" -- NOTE: Bionic doesn't support rpath, but does honor LD_LIBRARY_PATH... -- Give it a shove so it can actually find the STL. - if Device:isAndroid() then - C.setenv("LD_LIBRARY_PATH", "./libs", 1) + if android then + C.setenv("LD_LIBRARY_PATH", android.nativeLibraryDir, 1) end local completed, results_str = Trapper:dismissablePopen(cmd, lookup_progress_msg) - if Device:isAndroid() then + if android then -- NOTE: It's unset by default, so this is perfectly fine. C.unsetenv("LD_LIBRARY_PATH") end diff --git a/make/android.mk b/make/android.mk index d2ac084f2..83e1f2084 100644 --- a/make/android.mk +++ b/make/android.mk @@ -83,7 +83,6 @@ update: all # binaries are stored as shared libraries to prevent W^X exception on Android 10+ # https://developer.android.com/about/versions/10/behavior-changes-10#execute-permission llvm-strip --strip-unneeded $(INSTALL_DIR)/koreader/sdcv -o $(ANDROID_LIBS)/libsdcv.so - printf '%s\n' 'libs .' 'sdcv libsdcv.so' >$(ANDROID_ASSETS)/module/map.txt # assets are compressed manually and stored inside the APK. cd $(INSTALL_DIR)/koreader && \ ./tools/mk7z.sh \