From b1aca0578c4bd1597f6dd79aea2196c400afc694 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Wed, 2 Jul 2025 23:17:00 +0800 Subject: [PATCH] Build a single shared library --- app/src/main/cpp/CMakeLists.txt | 9 ++++++--- app/src/main/cpp/libehviewer.map.txt | 7 +++++++ app/src/main/rust/Cargo.toml | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 app/src/main/cpp/libehviewer.map.txt diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index ee4e3e1f3..0bc61eb6d 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -143,9 +143,12 @@ corrosion_import_crate( FEATURES $,android-26,android> FLAGS $<$>:-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort> ) -corrosion_link_libraries(ehviewer_rust webp webpdemux) -corrosion_add_target_local_rustflags(ehviewer_rust "-Clink-args=-Wl,-z,max-page-size=16384") +corrosion_link_libraries(ehviewer_rust android jnigraphics log webp webpdemux) # Build and link our app's native lib add_library(${PROJECT_NAME} SHARED archive.c gifutils.c hash.c natsort/strnatcmp.c) -target_link_libraries(${PROJECT_NAME} ehviewer_rust archive_static log jnigraphics -Wl,--exclude-libs,ALL) +target_link_libraries( + ${PROJECT_NAME} archive_static ehviewer_rust + -Wl,-u,JNI_OnLoad -Wl,--undefined-glob,Java_* + -Wl,--version-script,${CMAKE_SOURCE_DIR}/libehviewer.map.txt +) diff --git a/app/src/main/cpp/libehviewer.map.txt b/app/src/main/cpp/libehviewer.map.txt new file mode 100644 index 000000000..a8b7672c1 --- /dev/null +++ b/app/src/main/cpp/libehviewer.map.txt @@ -0,0 +1,7 @@ +{ + global: + JNI_OnLoad; + Java_*; + local: + *; +}; diff --git a/app/src/main/rust/Cargo.toml b/app/src/main/rust/Cargo.toml index d26e938f6..11dbb6ae2 100644 --- a/app/src/main/rust/Cargo.toml +++ b/app/src/main/rust/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition = "2024" [lib] -crate-type = ["cdylib"] +crate-type = ["staticlib"] [features] jvm = ["dep:jni", "dep:jni_fn"]