feat: command line option to skip dependency checks

This commit is contained in:
Gabriele Musco 2024-04-15 07:03:17 +02:00
parent 984cbd7d32
commit be4c50f020
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
2 changed files with 19 additions and 1 deletions

View file

@ -103,6 +103,9 @@ pub struct App {
#[tracker::do_not_track]
wivrn_conf_editor: Option<Controller<WivrnConfEditor>>,
#[tracker::do_not_track]
skip_depcheck: bool,
}
#[derive(Debug)]
@ -460,7 +463,7 @@ impl SimpleComponent for App {
// no listed deps for opencomp
}
jobs.extend(get_build_opencomposite_jobs(&profile, clean_build));
if !missing_deps.is_empty() {
if !(self.skip_depcheck || missing_deps.is_empty()) {
missing_deps.sort_unstable();
missing_deps.dedup(); // dedup only works if sorted, hence the above
let distro = LinuxDistro::get();
@ -731,6 +734,9 @@ impl SimpleComponent for App {
if opts.start {
sender.input(Msg::DoStartStopXRService)
}
if opts.skip_depcheck {
self.skip_depcheck = true;
}
}
}
}
@ -821,6 +827,7 @@ impl SimpleComponent for App {
restart_xrservice: false,
libmonado: None,
wivrn_conf_editor: None,
skip_depcheck: false,
};
let widgets = view_output!();

View file

@ -11,12 +11,14 @@ use gtk4::{
pub struct CmdLineOpts {
pub start: bool,
pub profile_uuid: Option<String>,
pub skip_depcheck: bool,
}
impl CmdLineOpts {
const OPT_START: (&'static str, char) = ("start", 'S');
const OPT_LIST_PROFILES: (&'static str, char) = ("list-profiles", 'l');
const OPT_PROFILE: (&'static str, char) = ("profile", 'p');
const OPT_SKIP_DEPCHECK: (&'static str, char) = ("skip-dependency-check", 'd');
pub fn init(app: &impl IsA<Application>) {
app.add_main_option(
@ -43,6 +45,14 @@ impl CmdLineOpts {
"Switch to the profile indicated by the UUID",
None,
);
app.add_main_option(
Self::OPT_SKIP_DEPCHECK.0,
glib::Char::try_from(Self::OPT_SKIP_DEPCHECK.1).unwrap(),
glib::OptionFlags::IN_MAIN,
glib::OptionArg::None,
"Skip dependency checks when building profiles",
None,
);
}
/// returns true if the application should quit
@ -67,6 +77,7 @@ impl CmdLineOpts {
Ok(None) => None,
Ok(Some(variant)) => Some(variant),
},
skip_depcheck: opts.contains(Self::OPT_SKIP_DEPCHECK.0),
}
}
}