Skip to content

Commit

Permalink
fix(android): fix compile when rwh_04 or rwh_05 is active (#1012)
Browse files Browse the repository at this point in the history
* fix(android): fix compile when `rwh_04` or `rwh_05` is active

closes #1011

* test features
  • Loading branch information
amrbashir authored Nov 11, 2024
1 parent 73741a7 commit 88f0b41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ jobs:
- { id: windows, target: x86_64-pc-windows-msvc, os: windows-latest }
# Ubuntu with default features
- { id: ubuntu, target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
# Ubuntu without features
- {
id: ubuntu-without-feat,
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
options: --no-default-features,
}
# macOS
- { id: macos, target: x86_64-apple-darwin, os: macos-latest }
# Android on Ubuntu
Expand All @@ -30,13 +23,17 @@ jobs:
}
# iOS on Ubuntu
- { id: ios, target: aarch64-apple-ios, os: macos-latest }
features:
- "" # default features
- "serde" # serde + default features
- "rwh_04,rwh_05,rwh_06" # rwh features

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
OPTIONS: ${{ matrix.platform.options }}
FEATURES: ${{ format(',{0}', matrix.platform.features ) }}
FEATURES: ${{ format(',{0}', matrix.features ) }}
CMD: ${{ matrix.platform.cmd }}

runs-on: ${{ matrix.platform.os }}
Expand All @@ -59,11 +56,6 @@ jobs:
sudo apt-get update
sudo apt-get install -y libgtk-3-dev
- name: Install ayatana-libappindicator (ubuntu[default/tray] only)
if: matrix.platform.id == 'ubuntu'
run: |
sudo apt-get install -y libayatana-appindicator3-dev
- name: Install GCC Multilib
if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')
run: sudo apt-get install gcc-multilib
Expand Down Expand Up @@ -93,18 +85,18 @@ jobs:

- name: Build with all features enabled
shell: bash
run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- name: Build tests with all features enabled
shell: bash
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- name: Run tests with all features enabled
shell: bash
if: (
!contains(matrix.platform.target, 'android') &&
!contains(matrix.platform.target, 'ios'))
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
run: cargo $CMD test --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

- uses: dtolnay/rust-toolchain@nightly
if: (
Expand All @@ -119,7 +111,7 @@ jobs:
!contains(matrix.platform.target, 'android') &&
!contains(matrix.platform.target, 'ios'))
shell: bash
run: cargo +nightly miri test --target ${{ matrix.platform.target }} $OPTIONS --features serde,$FEATURES
run: cargo +nightly miri test --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES

test_tao_macros:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ targets = [
[features]
default = [ "rwh_06" ]
serde = [ "dep:serde", "dpi/serde" ]
rwh_04 = [ "dep:rwh_04" ]
rwh_05 = [ "dep:rwh_05" ]
rwh_06 = [ "dep:rwh_06" ]

[workspace]
members = [ "tao-macros" ]
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ impl Window {
pub fn raw_window_handle_rwh_04(&self) -> rwh_04::RawWindowHandle {
// TODO: Use main activity instead?
let mut handle = rwh_04::AndroidNdkHandle::empty();
if let Some(w) = ndk_glue::window_manager() {
if let Some(w) = ndk_glue::window_manager().as_ref() {
handle.a_native_window = w.as_obj().as_raw() as *mut _;
} else {
panic!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.");
Expand All @@ -712,7 +712,7 @@ impl Window {
pub fn raw_window_handle_rwh_05(&self) -> rwh_05::RawWindowHandle {
// TODO: Use main activity instead?
let mut handle = rwh_05::AndroidNdkWindowHandle::empty();
if let Some(w) = ndk_glue::window_manager() {
if let Some(w) = ndk_glue::window_manager().as_ref() {
handle.a_native_window = w.as_obj().as_raw() as *mut _;
} else {
panic!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.");
Expand Down

0 comments on commit 88f0b41

Please sign in to comment.