Add library target for Android builds
This commit is contained in:
@@ -11,6 +11,10 @@ default-run = "cinny"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "cinny_lib"
|
||||||
|
crate-type = ["staticlib", "cdylib", "lib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2", features = [] }
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
|
|||||||
26
src-tauri/src/lib.rs
Normal file
26
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//! Cinny Desktop library for cross-platform builds including Android
|
||||||
|
|
||||||
|
#[cfg(mobile)]
|
||||||
|
mod mobile;
|
||||||
|
|
||||||
|
#[cfg(mobile)]
|
||||||
|
pub use mobile::*;
|
||||||
|
|
||||||
|
/// Runs the Tauri application
|
||||||
|
pub fn run() {
|
||||||
|
let port = 44548;
|
||||||
|
|
||||||
|
let mut builder = tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
||||||
|
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||||
|
.plugin(tauri_plugin_shell::init());
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
{
|
||||||
|
builder = builder.plugin(tauri_plugin_single_instance::init(|_app, _args, _cwd| {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while building tauri application");
|
||||||
|
}
|
||||||
@@ -4,12 +4,5 @@
|
|||||||
)]
|
)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let port = 44548;
|
cinny_lib::run();
|
||||||
|
|
||||||
tauri::Builder::default()
|
|
||||||
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
|
||||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
|
||||||
.plugin(tauri_plugin_shell::init())
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while building tauri application");
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
src-tauri/src/mobile.rs
Normal file
9
src-tauri/src/mobile.rs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//! Mobile-specific entry points for Android and iOS
|
||||||
|
|
||||||
|
use tauri::{AppHandle, Runtime};
|
||||||
|
|
||||||
|
/// Mobile entry point
|
||||||
|
#[tauri::mobile_entry_point]
|
||||||
|
fn main() {
|
||||||
|
crate::run();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user