Add CI for android (#1900)
* Add CI for android * Don't use arboard on Android * Fix Android support for eframe
This commit is contained in:
parent
923b67ef9c
commit
48e7f219a3
4 changed files with 32 additions and 13 deletions
15
.github/workflows/rust.yml
vendored
15
.github/workflows/rust.yml
vendored
|
@ -195,3 +195,18 @@ jobs:
|
||||||
- run: rustup target add wasm32-unknown-unknown
|
- run: rustup target add wasm32-unknown-unknown
|
||||||
- run: ./sh/setup_web.sh
|
- run: ./sh/setup_web.sh
|
||||||
- run: ./sh/wasm_bindgen_check.sh
|
- run: ./sh/wasm_bindgen_check.sh
|
||||||
|
|
||||||
|
android:
|
||||||
|
name: android
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: 1.61.0
|
||||||
|
target: aarch64-linux-android
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- run: cargo check --features wgpu --target aarch64-linux-android
|
||||||
|
working-directory: eframe
|
||||||
|
|
|
@ -468,7 +468,7 @@ mod wgpu_integration {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// SAFETY: `window` must outlive `painter`.
|
// SAFETY: `window` must outlive `painter`.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code, unused_mut, unused_unsafe)]
|
||||||
let painter = unsafe {
|
let painter = unsafe {
|
||||||
let mut painter = egui_wgpu::winit::Painter::new(
|
let mut painter = egui_wgpu::winit::Painter::new(
|
||||||
wgpu::Backends::PRIMARY | wgpu::Backends::GL,
|
wgpu::Backends::PRIMARY | wgpu::Backends::GL,
|
||||||
|
@ -486,7 +486,7 @@ mod wgpu_integration {
|
||||||
painter
|
painter
|
||||||
};
|
};
|
||||||
|
|
||||||
let wgpu_render_state = painter.render_state().expect("Uninitialized");
|
let wgpu_render_state = painter.render_state();
|
||||||
|
|
||||||
let system_theme = native_options.system_theme();
|
let system_theme = native_options.system_theme();
|
||||||
let mut integration = epi_integration::EpiIntegration::new(
|
let mut integration = epi_integration::EpiIntegration::new(
|
||||||
|
@ -497,7 +497,7 @@ mod wgpu_integration {
|
||||||
storage,
|
storage,
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
None,
|
None,
|
||||||
Some(wgpu_render_state.clone()),
|
wgpu_render_state.clone(),
|
||||||
);
|
);
|
||||||
let theme = system_theme.unwrap_or(native_options.default_theme);
|
let theme = system_theme.unwrap_or(native_options.default_theme);
|
||||||
integration.egui_ctx.set_visuals(theme.egui_visuals());
|
integration.egui_ctx.set_visuals(theme.egui_visuals());
|
||||||
|
@ -515,7 +515,7 @@ mod wgpu_integration {
|
||||||
storage: integration.frame.storage(),
|
storage: integration.frame.storage(),
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
gl: None,
|
gl: None,
|
||||||
wgpu_render_state: Some(wgpu_render_state),
|
wgpu_render_state,
|
||||||
});
|
});
|
||||||
|
|
||||||
if app.warm_up_enabled() {
|
if app.warm_up_enabled() {
|
||||||
|
@ -629,11 +629,13 @@ mod wgpu_integration {
|
||||||
match event {
|
match event {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
winit::event::Event::Resumed => unsafe {
|
winit::event::Event::Resumed => unsafe {
|
||||||
painter.set_window(Some(&window));
|
self.painter.set_window(Some(&self.window));
|
||||||
|
EventResult::RepaintAsap
|
||||||
},
|
},
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
winit::event::Event::Paused => unsafe {
|
winit::event::Event::Suspended => unsafe {
|
||||||
painter.set_window(None);
|
self.painter.set_window(None);
|
||||||
|
EventResult::Wait
|
||||||
},
|
},
|
||||||
|
|
||||||
winit::event::Event::WindowEvent { event, .. } => {
|
winit::event::Event::WindowEvent { event, .. } => {
|
||||||
|
|
|
@ -49,7 +49,6 @@ tracing = { version = "0.1", default-features = false, features = ["std"] }
|
||||||
winit = "0.27.2"
|
winit = "0.27.2"
|
||||||
|
|
||||||
#! ### Optional dependencies
|
#! ### Optional dependencies
|
||||||
arboard = { version = "2.1", optional = true, default-features = false }
|
|
||||||
|
|
||||||
## Enable this when generating docs.
|
## Enable this when generating docs.
|
||||||
document-features = { version = "0.2", optional = true }
|
document-features = { version = "0.2", optional = true }
|
||||||
|
@ -64,3 +63,6 @@ webbrowser = { version = "0.7", optional = true }
|
||||||
|
|
||||||
[target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies]
|
[target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies]
|
||||||
smithay-clipboard = { version = "0.6.3", optional = true }
|
smithay-clipboard = { version = "0.6.3", optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
|
arboard = { version = "2.1", optional = true, default-features = false }
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::os::raw::c_void;
|
||||||
/// If the "clipboard" feature is off, or we cannot connect to the OS clipboard,
|
/// If the "clipboard" feature is off, or we cannot connect to the OS clipboard,
|
||||||
/// then a fallback clipboard that just works works within the same app is used instead.
|
/// then a fallback clipboard that just works works within the same app is used instead.
|
||||||
pub struct Clipboard {
|
pub struct Clipboard {
|
||||||
#[cfg(feature = "arboard")]
|
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||||
arboard: Option<arboard::Clipboard>,
|
arboard: Option<arboard::Clipboard>,
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
|
@ -28,7 +28,7 @@ impl Clipboard {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn new(#[allow(unused_variables)] wayland_display: Option<*mut c_void>) -> Self {
|
pub fn new(#[allow(unused_variables)] wayland_display: Option<*mut c_void>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
#[cfg(feature = "arboard")]
|
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||||
arboard: init_arboard(),
|
arboard: init_arboard(),
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(
|
any(
|
||||||
|
@ -66,7 +66,7 @@ impl Clipboard {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "arboard")]
|
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||||
if let Some(clipboard) = &mut self.arboard {
|
if let Some(clipboard) = &mut self.arboard {
|
||||||
return match clipboard.get_text() {
|
return match clipboard.get_text() {
|
||||||
Ok(text) => Some(text),
|
Ok(text) => Some(text),
|
||||||
|
@ -96,7 +96,7 @@ impl Clipboard {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "arboard")]
|
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||||
if let Some(clipboard) = &mut self.arboard {
|
if let Some(clipboard) = &mut self.arboard {
|
||||||
if let Err(err) = clipboard.set_text(text) {
|
if let Err(err) = clipboard.set_text(text) {
|
||||||
tracing::error!("Copy/Cut error: {}", err);
|
tracing::error!("Copy/Cut error: {}", err);
|
||||||
|
@ -108,7 +108,7 @@ impl Clipboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "arboard")]
|
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||||
fn init_arboard() -> Option<arboard::Clipboard> {
|
fn init_arboard() -> Option<arboard::Clipboard> {
|
||||||
match arboard::Clipboard::new() {
|
match arboard::Clipboard::new() {
|
||||||
Ok(clipboard) => Some(clipboard),
|
Ok(clipboard) => Some(clipboard),
|
||||||
|
|
Loading…
Reference in a new issue