mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-02 22:29:01 +00:00
Make host_spawn not an option
This commit is contained in:
parent
dd4db97215
commit
1de2050277
14 changed files with 25 additions and 25 deletions
|
@ -14,10 +14,10 @@ pub async fn async_process<S: AsRef<OsStr>, T: AsRef<OsStr>>(
|
||||||
cmd: S,
|
cmd: S,
|
||||||
args: Option<&[T]>,
|
args: Option<&[T]>,
|
||||||
env: Option<HashMap<String, String>>,
|
env: Option<HashMap<String, String>>,
|
||||||
host_spawn: Option<bool>,
|
host_spawn: bool,
|
||||||
) -> anyhow::Result<AsyncProcessOut> {
|
) -> anyhow::Result<AsyncProcessOut> {
|
||||||
let mut command: Command;
|
let mut command: Command;
|
||||||
if *IS_FLATPAK && host_spawn.unwrap_or_default() {
|
if *IS_FLATPAK && host_spawn {
|
||||||
let mut flatpak_env = vec![];
|
let mut flatpak_env = vec![];
|
||||||
for (key, value) in env.unwrap_or_default() {
|
for (key, value) in env.unwrap_or_default() {
|
||||||
flatpak_env.push(format!("--env={}={}", key, value));
|
flatpak_env.push(format!("--env={}={}", key, value));
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Cmake {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.push(self.source_dir.to_string_lossy().to_string());
|
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 {
|
pub fn get_build_job(&self) -> WorkerJob {
|
||||||
|
@ -37,7 +37,7 @@ impl Cmake {
|
||||||
"--build".into(),
|
"--build".into(),
|
||||||
self.build_dir.to_string_lossy().to_string(),
|
self.build_dir.to_string_lossy().to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl Cmake {
|
||||||
"--install".into(),
|
"--install".into(),
|
||||||
self.build_dir.to_string_lossy().to_string(),
|
self.build_dir.to_string_lossy().to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ impl Git {
|
||||||
fn cmd(&self, args: Vec<String>) -> WorkerJob {
|
fn cmd(&self, args: Vec<String>) -> WorkerJob {
|
||||||
let mut nargs = vec!["-C".into(), self.dir.to_string_lossy().to_string()];
|
let mut nargs = vec!["-C".into(), self.dir.to_string_lossy().to_string()];
|
||||||
nargs.extend(args);
|
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 {
|
fn get_repo(&self) -> String {
|
||||||
|
@ -84,7 +84,7 @@ impl Git {
|
||||||
self.dir.to_string_lossy().to_string(),
|
self.dir.to_string_lossy().to_string(),
|
||||||
"--recurse-submodules".into(),
|
"--recurse-submodules".into(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
jobs.push_back(WorkerJob::new_cmd(
|
jobs.push_back(WorkerJob::new_cmd(
|
||||||
None,
|
None,
|
||||||
|
@ -101,7 +101,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
|
|
||||||
jobs
|
jobs
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn get_build_mercury_jobs(profile: &Profile) -> VecDeque<WorkerJob> {
|
||||||
profile.prefix.to_string_lossy().to_string(),
|
profile.prefix.to_string_lossy().to_string(),
|
||||||
get_cache_dir().to_string_lossy().to_string(),
|
get_cache_dir().to_string_lossy().to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
|
|
||||||
jobs
|
jobs
|
||||||
|
|
|
@ -62,7 +62,7 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque<
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// build job
|
// build job
|
||||||
|
@ -70,7 +70,7 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque<
|
||||||
None,
|
None,
|
||||||
"ninja".into(),
|
"ninja".into(),
|
||||||
Some(vec!["-C".into(), build_dir.to_string_lossy().to_string()]),
|
Some(vec!["-C".into(), build_dir.to_string_lossy().to_string()]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
// install job
|
// install job
|
||||||
jobs.push_back(WorkerJob::new_cmd(
|
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(),
|
build_dir.to_string_lossy().to_string(),
|
||||||
"install".into(),
|
"install".into(),
|
||||||
]),
|
]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
|
|
||||||
jobs
|
jobs
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl App {
|
||||||
self.debug_view.sender().emit(DebugViewMsg::ClearLog);
|
self.debug_view.sender().emit(DebugViewMsg::ClearLog);
|
||||||
self.xr_devices = vec![];
|
self.xr_devices = vec![];
|
||||||
if *IS_FLATPAK {
|
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()
|
.output()
|
||||||
.expect("Failed to remove xrservice IPC file");
|
.expect("Failed to remove xrservice IPC file");
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,7 +215,7 @@ impl App {
|
||||||
Some(prof.environment.clone()),
|
Some(prof.environment.clone()),
|
||||||
"sh".into(),
|
"sh".into(),
|
||||||
Some(vec!["-c".into(), autostart_cmd.clone()]),
|
Some(vec!["-c".into(), autostart_cmd.clone()]),
|
||||||
Some(true)
|
true
|
||||||
));
|
));
|
||||||
let autostart_worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
let autostart_worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
||||||
JobWorkerOut::Log(rows) => Msg::OnServiceLog(rows),
|
JobWorkerOut::Log(rows) => Msg::OnServiceLog(rows),
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl AsyncComponent for InstallWivrnBox {
|
||||||
"adb",
|
"adb",
|
||||||
Some(&["install", "-r", "-g", apk_path.to_string_lossy().to_string().as_str()]),
|
Some(&["install", "-r", "-g", apk_path.to_string_lossy().to_string().as_str()]),
|
||||||
None,
|
None,
|
||||||
None
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl Worker for InternalJobWorker {
|
||||||
match &mut job {
|
match &mut job {
|
||||||
WorkerJob::Cmd(data) => {
|
WorkerJob::Cmd(data) => {
|
||||||
let data = data.clone();
|
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())
|
.stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
@ -39,13 +39,13 @@ impl WorkerJob {
|
||||||
env: Option<HashMap<String, String>>,
|
env: Option<HashMap<String, String>>,
|
||||||
cmd: String,
|
cmd: String,
|
||||||
args: Option<Vec<String>>,
|
args: Option<Vec<String>>,
|
||||||
host_spawn: Option<bool>
|
host_spawn: bool
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::Cmd(CmdWorkerData {
|
Self::Cmd(CmdWorkerData {
|
||||||
environment: env.unwrap_or_default(),
|
environment: env.unwrap_or_default(),
|
||||||
command: cmd,
|
command: cmd,
|
||||||
args: args.unwrap_or_default(),
|
args: args.unwrap_or_default(),
|
||||||
host_spawn: host_spawn.unwrap_or_default(),
|
host_spawn,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl SimpleComponent for SteamVrCalibrationBox {
|
||||||
Some(env.clone()),
|
Some(env.clone()),
|
||||||
vrcmd.clone(),
|
vrcmd.clone(),
|
||||||
Some(vec!["--pollposes".into()]),
|
Some(vec!["--pollposes".into()]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
||||||
JobWorkerOut::Log(_) => Self::Input::NoOp,
|
JobWorkerOut::Log(_) => Self::Input::NoOp,
|
||||||
|
@ -179,7 +179,7 @@ impl SimpleComponent for SteamVrCalibrationBox {
|
||||||
Some(env),
|
Some(env),
|
||||||
vrcmd,
|
vrcmd,
|
||||||
Some(vec!["--resetroomsetup".into()]),
|
Some(vec!["--resetroomsetup".into()]),
|
||||||
Some(false),
|
false,
|
||||||
));
|
));
|
||||||
JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
||||||
JobWorkerOut::Log(_) => Self::Input::NoOp,
|
JobWorkerOut::Log(_) => Self::Input::NoOp,
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl AsyncComponent for WivrnWiredStartBox {
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
None,
|
None,
|
||||||
None
|
false,
|
||||||
).await {
|
).await {
|
||||||
Ok(out) if out.exit_code == 0 =>
|
Ok(out) if out.exit_code == 0 =>
|
||||||
StartClientStatus::Success
|
StartClientStatus::Success
|
||||||
|
|
|
@ -6,9 +6,9 @@ pub fn make_command<S: AsRef<OsStr>, T: AsRef<OsStr>>(
|
||||||
cmd: S,
|
cmd: S,
|
||||||
args: Option<&[T]>,
|
args: Option<&[T]>,
|
||||||
env: Option<HashMap<String, String>>,
|
env: Option<HashMap<String, String>>,
|
||||||
host_spawn: Option<bool>,
|
host_spawn: bool,
|
||||||
) -> Command {
|
) -> Command {
|
||||||
if *IS_FLATPAK && host_spawn.unwrap_or_default() {
|
if *IS_FLATPAK && host_spawn {
|
||||||
let mut flatpak_env = vec![];
|
let mut flatpak_env = vec![];
|
||||||
for (key, value) in env.unwrap_or_default() {
|
for (key, value) in env.unwrap_or_default() {
|
||||||
flatpak_env.push(format!("--env={}={}", key, value));
|
flatpak_env.push(format!("--env={}={}", key, value));
|
||||||
|
|
|
@ -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) {
|
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}");
|
eprintln!("Error: failed running setcap: {e}");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue