mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-04 23:29:00 +00:00
feat: refactor libmonado and libopenxr finding, profile takes care of it across the app
This commit is contained in:
parent
e486d36084
commit
7275168b5c
2 changed files with 22 additions and 26 deletions
|
@ -100,20 +100,11 @@ pub fn set_current_active_runtime_to_steam() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_profile_active_runtime(profile: &Profile) -> anyhow::Result<ActiveRuntime> {
|
pub fn build_profile_active_runtime(profile: &Profile) -> anyhow::Result<ActiveRuntime> {
|
||||||
let path_to = |end_path: &str| {
|
let Some(libopenxr_path) = profile.libopenxr_so() else {
|
||||||
["lib", "lib64"].iter().find_map(|lib| {
|
anyhow::bail!(
|
||||||
let p = profile.prefix.clone().join(lib).join(end_path);
|
"Could not find path to {}!",
|
||||||
if p.exists() {
|
profile.xrservice_type.libopenxr_path()
|
||||||
Some(p)
|
);
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
let libopenxr_end_path = profile.xrservice_type.libopenxr_path();
|
|
||||||
let Some(libopenxr_path) = path_to(libopenxr_end_path) else {
|
|
||||||
anyhow::bail!("Could not find path to {}!", libopenxr_end_path);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(ActiveRuntime {
|
Ok(ActiveRuntime {
|
||||||
|
@ -121,7 +112,7 @@ pub fn build_profile_active_runtime(profile: &Profile) -> anyhow::Result<ActiveR
|
||||||
runtime: ActiveRuntimeInnerRuntime {
|
runtime: ActiveRuntimeInnerRuntime {
|
||||||
name: None,
|
name: None,
|
||||||
valve_runtime_is_steamvr: None,
|
valve_runtime_is_steamvr: None,
|
||||||
libmonado_path: path_to(profile.xrservice_type.libmonado_path()),
|
libmonado_path: profile.libmonado_so(),
|
||||||
library_path: libopenxr_path,
|
library_path: libopenxr_path,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,6 +48,7 @@ impl XRServiceType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// relative path from the prefix lib dir of the libopenxr shared object
|
||||||
pub fn libopenxr_path(&self) -> &'static str {
|
pub fn libopenxr_path(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Monado => "libopenxr_monado.so",
|
Self::Monado => "libopenxr_monado.so",
|
||||||
|
@ -55,6 +56,7 @@ impl XRServiceType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// relative path from the prefix lib dir of the libmonado shared object
|
||||||
pub fn libmonado_path(&self) -> &'static str {
|
pub fn libmonado_path(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Monado => "libmonado.so",
|
Self::Monado => "libmonado.so",
|
||||||
|
@ -506,22 +508,25 @@ impl Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_start(&self) -> bool {
|
pub fn can_start(&self) -> bool {
|
||||||
Path::new(&self.xrservice_binary()).is_file()
|
self.xrservice_binary().is_file()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// absolute path to a given shared object in the profile prefix
|
||||||
|
pub fn find_so(&self, rel_path: &str) -> Option<PathBuf> {
|
||||||
|
["lib", "lib64"]
|
||||||
|
.into_iter()
|
||||||
|
.map(|lib| self.prefix.join(lib).join(rel_path))
|
||||||
|
.find(|path| path.is_file())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// absolute path to the libmonado shared object
|
||||||
pub fn libmonado_so(&self) -> Option<PathBuf> {
|
pub fn libmonado_so(&self) -> Option<PathBuf> {
|
||||||
let paths = [
|
self.find_so(self.xrservice_type.libmonado_path())
|
||||||
self.prefix.join("lib/libmonado.so"),
|
|
||||||
self.prefix.join("lib64/libmonado.so"),
|
|
||||||
self.prefix.join("lib/wivrn/libmonado.so"),
|
|
||||||
self.prefix.join("lib64/wivrn/libmonado.so"),
|
|
||||||
];
|
|
||||||
|
|
||||||
paths.into_iter().find(|path| path.is_file())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_libmonado(&self) -> bool {
|
/// absolute path to the libopenxr shared object
|
||||||
self.libmonado_so().is_some()
|
pub fn libopenxr_so(&self) -> Option<PathBuf> {
|
||||||
|
self.find_so(self.xrservice_type.libopenxr_path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue