diff --git a/src/builders/build_xrizer.rs b/src/builders/build_xrizer.rs new file mode 100644 index 0000000..6fc1b6b --- /dev/null +++ b/src/builders/build_xrizer.rs @@ -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 { + let mut jobs = VecDeque::::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 +} diff --git a/src/builders/mod.rs b/src/builders/mod.rs index c84be3b..1f66748 100644 --- a/src/builders/mod.rs +++ b/src/builders/mod.rs @@ -5,3 +5,4 @@ pub mod build_monado; pub mod build_opencomposite; pub mod build_openhmd; pub mod build_wivrn; +pub mod build_xrizer; diff --git a/src/file_builders/openvrpaths_vrpath.rs b/src/file_builders/openvrpaths_vrpath.rs index 773902c..842acf8 100644 --- a/src/file_builders/openvrpaths_vrpath.rs +++ b/src/file_builders/openvrpaths_vrpath.rs @@ -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, } } diff --git a/src/profile.rs b/src/profile.rs index 4a637fe..89177ac 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -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 { 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 for OvrCompatibilityModuleType { fn from(value: u32) -> Self { match value { 0 => Self::Opencomposite, + 1 => Self::Xrizer, _ => panic!("OvrCompatibilityModuleType index out of bounds"), } } diff --git a/src/ui/app.rs b/src/ui/app.rs index cd7d63d..77edeeb 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -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())