diff options
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/main.rs | 78 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/linux.rs | 21 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/mod.rs | 46 |
3 files changed, 72 insertions, 73 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e37f118e..6bb65a2c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -14,6 +14,7 @@ mod development; mod github; mod mod_management; mod northstar; +mod platform_specific; mod repair_and_verify; mod thunderstore; mod util; @@ -134,7 +135,7 @@ fn main() { repair_and_verify::disable_all_but_core, util::is_debug_mode, github::release_notes::get_northstar_release_notes, - linux_checks, + platform_specific::linux_checks, mod_management::get_installed_mods_and_properties, install_mod_caller, clean_up_download_folder_caller, @@ -143,9 +144,9 @@ fn main() { util::get_server_player_count, util::kill_northstar, mod_management::delete_thunderstore_mod, - install_northstar_proton_wrapper, - uninstall_northstar_proton_wrapper, - get_local_northstar_proton_wrapper_version, + platform_specific::install_northstar_proton_wrapper, + platform_specific::uninstall_northstar_proton_wrapper, + platform_specific::get_local_northstar_proton_wrapper_version, open_repair_window, thunderstore::query_thunderstore_packages_api, github::get_list_of_tags, @@ -193,23 +194,6 @@ fn main() { }; } -/// Returns true if linux compatible -#[tauri::command] -async fn linux_checks() -> Result<(), String> { - // Different behaviour depending on OS - // MacOS is missing as it is not a target - // in turn this means this application will not build on MacOS. - #[cfg(target_os = "windows")] - { - Err("Not available on Windows".to_string()) - } - - #[cfg(target_os = "linux")] - { - linux_checks_librs() - } -} - /// Returns the current version number as a string #[tauri::command] async fn get_flightcore_version_number() -> String { @@ -452,7 +436,6 @@ async fn get_available_northstar_versions() -> Result<Vec<NorthstarThunderstoreR } use anyhow::Result; -mod platform_specific; #[derive(Serialize, Deserialize, Debug, Clone, TS)] #[ts(export)] @@ -480,28 +463,6 @@ pub struct NorthstarMod { pub directory: String, } -// I intend to add more linux related stuff to check here, so making a func -// for now tho it only checks `ldd --version` -// - salmon -#[cfg(target_os = "linux")] -pub fn linux_checks_librs() -> Result<(), String> { - // Perform various checks in terms of Linux compatibility - // Return early with error message if a check fails - - // check `ldd --version` to see if glibc is up to date for northstar proton - let min_required_ldd_version = 2.33; - let lddv = platform_specific::linux::check_glibc_v(); - if lddv < min_required_ldd_version { - return Err(format!( - "GLIBC is not version {} or greater", - min_required_ldd_version - )); - }; - - // All checks passed - Ok(()) -} - /// Checks whether the provided path is a valid Titanfall2 gamepath by checking against a certain set of criteria pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { let path_to_titanfall2_exe = format!("{game_install_path}/Titanfall2.exe"); @@ -520,32 +481,3 @@ pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { fn get_host_os() -> String { env::consts::OS.to_string() } - -/// On Linux attempts to install NorthstarProton -/// On Windows simply returns an error message -#[tauri::command] -async fn install_northstar_proton_wrapper() -> Result<(), String> { - #[cfg(target_os = "linux")] - return platform_specific::linux::install_ns_proton().map_err(|err| err.to_string()); - - #[cfg(target_os = "windows")] - Err("Not supported on Windows".to_string()) -} - -#[tauri::command] -async fn uninstall_northstar_proton_wrapper() -> Result<(), String> { - #[cfg(target_os = "linux")] - return platform_specific::linux::uninstall_ns_proton(); - - #[cfg(target_os = "windows")] - Err("Not supported on Windows".to_string()) -} - -#[tauri::command] -async fn get_local_northstar_proton_wrapper_version() -> Result<String, String> { - #[cfg(target_os = "linux")] - return platform_specific::linux::get_local_ns_proton_version(); - - #[cfg(target_os = "windows")] - Err("Not supported on Windows".to_string()) -} diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs index 674f384b..706a4d22 100644 --- a/src-tauri/src/platform_specific/linux.rs +++ b/src-tauri/src/platform_specific/linux.rs @@ -3,6 +3,27 @@ use regex::Regex; use std::process::Command; +// I intend to add more linux related stuff to check here, so making a func +// for now tho it only checks `ldd --version` +// - salmon +pub fn linux_checks_librs() -> Result<(), String> { + // Perform various checks in terms of Linux compatibility + // Return early with error message if a check fails + + // check `ldd --version` to see if glibc is up to date for northstar proton + let min_required_ldd_version = 2.33; + let lddv = check_glibc_v(); + if lddv < min_required_ldd_version { + return Err(format!( + "GLIBC is not version {} or greater", + min_required_ldd_version + )); + }; + + // All checks passed + Ok(()) +} + fn get_proton_dir() -> Option<String> { let steam_dir = steamlocate::SteamDir::locate()?; let compat_dir = format!("{}/compatibilitytools.d/", steam_dir.path.display()); diff --git a/src-tauri/src/platform_specific/mod.rs b/src-tauri/src/platform_specific/mod.rs index 84bd478a..d5acfde8 100644 --- a/src-tauri/src/platform_specific/mod.rs +++ b/src-tauri/src/platform_specific/mod.rs @@ -3,3 +3,49 @@ pub mod windows; #[cfg(target_os = "linux")] pub mod linux; + +/// On Linux attempts to install NorthstarProton +/// On Windows simply returns an error message +#[tauri::command] +pub async fn install_northstar_proton_wrapper() -> Result<(), String> { + #[cfg(target_os = "linux")] + return linux::install_ns_proton().map_err(|err| err.to_string()); + + #[cfg(target_os = "windows")] + Err("Not supported on Windows".to_string()) +} + +#[tauri::command] +pub async fn uninstall_northstar_proton_wrapper() -> Result<(), String> { + #[cfg(target_os = "linux")] + return linux::uninstall_ns_proton(); + + #[cfg(target_os = "windows")] + Err("Not supported on Windows".to_string()) +} + +#[tauri::command] +pub async fn get_local_northstar_proton_wrapper_version() -> Result<String, String> { + #[cfg(target_os = "linux")] + return linux::get_local_ns_proton_version(); + + #[cfg(target_os = "windows")] + Err("Not supported on Windows".to_string()) +} + +/// Returns true if linux compatible +#[tauri::command] +pub async fn linux_checks() -> Result<(), String> { + // Different behaviour depending on OS + // MacOS is missing as it is not a target + // in turn this means this application will not build on MacOS. + #[cfg(target_os = "windows")] + { + Err("Not available on Windows".to_string()) + } + + #[cfg(target_os = "linux")] + { + linux::linux_checks_librs() + } +} |