diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd43a06fa..cf87e135d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,9 @@ jobs: with: cache-read-only: true + - name: Install NDK + run: echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.0.11718014" + - name: Spotless Check run: ./gradlew spotlessCheck @@ -57,6 +60,9 @@ jobs: distribution: temurin java-version: 21 + - name: Install NDK + run: echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.0.11718014" + - name: Install Rust Toolchain run: rustup update && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android && rustup component add rustfmt clippy @@ -131,6 +137,9 @@ jobs: distribution: temurin java-version: 21 + - name: Install NDK + run: echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.0.11718014" + - name: Install Rust Toolchain run: rustup update && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android && rustup component add rustfmt clippy diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index fcfca5787..0775233f0 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -18,6 +18,9 @@ jobs: distribution: temurin java-version: 21 + - name: Install NDK + run: echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.0.11718014" + - name: Install Rust Toolchain run: rustup update && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0db74f7f9..21fd40844 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -21,7 +21,7 @@ plugins { android { compileSdk = 34 - ndkVersion = "26.2.11394342" + ndkVersion = "27.0.11718014-beta1" splits { abi { @@ -88,6 +88,11 @@ android { ndk { debugSymbolLevel = "FULL" } + externalNativeBuild { + cmake { + arguments += "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON" + } + } } flavorDimensions += "api" @@ -209,6 +214,8 @@ dependencies { implementation(libs.androidx.core.splashscreen) implementation(libs.androidx.constraintlayout.compose) + implementation(libs.androidx.graphics.path) + // https://developer.android.com/jetpack/androidx/releases/lifecycle implementation(libs.androidx.lifecycle.process) implementation(libs.androidx.lifecycle.compose) diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 3227dabf7..c28f540e8 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -85,6 +85,7 @@ FetchContent_Declare( FetchContent_MakeAvailable(Corrosion) corrosion_import_crate(MANIFEST_PATH ../rust/Cargo.toml) +corrosion_add_target_local_rustflags(ehviewer_rust "-Clink-args=-Wl,-z,max-page-size=16384") # Build and link our app's native lib add_library(${PROJECT_NAME} SHARED archive.c border.c gifutils.c natsort/strnatcmp.c) diff --git a/app/src/main/cpp/archive.c b/app/src/main/cpp/archive.c index 34736a45b..ffabb59a3 100644 --- a/app/src/main/cpp/archive.c +++ b/app/src/main/cpp/archive.c @@ -54,8 +54,9 @@ static archive_ctx **ctx_pool; static void *mempool = NULL; static size_t *mempoolofs = NULL; +static int page_size = 0; -#define PAGE_ALIGN(x) ((x + ~PAGE_MASK) & PAGE_MASK) +#define PAGE_ALIGN(x) ((x + page_size - 1) & ~(page_size - 1)) #define MEMPOOL_ADDR_BY_SORTED_IDX(x) (mempool + (index ? mempoolofs[index - 1] : 0)) #define MEMPOOL_SIZE (mempoolofs[entryCount - 1]) @@ -282,6 +283,7 @@ JNIEXPORT jint JNICALL Java_com_hippo_ehviewer_jni_ArchiveKt_openArchive(JNIEnv *env, jclass thiz, jint fd, jlong size, jboolean sort_entries) { EH_UNUSED(env); EH_UNUSED(thiz); + page_size = getpagesize(); archive_ctx *ctx = NULL; archiveAddr = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); if (archiveAddr == MAP_FAILED) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4c783ac64..9ad3d65b6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ androidx-browser = "1.8.0" androidx-constraintlayout-compose = "1.1.0-alpha13" androidx-core = "1.13.0" androidx-core-splashscreen = "1.2.0-alpha01" +androidx-graphics-path = "1.0.0" androidx-lifecycle = "2.8.0-beta01" androidx-navigation = "2.8.0-alpha07" androidx-paging = "3.3.0-beta01" @@ -42,6 +43,7 @@ androidx-browser = { module = "androidx.browser:browser", version.ref = "android androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout-compose" } androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx-core-splashscreen" } +androidx-graphics-path = { module = "androidx.graphics:graphics-path", version.ref = "androidx-graphics-path" } androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "androidx-lifecycle" } androidx-lifecycle-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }