mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-27 11:48:37 +00:00
feat: build stardust
This commit is contained in:
parent
bca785d05a
commit
fd26cec29e
2 changed files with 82 additions and 14 deletions
|
@ -29,6 +29,7 @@ pub struct StardustClientSpec {
|
||||||
pub fn get_build_stardust_jobs(
|
pub fn get_build_stardust_jobs(
|
||||||
server_spec: StardustServerSpec,
|
server_spec: StardustServerSpec,
|
||||||
client_specs: &[StardustClientSpec],
|
client_specs: &[StardustClientSpec],
|
||||||
|
update: bool,
|
||||||
) -> VecDeque<WorkerJob> {
|
) -> VecDeque<WorkerJob> {
|
||||||
let mut jobs = VecDeque::<WorkerJob>::new();
|
let mut jobs = VecDeque::<WorkerJob>::new();
|
||||||
|
|
||||||
|
@ -37,15 +38,15 @@ pub fn get_build_stardust_jobs(
|
||||||
dir: get_data_dir() + "/stardust/stardust-xr-server",
|
dir: get_data_dir() + "/stardust/stardust-xr-server",
|
||||||
default_branch: server_spec.branch,
|
default_branch: server_spec.branch,
|
||||||
};
|
};
|
||||||
jobs.extend(server_git.get_pre_build_jobs(true));
|
jobs.extend(server_git.get_pre_build_jobs(update));
|
||||||
jobs.push_back(WorkerJob::new_cmd(
|
jobs.push_back(WorkerJob::new_cmd(
|
||||||
None,
|
None,
|
||||||
"cargo".into(),
|
"cargo".into(),
|
||||||
Some({
|
Some({
|
||||||
let mut args = vec![
|
let mut args = vec![
|
||||||
"build".into(),
|
"-C".into(),
|
||||||
"--path".into(),
|
|
||||||
server_git.dir,
|
server_git.dir,
|
||||||
|
"build".into(),
|
||||||
"--no-default-features".into(),
|
"--no-default-features".into(),
|
||||||
];
|
];
|
||||||
if server_spec.wayland_support {
|
if server_spec.wayland_support {
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
builders::build_stardust::{get_build_stardust_jobs, StardustServerSpec},
|
builders::build_stardust::{get_build_stardust_jobs, StardustServerSpec},
|
||||||
|
dependencies::stardust_deps::get_missing_stardust_deps,
|
||||||
|
linux_distro::get_distro,
|
||||||
stardust_config::StardustConfig,
|
stardust_config::StardustConfig,
|
||||||
stateless_action,
|
stateless_action,
|
||||||
ui::build_window::{BuildWindow, BuildWindowMsg, BuildWindowOutMsg},
|
ui::{
|
||||||
|
alert::alert,
|
||||||
|
build_window::{BuildStatus, BuildWindow, BuildWindowMsg, BuildWindowOutMsg},
|
||||||
|
job_worker::{internal_worker::JobWorkerOut, JobWorker},
|
||||||
|
},
|
||||||
withclones,
|
withclones,
|
||||||
};
|
};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
|
@ -15,8 +21,9 @@ use relm4::{
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum StardustViewMsg {
|
pub enum StardustViewMsg {
|
||||||
BuildStardust,
|
BuildStardust { update: bool },
|
||||||
UpdateStardust,
|
OnBuildLog(Vec<String>),
|
||||||
|
OnBuildExit(i32),
|
||||||
StartClicked,
|
StartClicked,
|
||||||
StopClicked,
|
StopClicked,
|
||||||
RestartClicked,
|
RestartClicked,
|
||||||
|
@ -49,6 +56,10 @@ pub struct StardustView {
|
||||||
stardust_service_active: bool,
|
stardust_service_active: bool,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
build_window: Controller<BuildWindow>,
|
build_window: Controller<BuildWindow>,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
root_win: gtk::Window,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
build_worker: Option<JobWorker>,
|
||||||
|
|
||||||
stardust_config: StardustConfig,
|
stardust_config: StardustConfig,
|
||||||
}
|
}
|
||||||
|
@ -243,9 +254,34 @@ impl SimpleComponent for StardustView {
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
Self::Input::BuildStardust => {
|
Self::Input::BuildStardust { update } => {
|
||||||
println!("Build");
|
let missing_deps = get_missing_stardust_deps();
|
||||||
get_build_stardust_jobs(
|
if !missing_deps.is_empty() {
|
||||||
|
let distro = get_distro();
|
||||||
|
alert(
|
||||||
|
"Missing dependencies:",
|
||||||
|
Some(
|
||||||
|
missing_deps
|
||||||
|
.iter()
|
||||||
|
.map(|dep| {
|
||||||
|
if let Some(d) = distro {
|
||||||
|
return dep
|
||||||
|
.packages
|
||||||
|
.get(&d)
|
||||||
|
.unwrap_or_else(|| &dep.name)
|
||||||
|
.clone();
|
||||||
|
}
|
||||||
|
dep.name.clone()
|
||||||
|
})
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ")
|
||||||
|
.as_str(),
|
||||||
|
),
|
||||||
|
Some(&self.root_win),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let jobs = get_build_stardust_jobs(
|
||||||
StardustServerSpec {
|
StardustServerSpec {
|
||||||
repo: self.stardust_config.repo.clone(),
|
repo: self.stardust_config.repo.clone(),
|
||||||
branch: self.stardust_config.branch.clone(),
|
branch: self.stardust_config.branch.clone(),
|
||||||
|
@ -253,12 +289,37 @@ impl SimpleComponent for StardustView {
|
||||||
wayland_support: true,
|
wayland_support: true,
|
||||||
},
|
},
|
||||||
&vec![],
|
&vec![],
|
||||||
|
update,
|
||||||
);
|
);
|
||||||
|
self.build_window
|
||||||
|
.sender()
|
||||||
|
.emit(BuildWindowMsg::UpdateTitle("Building Stardust XR".into()));
|
||||||
|
self.build_window
|
||||||
|
.sender()
|
||||||
|
.emit(BuildWindowMsg::UpdateCanClose(false));
|
||||||
self.build_window.sender().emit(BuildWindowMsg::Present);
|
self.build_window.sender().emit(BuildWindowMsg::Present);
|
||||||
|
let worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
|
||||||
|
JobWorkerOut::Log(rows) => Self::Input::OnBuildLog(rows),
|
||||||
|
JobWorkerOut::Exit(code) => Self::Input::OnBuildExit(code),
|
||||||
|
});
|
||||||
|
worker.start();
|
||||||
|
self.build_worker = Some(worker);
|
||||||
}
|
}
|
||||||
Self::Input::UpdateStardust => {
|
Self::Input::OnBuildLog(rows) => self
|
||||||
println!("Update");
|
.build_window
|
||||||
self.build_window.sender().emit(BuildWindowMsg::Present);
|
.sender()
|
||||||
|
.emit(BuildWindowMsg::UpdateContent(rows)),
|
||||||
|
Self::Input::OnBuildExit(status) => {
|
||||||
|
self.build_window
|
||||||
|
.sender()
|
||||||
|
.emit(BuildWindowMsg::UpdateCanClose(true));
|
||||||
|
self.build_window
|
||||||
|
.sender()
|
||||||
|
.emit(BuildWindowMsg::UpdateBuildStatus(if status == 0 {
|
||||||
|
BuildStatus::Done
|
||||||
|
} else {
|
||||||
|
BuildStatus::Error(format!("Exit status {}", status))
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
Self::Input::CancelBuild => {
|
Self::Input::CancelBuild => {
|
||||||
println!("Cancel Build");
|
println!("Cancel Build");
|
||||||
|
@ -348,6 +409,7 @@ impl SimpleComponent for StardustView {
|
||||||
let model = Self {
|
let model = Self {
|
||||||
tracker: 0,
|
tracker: 0,
|
||||||
stardust_service_active: false,
|
stardust_service_active: false,
|
||||||
|
root_win: init.root_win.clone(),
|
||||||
build_window: BuildWindow::builder()
|
build_window: BuildWindow::builder()
|
||||||
.transient_for(init.root_win)
|
.transient_for(init.root_win)
|
||||||
.launch(())
|
.launch(())
|
||||||
|
@ -355,6 +417,7 @@ impl SimpleComponent for StardustView {
|
||||||
BuildWindowOutMsg::CancelBuild => Self::Input::CancelBuild,
|
BuildWindowOutMsg::CancelBuild => Self::Input::CancelBuild,
|
||||||
}),
|
}),
|
||||||
stardust_config: StardustConfig::get_config(),
|
stardust_config: StardustConfig::get_config(),
|
||||||
|
build_worker: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
@ -364,13 +427,17 @@ impl SimpleComponent for StardustView {
|
||||||
{
|
{
|
||||||
withclones![sender];
|
withclones![sender];
|
||||||
stateless_action!(actions, BuildStardustAction, {
|
stateless_action!(actions, BuildStardustAction, {
|
||||||
sender.input_sender().emit(Self::Input::BuildStardust);
|
sender
|
||||||
|
.input_sender()
|
||||||
|
.emit(Self::Input::BuildStardust { update: false });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
withclones![sender];
|
withclones![sender];
|
||||||
stateless_action!(actions, UpdateStardustAction, {
|
stateless_action!(actions, UpdateStardustAction, {
|
||||||
sender.input_sender().emit(Self::Input::UpdateStardust);
|
sender
|
||||||
|
.input_sender()
|
||||||
|
.emit(Self::Input::BuildStardust { update: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue