mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 11:35:48 +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> {
|
||||
let path_to = |end_path: &str| {
|
||||
["lib", "lib64"].iter().find_map(|lib| {
|
||||
let p = profile.prefix.clone().join(lib).join(end_path);
|
||||
if p.exists() {
|
||||
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);
|
||||
let Some(libopenxr_path) = profile.libopenxr_so() else {
|
||||
anyhow::bail!(
|
||||
"Could not find path to {}!",
|
||||
profile.xrservice_type.libopenxr_path()
|
||||
);
|
||||
};
|
||||
|
||||
Ok(ActiveRuntime {
|
||||
|
@ -121,7 +112,7 @@ pub fn build_profile_active_runtime(profile: &Profile) -> anyhow::Result<ActiveR
|
|||
runtime: ActiveRuntimeInnerRuntime {
|
||||
name: None,
|
||||
valve_runtime_is_steamvr: None,
|
||||
libmonado_path: path_to(profile.xrservice_type.libmonado_path()),
|
||||
libmonado_path: profile.libmonado_so(),
|
||||
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 {
|
||||
match self {
|
||||
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 {
|
||||
match self {
|
||||
Self::Monado => "libmonado.so",
|
||||
|
@ -506,22 +508,25 @@ impl Profile {
|
|||
}
|
||||
|
||||
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> {
|
||||
let paths = [
|
||||
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())
|
||||
self.find_so(self.xrservice_type.libmonado_path())
|
||||
}
|
||||
|
||||
pub fn has_libmonado(&self) -> bool {
|
||||
self.libmonado_so().is_some()
|
||||
/// absolute path to the libopenxr shared object
|
||||
pub fn libopenxr_so(&self) -> Option<PathBuf> {
|
||||
self.find_so(self.xrservice_type.libopenxr_path())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue