mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 03:24:52 +00:00
feat: cleanup, remove old runner from build tools
This commit is contained in:
parent
c996f5c81b
commit
abb283b206
15 changed files with 200 additions and 603 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{cmd_runner::CmdRunner, ui::workers::runner_worker::WorkerJob};
|
||||
use crate::ui::job_worker::job::WorkerJob;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -10,30 +10,6 @@ pub struct Cmake {
|
|||
}
|
||||
|
||||
impl Cmake {
|
||||
#[deprecated]
|
||||
pub fn get_prepare_runner(&self) -> CmdRunner {
|
||||
let mut args = vec![
|
||||
"-B".into(),
|
||||
self.build_dir.clone(),
|
||||
"-G".into(),
|
||||
"Ninja".into(),
|
||||
];
|
||||
if self.vars.is_some() {
|
||||
for (k, v) in self.vars.as_ref().unwrap() {
|
||||
if k.contains(' ') {
|
||||
panic!("Cmake vars cannot contain spaces!");
|
||||
}
|
||||
if v.contains(' ') {
|
||||
args.push(format!("-D{k}=\"{v}\"", k = k, v = v));
|
||||
} else {
|
||||
args.push(format!("-D{k}={v}", k = k, v = v));
|
||||
}
|
||||
}
|
||||
}
|
||||
args.push(self.source_dir.clone());
|
||||
CmdRunner::new(self.env.clone(), "cmake".into(), args)
|
||||
}
|
||||
|
||||
pub fn get_prepare_job(&self) -> WorkerJob {
|
||||
let mut args = vec![
|
||||
"-B".into(),
|
||||
|
@ -57,14 +33,6 @@ impl Cmake {
|
|||
WorkerJob::new_cmd(self.env.clone(), "cmake".into(), Some(args))
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_runner(&self) -> CmdRunner {
|
||||
CmdRunner::new(
|
||||
self.env.clone(),
|
||||
"cmake".into(),
|
||||
vec!["--build".into(), self.build_dir.clone()],
|
||||
)
|
||||
}
|
||||
pub fn get_build_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
self.env.clone(),
|
||||
|
@ -73,15 +41,6 @@ impl Cmake {
|
|||
)
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_install_runner(&self) -> CmdRunner {
|
||||
CmdRunner::new(
|
||||
self.env.clone(),
|
||||
"cmake".into(),
|
||||
vec!["--install".into(), self.build_dir.clone()],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_install_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
self.env.clone(),
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::{
|
||||
cmd_runner::CmdRunner,
|
||||
func_runner::{FuncRunner, FuncRunnerOut},
|
||||
profile::Profile,
|
||||
ui::workers::runner_worker::{FuncWorkerOut, WorkerJob},
|
||||
ui::job_worker::job::{FuncWorkerOut, WorkerJob},
|
||||
};
|
||||
use git2::Repository;
|
||||
use std::path::Path;
|
||||
|
@ -28,20 +26,6 @@ impl Git {
|
|||
split.next().map(|s| s.into())
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_reset_runner(&self) -> CmdRunner {
|
||||
CmdRunner::new(
|
||||
None,
|
||||
"git".into(),
|
||||
vec![
|
||||
"-C".into(),
|
||||
self.dir.clone(),
|
||||
"reset".into(),
|
||||
"--hard".into(),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_reset_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
|
@ -55,43 +39,6 @@ impl Git {
|
|||
)
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_override_remote_url_runner(&self) -> FuncRunner {
|
||||
let dir = self.dir.clone();
|
||||
let n_remote_url = self.get_repo();
|
||||
FuncRunner::new(Box::new(move || {
|
||||
if let Ok(repo) = Repository::open(dir) {
|
||||
if let Ok(remote) = repo.find_remote("origin") {
|
||||
if remote.url().unwrap_or("") != n_remote_url {
|
||||
if repo.remote_set_url("origin", &n_remote_url).is_ok() {
|
||||
return FuncRunnerOut {
|
||||
success: true,
|
||||
out: vec![],
|
||||
};
|
||||
}
|
||||
return FuncRunnerOut {
|
||||
success: false,
|
||||
out: vec!["Failed to set origin remote url".into()],
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return FuncRunnerOut {
|
||||
success: false,
|
||||
out: vec!["Could not find remote origin".into()],
|
||||
};
|
||||
}
|
||||
return FuncRunnerOut {
|
||||
success: true,
|
||||
out: vec![],
|
||||
};
|
||||
}
|
||||
FuncRunnerOut {
|
||||
success: true,
|
||||
out: vec![],
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn get_override_remote_url_job(&self) -> WorkerJob {
|
||||
let dir = self.dir.clone();
|
||||
let n_remote_url = self.get_repo();
|
||||
|
@ -128,15 +75,6 @@ impl Git {
|
|||
}))
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_pull_runner(&self) -> CmdRunner {
|
||||
CmdRunner::new(
|
||||
None,
|
||||
"git".into(),
|
||||
vec!["-C".into(), self.dir.clone(), "pull".into()],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_pull_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
|
@ -145,20 +83,6 @@ impl Git {
|
|||
)
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_clone_runner(&self) -> CmdRunner {
|
||||
CmdRunner::new(
|
||||
None,
|
||||
"git".into(),
|
||||
vec![
|
||||
"clone".into(),
|
||||
self.get_repo(),
|
||||
self.dir.clone(),
|
||||
"--recurse-submodules".into(),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_clone_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
|
@ -172,17 +96,6 @@ impl Git {
|
|||
)
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_checkout_ref_runner(&self) -> Option<CmdRunner> {
|
||||
self.get_ref().map(|r| {
|
||||
CmdRunner::new(
|
||||
None,
|
||||
"git".into(),
|
||||
vec!["-C".into(), self.dir.clone(), "checkout".into(), r],
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_checkout_ref_job(&self) -> Option<WorkerJob> {
|
||||
self.get_ref().map(|r| {
|
||||
WorkerJob::new_cmd(
|
||||
|
@ -193,16 +106,6 @@ impl Git {
|
|||
})
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_clone_or_not_runner(&self) -> Option<CmdRunner> {
|
||||
let path_s = format!("{}/.git", self.dir.clone());
|
||||
let path = Path::new(&path_s);
|
||||
if path.is_dir() {
|
||||
return None;
|
||||
}
|
||||
Some(self.get_clone_runner())
|
||||
}
|
||||
|
||||
pub fn get_clone_or_not_job(&self) -> Option<WorkerJob> {
|
||||
let path_s = format!("{}/.git", self.dir.clone());
|
||||
let path = Path::new(&path_s);
|
||||
|
@ -212,24 +115,13 @@ impl Git {
|
|||
Some(self.get_clone_job())
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn clone_or_pull(&self, profile: &Profile) -> Option<CmdRunner> {
|
||||
match self.get_clone_or_not_runner() {
|
||||
Some(r) => Some(r),
|
||||
None => match profile.pull_on_build {
|
||||
true => Some(self.get_pull_runner()),
|
||||
false => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_clone_or_pull_job(&self, profile: &Profile) -> Option<WorkerJob> {
|
||||
match self.get_clone_or_not_job() {
|
||||
Some(j) => Some(j),
|
||||
None => match profile.pull_on_build {
|
||||
true => Some(self.get_pull_job()),
|
||||
false => None,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use crate::{
|
||||
build_tools::{cmake::Cmake, git::Git},
|
||||
cmd_runner::CmdRunner,
|
||||
file_utils::rm_rf,
|
||||
profile::Profile,
|
||||
runner::Runner, ui::workers::runner_worker::WorkerJob,
|
||||
ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
path::Path,
|
||||
};
|
||||
use std::{collections::{HashMap, VecDeque}, path::Path};
|
||||
|
||||
pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
|
||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||
|
@ -19,7 +21,7 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
|||
};
|
||||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
});
|
||||
|
@ -91,88 +93,5 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
|||
]),
|
||||
));
|
||||
|
||||
|
||||
jobs
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_basalt_runners(profile: &Profile, clean_build: bool) -> Vec<Box<dyn Runner>> {
|
||||
let mut runners: Vec<Box<dyn Runner>> = vec![];
|
||||
let git = Git {
|
||||
repo: match profile.features.basalt.repo.as_ref() {
|
||||
Some(r) => r.clone(),
|
||||
None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(),
|
||||
},
|
||||
dir: profile.features.basalt.path.as_ref().unwrap().clone(),
|
||||
};
|
||||
runners.push(Box::new(git.get_override_remote_url_runner()));
|
||||
if let Some(r) = git.clone_or_pull(profile) {
|
||||
runners.push(Box::new(r));
|
||||
};
|
||||
if let Some(r) = git.get_checkout_ref_runner() {
|
||||
runners.push(Box::new(r));
|
||||
if profile.pull_on_build {
|
||||
runners.push(Box::new(git.get_pull_runner()));
|
||||
}
|
||||
}
|
||||
|
||||
let build_dir = format!("{}/build", profile.features.basalt.path.as_ref().unwrap());
|
||||
let mut cmake_vars: HashMap<String, String> = HashMap::new();
|
||||
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
|
||||
cmake_vars.insert("CMAKE_INSTALL_PREFIX".into(), profile.prefix.clone());
|
||||
cmake_vars.insert("BUILD_TESTS".into(), "OFF".into());
|
||||
cmake_vars.insert("BASALT_INSTANTIATIONS_DOUBLE".into(), "OFF".into());
|
||||
cmake_vars.insert(
|
||||
"CMAKE_INSTALL_LIBDIR".into(),
|
||||
format!("{}/lib", profile.prefix),
|
||||
);
|
||||
|
||||
let mut cmake_env: HashMap<String, String> = HashMap::new();
|
||||
cmake_env.insert("CMAKE_BUILD_PARALLEL_LEVEL".into(), "2".into());
|
||||
|
||||
let cmake = Cmake {
|
||||
env: Some(cmake_env),
|
||||
vars: Some(cmake_vars),
|
||||
source_dir: profile.features.basalt.path.as_ref().unwrap().clone(),
|
||||
build_dir: build_dir.clone(),
|
||||
};
|
||||
runners.push(Box::new(CmdRunner::new(None, "bash".into(), vec![
|
||||
"-c".into(),
|
||||
format!(
|
||||
"cd {repo}/thirdparty/Pangolin && git checkout include/pangolin/utils/picojson.h && curl -sSL 'https://aur.archlinux.org/cgit/aur.git/plain/279c17d9c9eb9374c89489b449f92cb93350e8cd.patch?h=basalt-monado-git' -o picojson_fix.patch && git apply picojson_fix.patch && sed -i '1s/^/#include <stdint.h>\\n/' include/pangolin/platform.h",
|
||||
repo = git.dir
|
||||
),
|
||||
])));
|
||||
if !Path::new(&build_dir).is_dir() || clean_build {
|
||||
rm_rf(&build_dir);
|
||||
runners.push(Box::new(cmake.get_prepare_runner()));
|
||||
}
|
||||
runners.push(Box::new(cmake.get_build_runner()));
|
||||
runners.push(Box::new(cmake.get_install_runner()));
|
||||
|
||||
runners.push(Box::new(CmdRunner::new(
|
||||
None,
|
||||
"mkdir".into(),
|
||||
vec![
|
||||
"-p".into(),
|
||||
format!(
|
||||
"{}/share/basalt/thirdparty/basalt-headers/thirdparty",
|
||||
profile.prefix
|
||||
),
|
||||
],
|
||||
)));
|
||||
runners.push(Box::new(CmdRunner::new(
|
||||
None,
|
||||
"cp".into(),
|
||||
vec![
|
||||
"-Ra".into(),
|
||||
format!(
|
||||
"{}/thirdparty/basalt-headers/thirdparty/eigen",
|
||||
profile.features.basalt.path.as_ref().unwrap().clone()
|
||||
),
|
||||
format!("{}/share/basalt/thirdparty", profile.prefix),
|
||||
],
|
||||
)));
|
||||
|
||||
runners
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@ use crate::{
|
|||
build_tools::{cmake::Cmake, git::Git},
|
||||
file_utils::rm_rf,
|
||||
profile::Profile,
|
||||
runner::Runner, ui::workers::runner_worker::WorkerJob,
|
||||
ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
path::Path,
|
||||
};
|
||||
use std::{collections::{HashMap, VecDeque}, path::Path};
|
||||
|
||||
pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
|
||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||
|
@ -59,54 +62,3 @@ pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeq
|
|||
|
||||
jobs
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_libsurvive_runners(profile: &Profile, clean_build: bool) -> Vec<Box<dyn Runner>> {
|
||||
let mut runners: Vec<Box<dyn Runner>> = vec![];
|
||||
let git = Git {
|
||||
repo: match profile.features.libsurvive.repo.as_ref() {
|
||||
Some(r) => r.clone(),
|
||||
None => "https://github.com/cntools/libsurvive".into(),
|
||||
},
|
||||
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
|
||||
};
|
||||
runners.push(Box::new(git.get_override_remote_url_runner()));
|
||||
if let Some(r) = git.clone_or_pull(profile) {
|
||||
runners.push(Box::new(r));
|
||||
};
|
||||
if let Some(r) = git.get_checkout_ref_runner() {
|
||||
runners.push(Box::new(r));
|
||||
if profile.pull_on_build {
|
||||
runners.push(Box::new(git.get_pull_runner()));
|
||||
}
|
||||
}
|
||||
|
||||
let build_dir = format!(
|
||||
"{}/build",
|
||||
profile.features.libsurvive.path.as_ref().unwrap()
|
||||
);
|
||||
let mut cmake_vars: HashMap<String, String> = HashMap::new();
|
||||
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
|
||||
cmake_vars.insert("ENABLE_api_example".into(), "OFF".into());
|
||||
cmake_vars.insert("CMAKE_SKIP_INSTALL_RPATH".into(), "YES".into());
|
||||
cmake_vars.insert("CMAKE_INSTALL_PREFIX".into(), profile.prefix.clone());
|
||||
cmake_vars.insert(
|
||||
"CMAKE_INSTALL_LIBDIR".into(),
|
||||
format!("{}/lib", profile.prefix),
|
||||
);
|
||||
|
||||
let cmake = Cmake {
|
||||
env: None,
|
||||
vars: Some(cmake_vars),
|
||||
source_dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
|
||||
build_dir: build_dir.clone(),
|
||||
};
|
||||
if !Path::new(&build_dir).is_dir() || clean_build {
|
||||
rm_rf(&build_dir);
|
||||
runners.push(Box::new(cmake.get_prepare_runner()));
|
||||
}
|
||||
runners.push(Box::new(cmake.get_build_runner()));
|
||||
runners.push(Box::new(cmake.get_install_runner()));
|
||||
|
||||
runners
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
cmd_runner::CmdRunner, constants::pkg_data_dir, paths::get_cache_dir, profile::Profile, ui::workers::runner_worker::WorkerJob,
|
||||
constants::pkg_data_dir, paths::get_cache_dir, profile::Profile, ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
|
||||
pub fn get_build_mercury_job(profile: &Profile) -> WorkerJob {
|
||||
|
@ -9,19 +9,6 @@ pub fn get_build_mercury_job(profile: &Profile) -> WorkerJob {
|
|||
"{sysdata}/scripts/build_mercury.sh",
|
||||
sysdata = pkg_data_dir()
|
||||
),
|
||||
Some(vec![profile.prefix.clone(), get_cache_dir()])
|
||||
)
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_mercury_runner(profile: &Profile) -> CmdRunner {
|
||||
let args = vec![profile.prefix.clone(), get_cache_dir()];
|
||||
CmdRunner::new(
|
||||
None,
|
||||
format!(
|
||||
"{sysdata}/scripts/build_mercury.sh",
|
||||
sysdata = pkg_data_dir()
|
||||
),
|
||||
args,
|
||||
Some(vec![profile.prefix.clone(), get_cache_dir()]),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@ use crate::{
|
|||
build_tools::{cmake::Cmake, git::Git},
|
||||
file_utils::rm_rf,
|
||||
profile::Profile,
|
||||
runner::Runner, ui::workers::runner_worker::WorkerJob,
|
||||
ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
path::Path,
|
||||
};
|
||||
use std::{collections::{HashMap, VecDeque}, path::Path};
|
||||
|
||||
pub fn get_build_monado_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
|
||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||
|
@ -64,60 +67,3 @@ pub fn get_build_monado_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
|||
|
||||
jobs
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_monado_runners(profile: &Profile, clean_build: bool) -> Vec<Box<dyn Runner>> {
|
||||
let mut runners: Vec<Box<dyn Runner>> = vec![];
|
||||
let git = Git {
|
||||
repo: match profile.xrservice_repo.as_ref() {
|
||||
Some(r) => r.clone(),
|
||||
None => "https://gitlab.freedesktop.org/monado/monado".into(),
|
||||
},
|
||||
dir: profile.xrservice_path.clone(),
|
||||
};
|
||||
runners.push(Box::new(git.get_override_remote_url_runner()));
|
||||
if let Some(r) = git.clone_or_pull(profile) {
|
||||
runners.push(Box::new(r));
|
||||
}
|
||||
if let Some(r) = git.get_checkout_ref_runner() {
|
||||
runners.push(Box::new(r));
|
||||
if profile.pull_on_build {
|
||||
runners.push(Box::new(git.get_pull_runner()));
|
||||
}
|
||||
}
|
||||
|
||||
let build_dir = format!("{}/build", profile.xrservice_path);
|
||||
let mut env: HashMap<String, String> = HashMap::new();
|
||||
env.insert(
|
||||
"PKG_CONFIG_PATH".into(),
|
||||
format!("{}/lib/pkgconfig", profile.prefix),
|
||||
);
|
||||
let mut cmake_vars: HashMap<String, String> = HashMap::new();
|
||||
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
|
||||
cmake_vars.insert("XRT_HAVE_SYSTEM_CJSON".into(), "NO".into());
|
||||
cmake_vars.insert("CMAKE_LIBDIR".into(), format!("{}/lib", profile.prefix));
|
||||
cmake_vars.insert("CMAKE_INSTALL_PREFIX".into(), profile.prefix.clone());
|
||||
cmake_vars.insert(
|
||||
"CMAKE_C_FLAGS".into(),
|
||||
format!("-Wl,-rpath='{}/lib'", profile.prefix),
|
||||
);
|
||||
cmake_vars.insert(
|
||||
"CMAKE_CXX_FLAGS".into(),
|
||||
format!("-Wl,-rpath='{}/lib'", profile.prefix),
|
||||
);
|
||||
|
||||
let cmake = Cmake {
|
||||
env: Some(env),
|
||||
vars: Some(cmake_vars),
|
||||
source_dir: profile.xrservice_path.clone(),
|
||||
build_dir: build_dir.clone(),
|
||||
};
|
||||
if !Path::new(&build_dir).is_dir() || clean_build {
|
||||
rm_rf(&build_dir);
|
||||
runners.push(Box::new(cmake.get_prepare_runner()));
|
||||
}
|
||||
runners.push(Box::new(cmake.get_build_runner()));
|
||||
runners.push(Box::new(cmake.get_install_runner()));
|
||||
|
||||
runners
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ use crate::{
|
|||
build_tools::{cmake::Cmake, git::Git},
|
||||
file_utils::rm_rf,
|
||||
profile::Profile,
|
||||
runner::Runner, ui::workers::runner_worker::WorkerJob,
|
||||
ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
path::Path,
|
||||
};
|
||||
use std::{collections::{HashMap, VecDeque}, path::Path};
|
||||
|
||||
pub fn get_build_opencomposite_jobs(
|
||||
profile: &Profile,
|
||||
clean_build: bool,
|
||||
) -> VecDeque<WorkerJob> {
|
||||
pub fn get_build_opencomposite_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
|
||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||
|
||||
let git = Git {
|
||||
|
@ -50,45 +50,3 @@ pub fn get_build_opencomposite_jobs(
|
|||
|
||||
jobs
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_opencomposite_runners(
|
||||
profile: &Profile,
|
||||
clean_build: bool,
|
||||
) -> Vec<Box<dyn Runner>> {
|
||||
let mut runners: Vec<Box<dyn Runner>> = vec![];
|
||||
let git = Git {
|
||||
repo: match profile.opencomposite_repo.as_ref() {
|
||||
Some(r) => r.clone(),
|
||||
None => "https://gitlab.com/znixian/OpenOVR.git".into(),
|
||||
},
|
||||
dir: profile.opencomposite_path.clone(),
|
||||
};
|
||||
runners.push(Box::new(git.get_override_remote_url_runner()));
|
||||
if let Some(r) = git.clone_or_pull(profile) {
|
||||
runners.push(Box::new(r));
|
||||
};
|
||||
if let Some(r) = git.get_checkout_ref_runner() {
|
||||
runners.push(Box::new(r));
|
||||
if profile.pull_on_build {
|
||||
runners.push(Box::new(git.get_pull_runner()));
|
||||
}
|
||||
}
|
||||
|
||||
let build_dir = format!("{}/build", profile.opencomposite_path);
|
||||
let mut cmake_vars: HashMap<String, String> = HashMap::new();
|
||||
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
|
||||
let cmake = Cmake {
|
||||
env: None,
|
||||
vars: Some(cmake_vars),
|
||||
source_dir: profile.opencomposite_path.clone(),
|
||||
build_dir: build_dir.clone(),
|
||||
};
|
||||
if !Path::new(&build_dir).is_dir() || clean_build {
|
||||
rm_rf(&build_dir);
|
||||
runners.push(Box::new(cmake.get_prepare_runner()));
|
||||
}
|
||||
runners.push(Box::new(cmake.get_build_runner()));
|
||||
|
||||
runners
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@ use crate::{
|
|||
build_tools::{cmake::Cmake, git::Git},
|
||||
file_utils::rm_rf,
|
||||
profile::Profile,
|
||||
runner::Runner, ui::workers::runner_worker::WorkerJob,
|
||||
ui::job_worker::job::WorkerJob,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
path::Path,
|
||||
};
|
||||
use std::{collections::{HashMap, VecDeque}, path::Path};
|
||||
|
||||
pub fn get_build_wivrn_jobs(profile: &Profile, clean_build: bool) -> VecDeque<WorkerJob> {
|
||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||
|
@ -52,47 +55,3 @@ pub fn get_build_wivrn_jobs(profile: &Profile, clean_build: bool) -> VecDeque<Wo
|
|||
|
||||
jobs
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn get_build_wivrn_runners(profile: &Profile, clean_build: bool) -> Vec<Box<dyn Runner>> {
|
||||
let mut runners: Vec<Box<dyn Runner>> = vec![];
|
||||
let git = Git {
|
||||
repo: match profile.xrservice_repo.as_ref() {
|
||||
Some(r) => r.clone(),
|
||||
None => "https://github.com/Meumeu/WiVRn".into(),
|
||||
},
|
||||
dir: profile.xrservice_path.clone(),
|
||||
};
|
||||
runners.push(Box::new(git.get_override_remote_url_runner()));
|
||||
if let Some(r) = git.clone_or_pull(profile) {
|
||||
runners.push(Box::new(r));
|
||||
}
|
||||
if let Some(r) = git.get_checkout_ref_runner() {
|
||||
runners.push(Box::new(r));
|
||||
if profile.pull_on_build {
|
||||
runners.push(Box::new(git.get_pull_runner()));
|
||||
}
|
||||
}
|
||||
|
||||
let build_dir = format!("{}/build", profile.xrservice_path);
|
||||
let mut cmake_vars: HashMap<String, String> = HashMap::new();
|
||||
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
|
||||
cmake_vars.insert("XRT_HAVE_SYSTEM_CJSON".into(), "NO".into());
|
||||
cmake_vars.insert("WIVRN_BUILD_CLIENT".into(), "OFF".into());
|
||||
cmake_vars.insert("CMAKE_INSTALL_PREFIX".into(), profile.prefix.clone());
|
||||
|
||||
let cmake = Cmake {
|
||||
env: None,
|
||||
vars: Some(cmake_vars),
|
||||
source_dir: profile.xrservice_path.clone(),
|
||||
build_dir: build_dir.clone(),
|
||||
};
|
||||
if !Path::new(&build_dir).is_dir() || clean_build {
|
||||
rm_rf(&build_dir);
|
||||
runners.push(Box::new(cmake.get_prepare_runner()));
|
||||
}
|
||||
runners.push(Box::new(cmake.get_build_runner()));
|
||||
runners.push(Box::new(cmake.get_install_runner()));
|
||||
|
||||
runners
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ use super::alert::alert;
|
|||
use super::build_window::{BuildStatus, BuildWindow};
|
||||
use super::debug_view::{DebugView, DebugViewMsg};
|
||||
use super::fbt_config_editor::{FbtConfigEditor, FbtConfigEditorInit, FbtConfigEditorMsg};
|
||||
use super::job_worker::internal_worker::JobWorkerOut;
|
||||
use super::job_worker::job::WorkerJob;
|
||||
use super::job_worker::JobWorker;
|
||||
use super::libsurvive_setup_window::LibsurviveSetupWindow;
|
||||
use super::main_view::MainViewMsg;
|
||||
use super::workers::runner_worker::{
|
||||
RunnerWorkerMsg, RunnerWorkerOut, RunnerWorkerWrap, WorkerJob,
|
||||
};
|
||||
use crate::builders::build_basalt::get_build_basalt_jobs;
|
||||
use crate::builders::build_libsurvive::get_build_libsurvive_jobs;
|
||||
use crate::builders::build_mercury::get_build_mercury_job;
|
||||
|
@ -81,11 +81,11 @@ pub struct App {
|
|||
#[tracker::do_not_track]
|
||||
config: Config,
|
||||
#[tracker::do_not_track]
|
||||
xrservice_worker: Option<RunnerWorkerWrap>,
|
||||
xrservice_worker: Option<JobWorker>,
|
||||
#[tracker::do_not_track]
|
||||
restart_xrservice: bool,
|
||||
#[tracker::do_not_track]
|
||||
build_worker: Option<RunnerWorkerWrap>,
|
||||
build_worker: Option<JobWorker>,
|
||||
#[tracker::do_not_track]
|
||||
profiles: Vec<Profile>,
|
||||
#[tracker::do_not_track]
|
||||
|
@ -164,12 +164,12 @@ impl App {
|
|||
remove_file(&get_ipc_file_path(&prof.xrservice_type))
|
||||
.is_err()
|
||||
.then(|| println!("Failed to remove xrservice IPC file"));
|
||||
let worker = RunnerWorkerWrap::xrservice_worker_wrap_from_profile(
|
||||
let worker = JobWorker::xrservice_worker_wrap_from_profile(
|
||||
&prof,
|
||||
sender.input_sender(),
|
||||
|msg| match msg {
|
||||
RunnerWorkerOut::Log(rows) => Msg::OnServiceLog(rows),
|
||||
RunnerWorkerOut::Exit(code) => Msg::OnServiceExit(code),
|
||||
JobWorkerOut::Log(rows) => Msg::OnServiceLog(rows),
|
||||
JobWorkerOut::Exit(code) => Msg::OnServiceExit(code),
|
||||
},
|
||||
);
|
||||
worker.start();
|
||||
|
@ -417,9 +417,9 @@ impl SimpleComponent for App {
|
|||
.sender()
|
||||
.send(BuildWindowMsg::Present)
|
||||
.unwrap();
|
||||
let worker = RunnerWorkerWrap::new(jobs, sender.input_sender(), |msg| match msg {
|
||||
RunnerWorkerOut::Log(rows) => Msg::OnBuildLog(rows),
|
||||
RunnerWorkerOut::Exit(code) => Msg::OnBuildExit(code),
|
||||
let worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
||||
JobWorkerOut::Log(rows) => Msg::OnBuildLog(rows),
|
||||
JobWorkerOut::Exit(code) => Msg::OnBuildExit(code),
|
||||
});
|
||||
worker.start();
|
||||
self.build_window
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
use crate::{profile::Profile, withclones};
|
||||
use nix::{
|
||||
sys::signal::{
|
||||
kill,
|
||||
Signal::{SIGKILL, SIGTERM},
|
||||
},
|
||||
unistd::Pid,
|
||||
|
||||
use super::{
|
||||
job::{CmdWorkerData, FuncWorkerOut, WorkerJob},
|
||||
state::JobWorkerState,
|
||||
};
|
||||
use relm4::{prelude::*, Sender, Worker, WorkerController};
|
||||
use nix::unistd::Pid;
|
||||
use relm4::{prelude::*, Worker};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
collections::VecDeque,
|
||||
io::{BufRead, BufReader},
|
||||
mem,
|
||||
process::{Command, Stdio},
|
||||
sync::{Arc, Mutex},
|
||||
thread::{self, sleep},
|
||||
time::Duration,
|
||||
thread,
|
||||
};
|
||||
|
||||
macro_rules! logger_thread {
|
||||
|
@ -44,72 +42,31 @@ macro_rules! logger_thread {
|
|||
};
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CmdWorkerData {
|
||||
pub environment: HashMap<String, String>,
|
||||
pub command: String,
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct FuncWorkerOut {
|
||||
pub success: bool,
|
||||
pub out: Vec<String>,
|
||||
}
|
||||
|
||||
pub struct FuncWorkerData {
|
||||
pub func: Box<dyn FnOnce() -> FuncWorkerOut + Send + Sync + 'static>,
|
||||
}
|
||||
|
||||
pub enum WorkerJob {
|
||||
Cmd(CmdWorkerData),
|
||||
Func(FuncWorkerData),
|
||||
}
|
||||
|
||||
impl WorkerJob {
|
||||
pub fn new_cmd(env: Option<HashMap<String, String>>, cmd: String, args: Option<Vec<String>>) -> Self {
|
||||
Self::Cmd(CmdWorkerData { environment: env.unwrap_or_default(), command: cmd, args: args.unwrap_or_default() })
|
||||
}
|
||||
|
||||
pub fn new_func(func: Box<dyn FnOnce() -> FuncWorkerOut + Send + Sync + 'static>) -> Self {
|
||||
Self::Func(FuncWorkerData { func })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RunnerWorkerOut {
|
||||
pub enum JobWorkerOut {
|
||||
Log(Vec<String>),
|
||||
Exit(i32),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RunnerWorkerMsg {
|
||||
pub enum JobWorkerMsg {
|
||||
Start,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct RunnerWorkerState {
|
||||
pub current_pid: Option<Pid>,
|
||||
pub exit_status: Option<i32>,
|
||||
pub stop_requested: bool,
|
||||
pub started: bool,
|
||||
pub exited: bool,
|
||||
}
|
||||
|
||||
pub struct RunnerWorker {
|
||||
pub struct InternalJobWorker {
|
||||
jobs: VecDeque<WorkerJob>,
|
||||
state: Arc<Mutex<RunnerWorkerState>>,
|
||||
state: Arc<Mutex<JobWorkerState>>,
|
||||
}
|
||||
|
||||
pub struct RunnerWorkerInit {
|
||||
pub struct JobWorkerInit {
|
||||
pub jobs: VecDeque<WorkerJob>,
|
||||
pub state: Arc<Mutex<RunnerWorkerState>>,
|
||||
pub state: Arc<Mutex<JobWorkerState>>,
|
||||
}
|
||||
|
||||
impl Worker for RunnerWorker {
|
||||
type Init = RunnerWorkerInit;
|
||||
type Input = RunnerWorkerMsg;
|
||||
type Output = RunnerWorkerOut;
|
||||
impl Worker for InternalJobWorker {
|
||||
type Init = JobWorkerInit;
|
||||
type Input = JobWorkerMsg;
|
||||
type Output = JobWorkerOut;
|
||||
|
||||
fn init(init: Self::Init, _sender: ComponentSender<Self>) -> Self {
|
||||
Self {
|
||||
|
@ -118,7 +75,7 @@ impl Worker for RunnerWorker {
|
|||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: RunnerWorkerMsg, sender: ComponentSender<Self>) {
|
||||
fn update(&mut self, msg: JobWorkerMsg, sender: ComponentSender<Self>) {
|
||||
// Send the result of the calculation back
|
||||
match msg {
|
||||
Self::Input::Start => {
|
||||
|
@ -183,11 +140,11 @@ impl Worker for RunnerWorker {
|
|||
}
|
||||
}
|
||||
|
||||
impl RunnerWorker {
|
||||
impl InternalJobWorker {
|
||||
pub fn xrservice_worker_from_profile(
|
||||
prof: &Profile,
|
||||
state: Arc<Mutex<RunnerWorkerState>>,
|
||||
) -> relm4::WorkerHandle<RunnerWorker> {
|
||||
state: Arc<Mutex<JobWorkerState>>,
|
||||
) -> relm4::WorkerHandle<InternalJobWorker> {
|
||||
let mut env = prof.environment.clone();
|
||||
if !env.contains_key("LH_DRIVER") {
|
||||
env.insert(
|
||||
|
@ -202,70 +159,6 @@ impl RunnerWorker {
|
|||
};
|
||||
let mut jobs = VecDeque::new();
|
||||
jobs.push_back(WorkerJob::Cmd(data));
|
||||
Self::builder().detach_worker(RunnerWorkerInit { jobs, state })
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RunnerWorkerWrap {
|
||||
pub worker: WorkerController<RunnerWorker>,
|
||||
pub state: Arc<Mutex<RunnerWorkerState>>,
|
||||
}
|
||||
|
||||
impl RunnerWorkerWrap {
|
||||
pub fn new<X: 'static, F: (Fn(RunnerWorkerOut) -> X) + 'static>(
|
||||
jobs: VecDeque<WorkerJob>,
|
||||
sender: &Sender<X>,
|
||||
transform: F,
|
||||
) -> Self {
|
||||
let state = Arc::new(Mutex::new(RunnerWorkerState::default()));
|
||||
let init = RunnerWorkerInit {
|
||||
jobs,
|
||||
state: state.clone(),
|
||||
};
|
||||
Self {
|
||||
worker: RunnerWorker::builder()
|
||||
.detach_worker(init)
|
||||
.forward(sender, transform),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn xrservice_worker_wrap_from_profile<
|
||||
X: 'static,
|
||||
F: (Fn(RunnerWorkerOut) -> X) + 'static,
|
||||
>(
|
||||
prof: &Profile,
|
||||
sender: &Sender<X>,
|
||||
transform: F,
|
||||
) -> Self {
|
||||
let state = Arc::new(Mutex::new(RunnerWorkerState::default()));
|
||||
Self {
|
||||
worker: RunnerWorker::xrservice_worker_from_profile(prof, state.clone())
|
||||
.forward(sender, transform),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(&self) {
|
||||
self.worker.emit(RunnerWorkerMsg::Start);
|
||||
}
|
||||
|
||||
pub fn stop(&self) {
|
||||
if self.state.lock().unwrap().started && !self.state.lock().unwrap().exited {
|
||||
self.state.lock().unwrap().stop_requested = true;
|
||||
if let Some(pid) = self.state.lock().unwrap().current_pid {
|
||||
kill(pid, SIGTERM).expect("Could not send sigterm to process");
|
||||
let state = self.state.clone();
|
||||
thread::spawn(move || {
|
||||
sleep(Duration::from_secs(2));
|
||||
if let Ok(s) = state.lock() {
|
||||
if s.exited {
|
||||
// process is still alive
|
||||
kill(pid, SIGKILL).expect("Failed to kill process");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Self::builder().detach_worker(JobWorkerInit { jobs, state })
|
||||
}
|
||||
}
|
41
src/ui/job_worker/job.rs
Normal file
41
src/ui/job_worker/job.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CmdWorkerData {
|
||||
pub environment: HashMap<String, String>,
|
||||
pub command: String,
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct FuncWorkerOut {
|
||||
pub success: bool,
|
||||
pub out: Vec<String>,
|
||||
}
|
||||
|
||||
pub struct FuncWorkerData {
|
||||
pub func: Box<dyn FnOnce() -> FuncWorkerOut + Send + Sync + 'static>,
|
||||
}
|
||||
|
||||
pub enum WorkerJob {
|
||||
Cmd(CmdWorkerData),
|
||||
Func(FuncWorkerData),
|
||||
}
|
||||
|
||||
impl WorkerJob {
|
||||
pub fn new_cmd(
|
||||
env: Option<HashMap<String, String>>,
|
||||
cmd: String,
|
||||
args: Option<Vec<String>>,
|
||||
) -> Self {
|
||||
Self::Cmd(CmdWorkerData {
|
||||
environment: env.unwrap_or_default(),
|
||||
command: cmd,
|
||||
args: args.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_func(func: Box<dyn FnOnce() -> FuncWorkerOut + Send + Sync + 'static>) -> Self {
|
||||
Self::Func(FuncWorkerData { func })
|
||||
}
|
||||
}
|
82
src/ui/job_worker/mod.rs
Normal file
82
src/ui/job_worker/mod.rs
Normal file
|
@ -0,0 +1,82 @@
|
|||
use self::{
|
||||
internal_worker::{InternalJobWorker, JobWorkerInit, JobWorkerMsg, JobWorkerOut},
|
||||
job::WorkerJob,
|
||||
state::JobWorkerState,
|
||||
};
|
||||
use crate::profile::Profile;
|
||||
use nix::sys::signal::{
|
||||
kill,
|
||||
Signal::{SIGKILL, SIGTERM},
|
||||
};
|
||||
use relm4::{prelude::*, Sender, WorkerController};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
sync::{Arc, Mutex},
|
||||
thread::{self, sleep},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
pub mod internal_worker;
|
||||
pub mod job;
|
||||
pub mod state;
|
||||
|
||||
pub struct JobWorker {
|
||||
pub worker: WorkerController<InternalJobWorker>,
|
||||
pub state: Arc<Mutex<JobWorkerState>>,
|
||||
}
|
||||
|
||||
impl JobWorker {
|
||||
pub fn new<X: 'static, F: (Fn(JobWorkerOut) -> X) + 'static>(
|
||||
jobs: VecDeque<WorkerJob>,
|
||||
sender: &Sender<X>,
|
||||
transform: F,
|
||||
) -> Self {
|
||||
let state = Arc::new(Mutex::new(JobWorkerState::default()));
|
||||
let init = JobWorkerInit {
|
||||
jobs,
|
||||
state: state.clone(),
|
||||
};
|
||||
Self {
|
||||
worker: InternalJobWorker::builder()
|
||||
.detach_worker(init)
|
||||
.forward(sender, transform),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn xrservice_worker_wrap_from_profile<X: 'static, F: (Fn(JobWorkerOut) -> X) + 'static>(
|
||||
prof: &Profile,
|
||||
sender: &Sender<X>,
|
||||
transform: F,
|
||||
) -> Self {
|
||||
let state = Arc::new(Mutex::new(JobWorkerState::default()));
|
||||
Self {
|
||||
worker: InternalJobWorker::xrservice_worker_from_profile(prof, state.clone())
|
||||
.forward(sender, transform),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(&self) {
|
||||
self.worker.emit(JobWorkerMsg::Start);
|
||||
}
|
||||
|
||||
pub fn stop(&self) {
|
||||
if self.state.lock().unwrap().started && !self.state.lock().unwrap().exited {
|
||||
self.state.lock().unwrap().stop_requested = true;
|
||||
if let Some(pid) = self.state.lock().unwrap().current_pid {
|
||||
kill(pid, SIGTERM).expect("Could not send sigterm to process");
|
||||
let state = self.state.clone();
|
||||
thread::spawn(move || {
|
||||
sleep(Duration::from_secs(2));
|
||||
if let Ok(s) = state.lock() {
|
||||
if s.exited {
|
||||
// process is still alive
|
||||
kill(pid, SIGKILL).expect("Failed to kill process");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
src/ui/job_worker/state.rs
Normal file
10
src/ui/job_worker/state.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use nix::unistd::Pid;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct JobWorkerState {
|
||||
pub current_pid: Option<Pid>,
|
||||
pub exit_status: Option<i32>,
|
||||
pub stop_requested: bool,
|
||||
pub started: bool,
|
||||
pub exited: bool,
|
||||
}
|
|
@ -7,6 +7,7 @@ pub mod devices_box;
|
|||
pub mod factories;
|
||||
pub mod fbt_config_editor;
|
||||
pub mod install_wivrn_box;
|
||||
pub mod job_worker;
|
||||
pub mod libsurvive_setup_window;
|
||||
pub mod macros;
|
||||
pub mod main_view;
|
||||
|
@ -15,4 +16,3 @@ pub mod profile_editor;
|
|||
pub mod steam_launch_options_box;
|
||||
pub mod util;
|
||||
pub mod wivrn_conf_editor;
|
||||
pub mod workers;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
pub mod runner_worker;
|
Loading…
Add table
Reference in a new issue