feat: option to dirty or clean build profile

This commit is contained in:
Gabriele Musco 2023-07-21 18:28:38 +02:00
parent cefdf35734
commit a71a0fd291
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
6 changed files with 46 additions and 28 deletions

View file

@ -4,9 +4,9 @@ use crate::{
profile::Profile,
runner::Runner,
};
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
pub fn get_build_libsurvive_runners(profile: &Profile) -> Vec<Runner> {
pub fn get_build_libsurvive_runners(profile: &Profile, clean_build: bool) -> Vec<Runner> {
let mut runners: Vec<Runner> = vec![];
let git = Git {
repo: match profile.features.libsurvive.repo.as_ref() {
@ -24,7 +24,6 @@ pub fn get_build_libsurvive_runners(profile: &Profile) -> Vec<Runner> {
"{}/build",
profile.features.libsurvive.path.as_ref().unwrap()
);
rm_rf(&build_dir);
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());
@ -39,9 +38,12 @@ pub fn get_build_libsurvive_runners(profile: &Profile) -> Vec<Runner> {
env: None,
vars: Some(cmake_vars),
source_dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
build_dir,
build_dir: build_dir.clone(),
};
runners.push(cmake.get_prepare_runner());
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
runners.push(cmake.get_prepare_runner());
}
runners.push(cmake.get_build_runner());
runners.push(cmake.get_install_runner());

View file

@ -4,9 +4,9 @@ use crate::{
profile::Profile,
runner::Runner,
};
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
pub fn get_build_monado_runners(profile: &Profile) -> Vec<Runner> {
pub fn get_build_monado_runners(profile: &Profile, clean_build: bool) -> Vec<Runner> {
let mut runners: Vec<Runner> = vec![];
let git = Git {
repo: match profile.xrservice_repo.as_ref() {
@ -21,7 +21,6 @@ pub fn get_build_monado_runners(profile: &Profile) -> Vec<Runner> {
};
let build_dir = format!("{}/build", profile.xrservice_path);
rm_rf(&build_dir);
let mut env: HashMap<String, String> = HashMap::new();
env.insert(
"PKG_CONFIG_PATH".into(),
@ -45,9 +44,12 @@ pub fn get_build_monado_runners(profile: &Profile) -> Vec<Runner> {
env: Some(env),
vars: Some(cmake_vars),
source_dir: profile.xrservice_path.clone(),
build_dir,
build_dir: build_dir.clone(),
};
runners.push(cmake.get_prepare_runner());
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
runners.push(cmake.get_prepare_runner());
}
runners.push(cmake.get_build_runner());
runners.push(cmake.get_install_runner());

View file

@ -4,9 +4,9 @@ use crate::{
profile::Profile,
runner::Runner,
};
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
pub fn get_build_opencomposite_runners(profile: &Profile) -> Vec<Runner> {
pub fn get_build_opencomposite_runners(profile: &Profile, clean_build: bool) -> Vec<Runner> {
let mut runners: Vec<Runner> = vec![];
let git = Git {
repo: match profile.opencomposite_repo.as_ref() {
@ -21,16 +21,18 @@ pub fn get_build_opencomposite_runners(profile: &Profile) -> Vec<Runner> {
};
let build_dir = format!("{}/build", profile.opencomposite_path);
rm_rf(&build_dir);
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: build_dir.clone(),
};
runners.push(cmake.get_prepare_runner());
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
runners.push(cmake.get_prepare_runner());
}
runners.push(cmake.get_build_runner());
runners

View file

@ -4,9 +4,9 @@ use crate::{
profile::Profile,
runner::Runner,
};
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
pub fn get_build_wivrn_runners(profile: &Profile) -> Vec<Runner> {
pub fn get_build_wivrn_runners(profile: &Profile, clean_build: bool) -> Vec<Runner> {
let mut runners: Vec<Runner> = vec![];
let git = Git {
repo: match profile.xrservice_repo.as_ref() {
@ -21,7 +21,6 @@ pub fn get_build_wivrn_runners(profile: &Profile) -> Vec<Runner> {
};
let build_dir = format!("{}/build", profile.xrservice_path);
rm_rf(&build_dir);
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());
@ -32,9 +31,12 @@ pub fn get_build_wivrn_runners(profile: &Profile) -> Vec<Runner> {
env: None,
vars: Some(cmake_vars),
source_dir: profile.xrservice_path.clone(),
build_dir,
build_dir: build_dir.clone(),
};
runners.push(cmake.get_prepare_runner());
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
runners.push(cmake.get_prepare_runner());
}
runners.push(cmake.get_build_runner());
runners.push(cmake.get_install_runner());

View file

@ -89,7 +89,7 @@ pub struct App {
#[derive(Debug)]
pub enum Msg {
ClockTicking,
BuildProfile,
BuildProfile(bool),
EnableDebugViewChanged(bool),
DoStartStopXRService,
RestartXRService,
@ -357,7 +357,7 @@ impl SimpleComponent for App {
}
self.start_xrservice();
}
Msg::BuildProfile => {
Msg::BuildProfile(clean_build) => {
let profile = self.get_selected_profile();
let mut missing_deps = vec![];
let mut runners: Vec<Runner> = vec![];
@ -369,7 +369,7 @@ impl SimpleComponent for App {
});
if profile.features.libsurvive.enabled {
missing_deps.extend(get_missing_libsurvive_deps());
runners.extend(get_build_libsurvive_runners(&profile));
runners.extend(get_build_libsurvive_runners(&profile, clean_build));
}
if profile.features.basalt.enabled {
missing_deps.extend(get_missing_basalt_deps());
@ -380,12 +380,12 @@ impl SimpleComponent for App {
runners.push(get_build_mercury_runner(&profile));
}
runners.extend(match profile.xrservice_type {
XRServiceType::Monado => get_build_monado_runners(&profile),
XRServiceType::Wivrn => get_build_wivrn_runners(&profile),
XRServiceType::Monado => get_build_monado_runners(&profile, clean_build),
XRServiceType::Wivrn => get_build_wivrn_runners(&profile, clean_build),
});
// no listed deps for opencomp
}
runners.extend(get_build_opencomposite_runners(&profile));
runners.extend(get_build_opencomposite_runners(&profile, clean_build));
if !missing_deps.is_empty() {
missing_deps.sort_unstable();
missing_deps.dedup(); // dedup only works if sorted, hence the above
@ -598,7 +598,14 @@ impl SimpleComponent for App {
let buildprofile_action = {
let this_sender = sender.clone();
RelmAction::<BuildProfileAction>::new_stateless(move |_| {
this_sender.input_sender().emit(Msg::BuildProfile);
this_sender.input_sender().emit(Msg::BuildProfile(false));
})
};
let buildprofileclean_action = {
let this_sender = sender.clone();
RelmAction::<BuildProfileCleanAction>::new_stateless(move |_| {
this_sender.input_sender().emit(Msg::BuildProfile(true));
})
};
@ -638,6 +645,7 @@ impl SimpleComponent for App {
actions.add_action(about_action);
actions.add_action(quit_action);
actions.add_action(buildprofile_action);
actions.add_action(buildprofileclean_action);
actions.add_action(debug_view_toggle_action);
actions.add_action(libsurvive_setup_action);
@ -665,6 +673,7 @@ impl SimpleComponent for App {
new_action_group!(pub AppActionGroup, "win");
new_stateless_action!(pub AboutAction, AppActionGroup, "about");
new_stateless_action!(pub BuildProfileAction, AppActionGroup, "buildprofile");
new_stateless_action!(pub BuildProfileCleanAction, AppActionGroup, "buildprofileclean");
new_stateless_action!(pub LibsurviveSetupAction, AppActionGroup, "libsurvivesetup");
new_stateless_action!(pub QuitAction, AppActionGroup, "quit");
new_stateful_action!(pub DebugViewToggleAction, AppActionGroup, "debugviewtoggle", (), bool);

View file

@ -6,7 +6,7 @@ use crate::config::Config;
use crate::constants::APP_NAME;
use crate::profile::{Profile, XRServiceType};
use crate::ui::app::{
AboutAction, BuildProfileAction, DebugViewToggleAction, LibsurviveSetupAction,
AboutAction, BuildProfileAction, DebugViewToggleAction, LibsurviveSetupAction, BuildProfileCleanAction,
};
use crate::ui::profile_editor::ProfileEditorInit;
use crate::xr_devices::XRDevices;
@ -87,6 +87,7 @@ impl SimpleComponent for MainView {
// value inside action is ignored
"_Debug View" => DebugViewToggleAction,
"_Build Profile" => BuildProfileAction,
"C_lean Build Profile" => BuildProfileCleanAction,
"_Calibrate Lighthouses" => LibsurviveSetupAction,
},
section! {