mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-15 21:41:35 +00:00
fix so path finding for wivrn
This commit is contained in:
parent
d533a05cb4
commit
26e3952fcc
2 changed files with 51 additions and 45 deletions
|
@ -7,6 +7,29 @@ use crate::{
|
||||||
use serde::{ser::Error, Deserialize, Serialize};
|
use serde::{ser::Error, Deserialize, Serialize};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
struct RuntimePathInfo {
|
||||||
|
libopenxr_path: &'static str,
|
||||||
|
libmonado_path: Option<&'static str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RuntimePathInfo {
|
||||||
|
const RUNTIME_PATH_INFO: [RuntimePathInfo; 2] = [
|
||||||
|
RuntimePathInfo {
|
||||||
|
libopenxr_path: "libopenxr_monado.so",
|
||||||
|
libmonado_path: Some("libmonado.so"),
|
||||||
|
},
|
||||||
|
RuntimePathInfo {
|
||||||
|
libopenxr_path: "wivrn/libopenxr_wivrn.so",
|
||||||
|
libmonado_path: Some("wivrn/libmonado.so"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
fn get_for(xr_service_type: XRServiceType) -> Self {
|
||||||
|
Self::RUNTIME_PATH_INFO[xr_service_type as usize]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ActiveRuntimeInnerRuntime {
|
pub struct ActiveRuntimeInnerRuntime {
|
||||||
#[serde(rename = "VALVE_runtime_is_steamvr")]
|
#[serde(rename = "VALVE_runtime_is_steamvr")]
|
||||||
|
@ -99,50 +122,35 @@ pub fn set_current_active_runtime_to_steam() -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_profile_active_runtime(profile: &Profile) -> ActiveRuntime {
|
pub fn build_profile_active_runtime(profile: &Profile) -> anyhow::Result<ActiveRuntime> {
|
||||||
let build_path = |lib64: bool, prefix: &str| {
|
let info = RuntimePathInfo::get_for(profile.xrservice_type.clone());
|
||||||
profile
|
|
||||||
.prefix
|
let path_to = |end_path: &str| {
|
||||||
.clone()
|
["lib", "lib64"].iter().find_map(|lib| {
|
||||||
.join(match lib64 {
|
let p = profile.prefix.clone().join(lib).join(end_path);
|
||||||
true => "lib64",
|
if p.exists() {
|
||||||
false => "lib",
|
Some(p)
|
||||||
})
|
} else {
|
||||||
.join(
|
None
|
||||||
prefix.to_string()
|
}
|
||||||
+ match profile.xrservice_type {
|
})
|
||||||
XRServiceType::Monado => "monado.so",
|
|
||||||
XRServiceType::Wivrn => "wivrn.so",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut oxr_so = build_path(false, "libopenxr_");
|
let Some(oxr_so) = path_to(info.libopenxr_path) else {
|
||||||
if !oxr_so.exists() {
|
anyhow::bail!("Could not find path to {}!", info.libopenxr_path);
|
||||||
let alt = build_path(true, "libopenxr_");
|
};
|
||||||
if alt.exists() {
|
|
||||||
oxr_so = alt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut monado_so = Some(build_path(false, "lib"));
|
|
||||||
if !monado_so.as_ref().unwrap().exists() {
|
|
||||||
let alt = build_path(true, "lib");
|
|
||||||
if alt.exists() {
|
|
||||||
monado_so = Some(alt);
|
|
||||||
} else {
|
|
||||||
monado_so = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ActiveRuntime {
|
let mnd_so = info.libmonado_path.and_then(path_to);
|
||||||
|
|
||||||
|
Ok(ActiveRuntime {
|
||||||
file_format_version: "1.0.0".into(),
|
file_format_version: "1.0.0".into(),
|
||||||
runtime: ActiveRuntimeInnerRuntime {
|
runtime: ActiveRuntimeInnerRuntime {
|
||||||
name: None,
|
name: None,
|
||||||
valve_runtime_is_steamvr: None,
|
valve_runtime_is_steamvr: None,
|
||||||
libmonado_path: monado_so,
|
libmonado_path: mnd_so,
|
||||||
library_path: oxr_so,
|
library_path: oxr_so,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// for system installs
|
// for system installs
|
||||||
|
@ -167,7 +175,7 @@ pub fn set_current_active_runtime_to_profile(profile: &Profile) -> anyhow::Resul
|
||||||
set_file_readonly(&dest, false)?;
|
set_file_readonly(&dest, false)?;
|
||||||
backup_steam_active_runtime();
|
backup_steam_active_runtime();
|
||||||
let pfx = profile.clone().prefix;
|
let pfx = profile.clone().prefix;
|
||||||
let mut ar = build_profile_active_runtime(profile);
|
let mut ar = build_profile_active_runtime(profile)?;
|
||||||
// hack: relativize libopenxr_monado.so path for system installs
|
// hack: relativize libopenxr_monado.so path for system installs
|
||||||
if pfx == PathBuf::from(SYSTEM_PREFIX) {
|
if pfx == PathBuf::from(SYSTEM_PREFIX) {
|
||||||
ar = relativize_active_runtime_lib_path(&ar, &dest);
|
ar = relativize_active_runtime_lib_path(&ar, &dest);
|
||||||
|
|
|
@ -485,16 +485,14 @@ impl Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn libmonado_so(&self) -> Option<PathBuf> {
|
pub fn libmonado_so(&self) -> Option<PathBuf> {
|
||||||
let res = self.prefix.join("lib/libmonado.so");
|
let paths = [
|
||||||
if res.is_file() {
|
self.prefix.join("lib/libmonado.so"),
|
||||||
return Some(res);
|
self.prefix.join("lib64/libmonado.so"),
|
||||||
}
|
self.prefix.join("lib/wivrn/libmonado.so"),
|
||||||
let res = self.prefix.join("lib64/libmonado.so");
|
self.prefix.join("lib64/wivrn/libmonado.so"),
|
||||||
if res.is_file() {
|
];
|
||||||
return Some(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
paths.into_iter().find(|path| path.is_file())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_libmonado(&self) -> bool {
|
pub fn has_libmonado(&self) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue