Make host_spawn not an option

This commit is contained in:
Charlie Le 2024-11-21 14:06:37 -05:00
parent dd4db97215
commit 1de2050277
14 changed files with 25 additions and 25 deletions

View file

@ -14,10 +14,10 @@ pub async fn async_process<S: AsRef<OsStr>, T: AsRef<OsStr>>(
cmd: S,
args: Option<&[T]>,
env: Option<HashMap<String, String>>,
host_spawn: Option<bool>,
host_spawn: bool,
) -> anyhow::Result<AsyncProcessOut> {
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));

View file

@ -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,
)
}
}

View file

@ -13,7 +13,7 @@ impl Git {
fn cmd(&self, args: Vec<String>) -> 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,
)
}

View file

@ -79,7 +79,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
.to_string_lossy()
.to_string(),
]),
Some(false),
false,
));
jobs.push_back(WorkerJob::new_cmd(
None,
@ -101,7 +101,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
.to_string_lossy()
.to_string(),
]),
Some(false),
false,
));
jobs

View file

@ -21,7 +21,7 @@ pub fn get_build_mercury_jobs(profile: &Profile) -> VecDeque<WorkerJob> {
profile.prefix.to_string_lossy().to_string(),
get_cache_dir().to_string_lossy().to_string(),
]),
Some(false),
false,
));
jobs

View file

@ -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

View file

@ -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),

View file

@ -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
{

View file

@ -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())

View file

@ -39,13 +39,13 @@ impl WorkerJob {
env: Option<HashMap<String, String>>,
cmd: String,
args: Option<Vec<String>>,
host_spawn: Option<bool>
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,
})
}

View file

@ -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,

View file

@ -137,7 +137,7 @@ impl AsyncComponent for WivrnWiredStartBox {
)
]),
None,
None
false,
).await {
Ok(out) if out.exit_code == 0 =>
StartClientStatus::Success

View file

@ -6,9 +6,9 @@ pub fn make_command<S: AsRef<OsStr>, T: AsRef<OsStr>>(
cmd: S,
args: Option<&[T]>,
env: Option<HashMap<String, String>>,
host_spawn: Option<bool>,
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));

View file

@ -81,7 +81,7 @@ pub fn setcap_cap_sys_nice_eip_cmd(profile: &Profile) -> Vec<String> {
}
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}");
}