feat: add xrizer as an option for openvr compatibility module
Some checks failed
/ cargo-fmtcheck (push) Has been cancelled
/ cargo-clippy (push) Has been cancelled
/ cargo-test (push) Has been cancelled
/ appimage (push) Has been cancelled

This commit is contained in:
Gabriele Musco 2025-01-04 19:39:42 +01:00
parent 8ffb44aa11
commit 1c3b4decb5
5 changed files with 67 additions and 4 deletions

View file

@ -0,0 +1,50 @@
use crate::{
build_tools::git::Git, profile::Profile, termcolor::TermColor, ui::job_worker::job::WorkerJob,
util::file_utils::rm_rf,
};
use std::{collections::VecDeque, path::Path};
pub fn get_build_xrizer_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
let mut jobs = VecDeque::<WorkerJob>::new();
jobs.push_back(WorkerJob::new_printer(
"Building xrizer...",
Some(TermColor::Blue),
));
let git = Git {
repo: profile
.ovr_comp
.repo
.as_ref()
.unwrap_or(&"https://github.com/Supreeeme/xrizer".into())
.clone(),
dir: profile.ovr_comp.path.clone(),
branch: profile
.ovr_comp
.branch
.as_ref()
.unwrap_or(&"main".into())
.clone(),
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));
let build_dir = profile.ovr_comp.path.join("target");
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
}
jobs.push_back(WorkerJob::new_cmd(
None,
"sh".into(),
Some(vec![
"-c".into(),
format!(
"cd '{}' && cargo xbuild --release",
profile.ovr_comp.path.to_string_lossy()
),
]),
));
jobs
}

View file

@ -5,3 +5,4 @@ pub mod build_monado;
pub mod build_opencomposite;
pub mod build_openhmd;
pub mod build_wivrn;
pub mod build_xrizer;

View file

@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use crate::{
paths::get_backup_dir,
profile::Profile,
profile::{OvrCompatibilityModuleType, Profile},
util::file_utils::{copy_file, deserialize_file, get_writer, set_file_readonly},
xdg::XDG,
};
@ -98,7 +98,12 @@ pub fn build_profile_openvrpaths(profile: &Profile) -> OpenVrPaths {
external_drivers: None,
jsonid: "vrpathreg".into(),
log: vec![datadir.join("Steam/logs")],
runtime: vec![profile.ovr_comp.path.join("build")],
runtime: match profile.ovr_comp.mod_type {
OvrCompatibilityModuleType::Opencomposite => vec![profile.ovr_comp.path.join("build")],
OvrCompatibilityModuleType::Xrizer => {
vec![profile.ovr_comp.path.join("target/release")]
}
},
version: 1,
}
}

View file

@ -264,19 +264,21 @@ impl Display for LighthouseDriver {
pub enum OvrCompatibilityModuleType {
#[default]
Opencomposite,
Xrizer,
}
impl Display for OvrCompatibilityModuleType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Opencomposite => "OpenComposite",
Self::Xrizer => "xrizer",
})
}
}
impl OvrCompatibilityModuleType {
pub fn iter() -> Iter<'static, Self> {
[Self::Opencomposite].iter()
[Self::Opencomposite, Self::Xrizer].iter()
}
}
@ -286,6 +288,7 @@ impl FromStr for OvrCompatibilityModuleType {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().trim() {
"opencomposite" => Ok(Self::Opencomposite),
"xrizer" => Ok(Self::Xrizer),
_ => Err(format!("no match for ovr compatibility module `{s}`")),
}
}
@ -295,6 +298,7 @@ impl From<u32> for OvrCompatibilityModuleType {
fn from(value: u32) -> Self {
match value {
0 => Self::Opencomposite,
1 => Self::Xrizer,
_ => panic!("OvrCompatibilityModuleType index out of bounds"),
}
}

View file

@ -20,7 +20,7 @@ use crate::{
build_basalt::get_build_basalt_jobs, build_libsurvive::get_build_libsurvive_jobs,
build_mercury::get_build_mercury_jobs, build_monado::get_build_monado_jobs,
build_opencomposite::get_build_opencomposite_jobs, build_openhmd::get_build_openhmd_jobs,
build_wivrn::get_build_wivrn_jobs,
build_wivrn::get_build_wivrn_jobs, build_xrizer::get_build_xrizer_jobs,
},
config::{Config, PluginConfig},
constants::APP_NAME,
@ -518,6 +518,9 @@ impl AsyncComponent for App {
OvrCompatibilityModuleType::Opencomposite => {
get_build_opencomposite_jobs(&profile, clean_build)
}
OvrCompatibilityModuleType::Xrizer => {
get_build_xrizer_jobs(&profile, clean_build)
}
});
let missing_deps = profile.missing_dependencies();
if !(self.skip_depcheck || profile.skip_dependency_check || missing_deps.is_empty())