From 2ac3a7bb99ef7ab9ccb7f651be657871b70118f8 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 29 Jul 2024 09:51:52 +0200 Subject: [PATCH] Fix `unexpected-cfgs` by adding `api-level-30` feature and removing `test` Some code copied from the NDK carried over the respective `feature` `cfg` guards, without ever adding the feature to the `[features]` list in `Cargo.toml`. Now that Rust detects these mishaps, we can fix it by removing `test` (bindings don't seem to be run-tested) and reexpose `ConfigurationRef::screen_round()` which was behind a previously unsettable `feature = "api-level-30"`. Also remove `unsafe impl Send/Sync for ConfigurationRef` since the upstream `ndk` already declares `Configuration` to be `Send` and `Sync`, and `RwLock` and `Arc` carry that through. --- android-activity/Cargo.toml | 1 + android-activity/src/config.rs | 2 -- android-activity/src/game_activity/ffi.rs | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/android-activity/Cargo.toml b/android-activity/Cargo.toml index 59b0b54..c05ad3f 100644 --- a/android-activity/Cargo.toml +++ b/android-activity/Cargo.toml @@ -27,6 +27,7 @@ rust-version = "1.69.0" default = [] game-activity = [] native-activity = [] +api-level-30 = ["ndk/api-level-30"] [dependencies] log = "0.4" diff --git a/android-activity/src/config.rs b/android-activity/src/config.rs index 7d818ec..2c3dce8 100644 --- a/android-activity/src/config.rs +++ b/android-activity/src/config.rs @@ -28,8 +28,6 @@ impl PartialEq for ConfigurationRef { } } impl Eq for ConfigurationRef {} -unsafe impl Send for ConfigurationRef {} -unsafe impl Sync for ConfigurationRef {} impl fmt::Debug for ConfigurationRef { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/android-activity/src/game_activity/ffi.rs b/android-activity/src/game_activity/ffi.rs index e8be24c..51063ff 100644 --- a/android-activity/src/game_activity/ffi.rs +++ b/android-activity/src/game_activity/ffi.rs @@ -16,14 +16,14 @@ use jni_sys::*; use libc::{pthread_cond_t, pthread_mutex_t, pthread_t}; use ndk_sys::{AAssetManager, AConfiguration, ALooper, ALooper_callbackFunc, ANativeWindow, ARect}; -#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "arm"))] +#[cfg(all(any(target_os = "android"), target_arch = "arm"))] include!("ffi_arm.rs"); -#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "aarch64"))] +#[cfg(all(any(target_os = "android"), target_arch = "aarch64"))] include!("ffi_aarch64.rs"); -#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86"))] +#[cfg(all(any(target_os = "android"), target_arch = "x86"))] include!("ffi_i686.rs"); -#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86_64"))] +#[cfg(all(any(target_os = "android"), target_arch = "x86_64"))] include!("ffi_x86_64.rs");