From 1de20502778080a764687aaab4d30780b31b4696 Mon Sep 17 00:00:00 2001 From: Charlie Le <20309750+CharlieQLe@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:06:37 -0500 Subject: [PATCH] Make host_spawn not an option --- src/async_process.rs | 4 ++-- src/build_tools/cmake.rs | 6 +++--- src/build_tools/git.rs | 4 ++-- src/builders/build_basalt.rs | 4 ++-- src/builders/build_mercury.rs | 2 +- src/builders/build_openhmd.rs | 6 +++--- src/ui/app.rs | 4 ++-- src/ui/install_wivrn_box.rs | 2 +- src/ui/job_worker/internal_worker.rs | 2 +- src/ui/job_worker/job.rs | 4 ++-- src/ui/steamvr_calibration_box.rs | 4 ++-- src/ui/wivrn_wired_start_box.rs | 2 +- src/util/cmd_utils.rs | 4 ++-- src/util/file_utils.rs | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/async_process.rs b/src/async_process.rs index 1f0ab4c..c3cfc76 100644 --- a/src/async_process.rs +++ b/src/async_process.rs @@ -14,10 +14,10 @@ pub async fn async_process, T: AsRef>( cmd: S, args: Option<&[T]>, env: Option>, - host_spawn: Option, + host_spawn: bool, ) -> anyhow::Result { let mut command: Command; - if *IS_FLATPAK && host_spawn.unwrap_or_default() { + if *IS_FLATPAK && host_spawn { let mut flatpak_env = vec![]; for (key, value) in env.unwrap_or_default() { flatpak_env.push(format!("--env={}={}", key, value)); diff --git a/src/build_tools/cmake.rs b/src/build_tools/cmake.rs index f2d3fc4..0465e7c 100644 --- a/src/build_tools/cmake.rs +++ b/src/build_tools/cmake.rs @@ -26,7 +26,7 @@ impl Cmake { } } args.push(self.source_dir.to_string_lossy().to_string()); - WorkerJob::new_cmd(self.env.clone(), "cmake".into(), Some(args), Some(false)) + WorkerJob::new_cmd(self.env.clone(), "cmake".into(), Some(args), false) } pub fn get_build_job(&self) -> WorkerJob { @@ -37,7 +37,7 @@ impl Cmake { "--build".into(), self.build_dir.to_string_lossy().to_string(), ]), - Some(false), + false, ) } @@ -49,7 +49,7 @@ impl Cmake { "--install".into(), self.build_dir.to_string_lossy().to_string(), ]), - Some(false), + false, ) } } diff --git a/src/build_tools/git.rs b/src/build_tools/git.rs index 923b25b..0f03a0e 100644 --- a/src/build_tools/git.rs +++ b/src/build_tools/git.rs @@ -13,7 +13,7 @@ impl Git { fn cmd(&self, args: Vec) -> WorkerJob { let mut nargs = vec!["-C".into(), self.dir.to_string_lossy().to_string()]; nargs.extend(args); - WorkerJob::new_cmd(None, "git".into(), Some(nargs), Some(false)) + WorkerJob::new_cmd(None, "git".into(), Some(nargs), false) } fn get_repo(&self) -> String { @@ -84,7 +84,7 @@ impl Git { self.dir.to_string_lossy().to_string(), "--recurse-submodules".into(), ]), - Some(false), + false, ) } diff --git a/src/builders/build_basalt.rs b/src/builders/build_basalt.rs index cc1bd2e..5b46235 100644 --- a/src/builders/build_basalt.rs +++ b/src/builders/build_basalt.rs @@ -79,7 +79,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque VecDeque VecDeque { profile.prefix.to_string_lossy().to_string(), get_cache_dir().to_string_lossy().to_string(), ]), - Some(false), + false, )); jobs diff --git a/src/builders/build_openhmd.rs b/src/builders/build_openhmd.rs index 3404bbd..fa802cb 100644 --- a/src/builders/build_openhmd.rs +++ b/src/builders/build_openhmd.rs @@ -62,7 +62,7 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque< .to_string_lossy() .to_string(), ]), - Some(false), + false, )); } // build job @@ -70,7 +70,7 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque< None, "ninja".into(), Some(vec!["-C".into(), build_dir.to_string_lossy().to_string()]), - Some(false), + false, )); // install job jobs.push_back(WorkerJob::new_cmd( @@ -81,7 +81,7 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque< build_dir.to_string_lossy().to_string(), "install".into(), ]), - Some(false), + false, )); jobs diff --git a/src/ui/app.rs b/src/ui/app.rs index d46a7ee..33ff27e 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -163,7 +163,7 @@ impl App { self.debug_view.sender().emit(DebugViewMsg::ClearLog); self.xr_devices = vec![]; if *IS_FLATPAK { - make_command(String::from("rm"), Some(&[prof.xrservice_type.ipc_file_path().to_str().unwrap()]), None, Some(true)) + make_command(String::from("rm"), Some(&[prof.xrservice_type.ipc_file_path().to_str().unwrap()]), None, true) .output() .expect("Failed to remove xrservice IPC file"); } else { @@ -215,7 +215,7 @@ impl App { Some(prof.environment.clone()), "sh".into(), Some(vec!["-c".into(), autostart_cmd.clone()]), - Some(true) + true )); let autostart_worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg { JobWorkerOut::Log(rows) => Msg::OnServiceLog(rows), diff --git a/src/ui/install_wivrn_box.rs b/src/ui/install_wivrn_box.rs index af5b08a..0b456c6 100644 --- a/src/ui/install_wivrn_box.rs +++ b/src/ui/install_wivrn_box.rs @@ -218,7 +218,7 @@ impl AsyncComponent for InstallWivrnBox { "adb", Some(&["install", "-r", "-g", apk_path.to_string_lossy().to_string().as_str()]), None, - None + false, ) .await { diff --git a/src/ui/job_worker/internal_worker.rs b/src/ui/job_worker/internal_worker.rs index 3b6e35b..2d4e7a4 100644 --- a/src/ui/job_worker/internal_worker.rs +++ b/src/ui/job_worker/internal_worker.rs @@ -85,7 +85,7 @@ impl Worker for InternalJobWorker { match &mut job { WorkerJob::Cmd(data) => { let data = data.clone(); - if let Ok(mut cmd) = make_command(data.command, Some(&data.args), Some(data.environment), Some(data.host_spawn)) + if let Ok(mut cmd) = make_command(data.command, Some(&data.args), Some(data.environment), data.host_spawn) .stdin(Stdio::piped()) .stderr(Stdio::piped()) .stdout(Stdio::piped()) diff --git a/src/ui/job_worker/job.rs b/src/ui/job_worker/job.rs index 39bcc9d..adde61c 100644 --- a/src/ui/job_worker/job.rs +++ b/src/ui/job_worker/job.rs @@ -39,13 +39,13 @@ impl WorkerJob { env: Option>, cmd: String, args: Option>, - host_spawn: Option + host_spawn: bool ) -> Self { Self::Cmd(CmdWorkerData { environment: env.unwrap_or_default(), command: cmd, args: args.unwrap_or_default(), - host_spawn: host_spawn.unwrap_or_default(), + host_spawn, }) } diff --git a/src/ui/steamvr_calibration_box.rs b/src/ui/steamvr_calibration_box.rs index cb3ac77..1ea8230 100644 --- a/src/ui/steamvr_calibration_box.rs +++ b/src/ui/steamvr_calibration_box.rs @@ -159,7 +159,7 @@ impl SimpleComponent for SteamVrCalibrationBox { Some(env.clone()), vrcmd.clone(), Some(vec!["--pollposes".into()]), - Some(false), + false, )); JobWorker::new(jobs, sender.input_sender(), |msg| match msg { JobWorkerOut::Log(_) => Self::Input::NoOp, @@ -179,7 +179,7 @@ impl SimpleComponent for SteamVrCalibrationBox { Some(env), vrcmd, Some(vec!["--resetroomsetup".into()]), - Some(false), + false, )); JobWorker::new(jobs, sender.input_sender(), |msg| match msg { JobWorkerOut::Log(_) => Self::Input::NoOp, diff --git a/src/ui/wivrn_wired_start_box.rs b/src/ui/wivrn_wired_start_box.rs index 8736e79..89b384d 100644 --- a/src/ui/wivrn_wired_start_box.rs +++ b/src/ui/wivrn_wired_start_box.rs @@ -137,7 +137,7 @@ impl AsyncComponent for WivrnWiredStartBox { ) ]), None, - None + false, ).await { Ok(out) if out.exit_code == 0 => StartClientStatus::Success diff --git a/src/util/cmd_utils.rs b/src/util/cmd_utils.rs index f7372bb..e09295b 100644 --- a/src/util/cmd_utils.rs +++ b/src/util/cmd_utils.rs @@ -6,9 +6,9 @@ pub fn make_command, T: AsRef>( cmd: S, args: Option<&[T]>, env: Option>, - host_spawn: Option, + host_spawn: bool, ) -> Command { - if *IS_FLATPAK && host_spawn.unwrap_or_default() { + if *IS_FLATPAK && host_spawn { let mut flatpak_env = vec![]; for (key, value) in env.unwrap_or_default() { flatpak_env.push(format!("--env={}={}", key, value)); diff --git a/src/util/file_utils.rs b/src/util/file_utils.rs index 6bbddd0..cf7731f 100644 --- a/src/util/file_utils.rs +++ b/src/util/file_utils.rs @@ -81,7 +81,7 @@ pub fn setcap_cap_sys_nice_eip_cmd(profile: &Profile) -> Vec { } pub async fn setcap_cap_sys_nice_eip(profile: &Profile) { - if let Err(e) = async_process("pkexec", Some(&setcap_cap_sys_nice_eip_cmd(profile)), None, Some(true)).await + if let Err(e) = async_process("pkexec", Some(&setcap_cap_sys_nice_eip_cmd(profile)), None, true).await { eprintln!("Error: failed running setcap: {e}"); }