feat: added branch specification for each service

This commit is contained in:
PLYSHKA 2024-01-07 19:38:01 +00:00 committed by GabMus
commit f71855cf19
13 changed files with 92 additions and 12 deletions

View file

@ -6,7 +6,7 @@ use std::path::Path;
pub struct Git { pub struct Git {
pub repo: String, pub repo: String,
pub dir: String, pub dir: String,
pub default_branch: String, pub branch: String,
} }
impl Git { impl Git {
@ -88,7 +88,7 @@ impl Git {
} }
pub fn get_checkout_ref_job(&self) -> WorkerJob { 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]) 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(), None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(),
}, },
dir: profile.features.basalt.path.as_ref().unwrap().clone(), 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)); 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(), None => "https://github.com/cntools/libsurvive".into(),
}, },
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(), 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)); 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(), None => "https://gitlab.freedesktop.org/monado/monado".into(),
}, },
dir: profile.xrservice_path.clone(), 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)); 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(), None => "https://gitlab.com/znixian/OpenOVR.git".into(),
}, },
dir: profile.opencomposite_path.clone(), 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)); 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(), None => "https://github.com/OpenHMD/OpenHMD".into(),
}, },
dir: profile.features.openhmd.path.as_ref().unwrap().clone(), 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)); 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(), None => "https://github.com/Meumeu/WiVRn".into(),
}, },
dir: profile.xrservice_path.clone(), 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)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

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

View file

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

View file

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

View file

@ -34,6 +34,7 @@ pub fn wmr_profile() -> Profile {
enabled: true, enabled: true,
path: Some(data_basalt_path()), path: Some(data_basalt_path()),
repo: None, repo: None,
branch: None,
}, },
mercury_enabled: true, mercury_enabled: true,
..Default::default() ..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); 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: model.xrservice_cmake_flags_rows.widget(),
add: opencompgrp = &adw::PreferencesGroup { 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); 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 { add: libsurvivegrp = &adw::PreferencesGroup {
set_title: "Libsurvive", 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); 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 { add: openhmdgrp = &adw::PreferencesGroup {
set_title: "OpenHMD", 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); 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 { add: basaltgrp = &adw::PreferencesGroup {
set_title: "Basalt", 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); 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 { add: mercurygrp = &adw::PreferencesGroup {
set_title: "Mercury", set_title: "Mercury",

View file

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