aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/platform_specific
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-10-13 02:27:29 +0200
committerGitHub <noreply@github.com>2023-10-13 02:27:29 +0200
commitf515a3b702f781c0da438840071def1b37d2e1bc (patch)
tree5b078d7aeff8d3333f810ca21400403e7d25723f /src-tauri/src/platform_specific
parentc3c1aab86e7254f8f1724f3e13a4f17a9974f422 (diff)
downloadFlightCore-f515a3b702f781c0da438840071def1b37d2e1bc.tar.gz
FlightCore-f515a3b702f781c0da438840071def1b37d2e1bc.zip
refactor: Move platform specific logic to proper mod (#616)
in an effort to clean up `main.rs` * refactor: Move Proton related wrapper functions to root of platform_specific module * refactor: Move Linux checks to Linux mod for platform specific stuff * refactor: Move Linux checks wrapper to mod for platform specific stuff
Diffstat (limited to 'src-tauri/src/platform_specific')
-rw-r--r--src-tauri/src/platform_specific/linux.rs21
-rw-r--r--src-tauri/src/platform_specific/mod.rs46
2 files changed, 67 insertions, 0 deletions
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()
+ }
+}