Merge branch 'branch-for-services' into 'main'

feat: added branch specification for each service

See merge request gabmus/envision!29
This commit is contained in:
GabMus 2024-01-07 19:38:01 +00:00
commit c9d8f11c06
13 changed files with 92 additions and 12 deletions

View file

@ -6,7 +6,7 @@ use std::path::Path;
pub struct Git {
pub repo: String,
pub dir: String,
pub default_branch: String,
pub branch: String,
}
impl Git {
@ -88,7 +88,7 @@ impl Git {
}
pub fn get_checkout_ref_job(&self) -> WorkerJob {
let gref = self.get_ref().unwrap_or(self.default_branch.clone());
let gref = self.get_ref().unwrap_or(self.branch.clone());
self.cmd(vec!["checkout".into(), gref])
}

View file

@ -18,7 +18,10 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(),
},
dir: profile.features.basalt.path.as_ref().unwrap().clone(),
default_branch: "main".into(),
branch: match profile.features.basalt.branch.as_ref() {
Some(r) => r.clone(),
None => "main".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -18,7 +18,10 @@ pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeq
None => "https://github.com/cntools/libsurvive".into(),
},
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
default_branch: "master".into(),
branch: match profile.features.libsurvive.branch.as_ref() {
Some(r) => r.clone(),
None => "master".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -22,7 +22,10 @@ pub fn get_build_monado_jobs(
None => "https://gitlab.freedesktop.org/monado/monado".into(),
},
dir: profile.xrservice_path.clone(),
default_branch: "main".into(),
branch: match profile.xrservice_branch.as_ref() {
Some(r) => r.clone(),
None => "main".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -22,7 +22,10 @@ pub fn get_build_opencomposite_jobs(
None => "https://gitlab.com/znixian/OpenOVR.git".into(),
},
dir: profile.opencomposite_path.clone(),
default_branch: "openxr".into(),
branch: match profile.opencomposite_branch.as_ref() {
Some(r) => r.clone(),
None => "openxr".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -18,7 +18,10 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque<
None => "https://github.com/OpenHMD/OpenHMD".into(),
},
dir: profile.features.openhmd.path.as_ref().unwrap().clone(),
default_branch: "master".into(),
branch: match profile.features.openhmd.branch.as_ref() {
Some(r) => r.clone(),
None => "master".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -22,7 +22,10 @@ pub fn get_build_wivrn_jobs(
None => "https://github.com/Meumeu/WiVRn".into(),
},
dir: profile.xrservice_path.clone(),
default_branch: "master".into(),
branch: match profile.xrservice_branch.as_ref() {
Some(r) => r.clone(),
None => "master".into(),
},
};
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -90,6 +90,7 @@ pub struct ProfileFeature {
pub enabled: bool,
pub path: Option<String>,
pub repo: Option<String>,
pub branch: Option<String>,
}
impl Default for ProfileFeature {
@ -99,6 +100,7 @@ impl Default for ProfileFeature {
enabled: false,
path: None,
repo: None,
branch: None,
}
}
}
@ -210,10 +212,12 @@ pub struct Profile {
pub xrservice_type: XRServiceType,
pub xrservice_path: String,
pub xrservice_repo: Option<String>,
pub xrservice_branch: Option<String>,
#[serde(default = "HashMap::<String, String>::default")]
pub xrservice_cmake_flags: HashMap<String, String>,
pub opencomposite_path: String,
pub opencomposite_repo: Option<String>,
pub opencomposite_branch: Option<String>,
pub features: ProfileFeatures,
pub environment: HashMap<String, String>,
/** Install prefix */
@ -243,24 +247,28 @@ impl Default for Profile {
xrservice_path: format!("{}/xrservice", profile_dir),
xrservice_type: XRServiceType::Monado,
xrservice_repo: None,
xrservice_branch: None,
xrservice_cmake_flags: HashMap::<String, String>::default(),
features: ProfileFeatures {
libsurvive: ProfileFeature {
enabled: false,
path: Some(format!("{}/libsurvive", profile_dir)),
repo: None,
branch: None,
feature_type: ProfileFeatureType::Libsurvive,
},
basalt: ProfileFeature {
enabled: false,
path: Some(format!("{}/basalt", profile_dir)),
repo: None,
branch: None,
feature_type: ProfileFeatureType::Basalt,
},
openhmd: ProfileFeature {
enabled: false,
path: Some(format!("{}/openhmd", profile_dir)),
repo: None,
branch: None,
feature_type: ProfileFeatureType::OpenHmd,
},
mercury_enabled: false,
@ -269,8 +277,9 @@ impl Default for Profile {
prefix: format!("{}/prefixes/{}", get_data_dir(), uuid),
can_be_built: true,
pull_on_build: true,
opencomposite_repo: None,
opencomposite_path: format!("{}/opencomposite", profile_dir),
opencomposite_repo: None,
opencomposite_branch: None,
editable: true,
lighthouse_driver: LighthouseDriver::default(),
xrservice_launch_options: String::default(),
@ -337,17 +346,22 @@ impl Profile {
dup.name = format!("Duplicate of {}", self.name);
dup.xrservice_type = self.xrservice_type.clone();
dup.xrservice_repo = self.xrservice_repo.clone();
dup.xrservice_branch = self.xrservice_branch.clone();
dup.xrservice_cmake_flags = self.xrservice_cmake_flags.clone();
dup.features.libsurvive.enabled = self.features.libsurvive.enabled;
dup.features.libsurvive.repo = self.features.libsurvive.repo.clone();
dup.features.libsurvive.branch = self.features.libsurvive.branch.clone();
dup.features.basalt.enabled = self.features.basalt.enabled;
dup.features.basalt.repo = self.features.basalt.repo.clone();
dup.features.basalt.branch = self.features.basalt.branch.clone();
dup.features.openhmd.enabled = self.features.openhmd.enabled;
dup.features.openhmd.repo = self.features.openhmd.repo.clone();
dup.features.openhmd.branch = self.features.openhmd.branch.clone();
dup.features.mercury_enabled = self.features.mercury_enabled;
dup.environment = self.environment.clone();
dup.pull_on_build = self.pull_on_build;
dup.opencomposite_repo = self.opencomposite_repo.clone();
dup.opencomposite_branch = self.opencomposite_branch.clone();
dup.lighthouse_driver = self.lighthouse_driver;
dup.xrservice_launch_options = self.xrservice_launch_options.clone();
dup
@ -467,6 +481,7 @@ mod tests {
enabled: true,
path: Some(String::from("/home/user/libsurvive")),
repo: None,
branch: None,
},
basalt: ProfileFeature::default_basalt(),
openhmd: ProfileFeature::default_openhmd(),

View file

@ -34,6 +34,7 @@ pub fn openhmd_profile() -> Profile {
enabled: true,
path: Some(data_openhmd_path()),
repo: None,
branch: None,
},
..Default::default()
},

View file

@ -36,6 +36,7 @@ pub fn survive_profile() -> Profile {
enabled: true,
path: Some(data_libsurvive_path()),
repo: None,
branch: None,
},
..Default::default()
},

View file

@ -34,6 +34,7 @@ pub fn wmr_profile() -> Profile {
enabled: true,
path: Some(data_basalt_path()),
repo: None,
branch: None,
},
mercury_enabled: true,
..Default::default()

View file

@ -176,6 +176,14 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().xrservice_repo = (!n_val.is_empty()).then_some(n_val);
})
),
add: &entry_row(
"XR Service Branch",
model.profile.borrow().xrservice_branch.clone().unwrap_or_default().as_str(),
clone!(@strong prof => move |row| {
let n_val = row.text().to_string();
prof.borrow_mut().xrservice_branch = (!n_val.is_empty()).then_some(n_val);
})
),
},
add: model.xrservice_cmake_flags_rows.widget(),
add: opencompgrp = &adw::PreferencesGroup {
@ -197,6 +205,14 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().opencomposite_repo = (!n_val.is_empty()).then_some(n_val);
})
),
add: &entry_row(
"OpenComposite Branch",
model.profile.borrow().opencomposite_branch.clone().unwrap_or_default().as_str(),
clone!(@strong prof => move |row| {
let n_val = row.text().to_string();
prof.borrow_mut().opencomposite_branch = (!n_val.is_empty()).then_some(n_val);
})
),
},
add: libsurvivegrp = &adw::PreferencesGroup {
set_title: "Libsurvive",
@ -225,6 +241,14 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().features.libsurvive.repo = (!n_val.is_empty()).then_some(n_val);
})
),
add: &entry_row(
"Libsurvive Branch",
model.profile.borrow().features.libsurvive.branch.clone().unwrap_or_default().as_str(),
clone!(@strong prof => move |row| {
let n_val = row.text().to_string();
prof.borrow_mut().features.libsurvive.branch = (!n_val.is_empty()).then_some(n_val);
})
),
},
add: openhmdgrp = &adw::PreferencesGroup {
set_title: "OpenHMD",
@ -253,6 +277,14 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().features.openhmd.repo = (!n_val.is_empty()).then_some(n_val);
})
),
add: &entry_row(
"OpenHMD Branch",
model.profile.borrow().features.openhmd.branch.clone().unwrap_or_default().as_str(),
clone!(@strong prof => move |row| {
let n_val = row.text().to_string();
prof.borrow_mut().features.openhmd.branch = (!n_val.is_empty()).then_some(n_val);
})
),
},
add: basaltgrp = &adw::PreferencesGroup {
set_title: "Basalt",
@ -281,6 +313,14 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().features.basalt.repo = n_val.is_empty().then_some(n_val);
})
),
add: &entry_row(
"Basalt Branch",
model.profile.borrow().features.basalt.branch.clone().unwrap_or_default().as_str(),
clone!(@strong prof => move |row| {
let n_val = row.text().to_string();
prof.borrow_mut().features.basalt.branch = n_val.is_empty().then_some(n_val);
})
),
},
add: mercurygrp = &adw::PreferencesGroup {
set_title: "Mercury",

View file

@ -4,20 +4,24 @@
"xrservice_type": "Monado",
"xrservice_path": "/home/user/monado",
"xrservice_repo": null,
"xrservice_branch": null,
"opencomposite_path": "/home/user/opencomposite",
"opencomposite_repo": null,
"opencomposite_branch": null,
"features": {
"libsurvive": {
"feature_type": "Libsurvive",
"enabled": true,
"path": "/home/user/libsurvive",
"repo": null
"repo": null,
"branch": null
},
"basalt": {
"feature_type": "Basalt",
"enabled": false,
"path": null,
"repo": null
"repo": null,
"branch": null
},
"mercury_enabled": false
},
@ -30,4 +34,4 @@
"can_be_built": true,
"editable": true,
"pull_on_build": true
}
}