Skip to content

Commit

Permalink
Disable messagebox for Appimage
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Aug 25, 2023
1 parent 828976d commit 5e8a9da
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 116 deletions.
189 changes: 89 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion alvr/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ rust-version.workspace = true
authors.workspace = true
license.workspace = true

[features]
enable-messagebox = ["rfd"]

[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
backtrace = "0.3"
Expand All @@ -19,4 +22,4 @@ settings-schema = { git = "https://github.com/zarik5/settings-schema-rs" }
# settings-schema = { path = "../../../../settings-schema-rs/settings-schema" }

[target.'cfg(not(target_os = "android"))'.dependencies]
rfd = "0.11"
rfd = {version = "0.11", optional = true }
6 changes: 3 additions & 3 deletions alvr/common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn set_panic_hook() {

log::error!("{err_str}");

#[cfg(not(target_os = "android"))]
#[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))]
std::thread::spawn(move || {
rfd::MessageDialog::new()
.set_title("ALVR panicked")
Expand All @@ -63,7 +63,7 @@ pub fn set_panic_hook() {
pub fn show_w<W: Display + Send + 'static>(w: W) {
log::warn!("{w}");

#[cfg(not(target_os = "android"))]
#[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))]
std::thread::spawn(move || {
rfd::MessageDialog::new()
.set_title("ALVR warning")
Expand All @@ -81,7 +81,7 @@ pub fn show_warn<T, E: Display + Send + 'static>(res: Result<T, E>) -> Option<T>
fn show_e_block<E: Display>(e: E, blocking: bool) {
log::error!("{e}");

#[cfg(not(target_os = "android"))]
#[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))]
{
// Store the last error shown in a message box. Do not open a new message box if the content
// of the error has not changed
Expand Down
1 change: 1 addition & 0 deletions alvr/launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
alvr_common.workspace = true
alvr_gui_common.workspace = true

anyhow = "1"
Expand Down
7 changes: 4 additions & 3 deletions alvr/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ pub fn create_recording_file() {
"h265"
};

let path = FILESYSTEM_LAYOUT
.log_dir
.join(format!("recording.{}.{ext}", chrono::Local::now().format("%F.%H-%M-%S")));
let path = FILESYSTEM_LAYOUT.log_dir.join(format!(
"recording.{}.{ext}",
chrono::Local::now().format("%F.%H-%M-%S")
));

match File::create(path) {
Ok(mut file) => {
Expand Down
11 changes: 10 additions & 1 deletion alvr/xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl Display for Profile {

pub fn build_streamer(
profile: Profile,
enable_messagebox: bool,
gpl: bool,
root: Option<String>,
reproducible: bool,
Expand All @@ -46,6 +47,10 @@ pub fn build_streamer(
Profile::Release => common_flags.push("--release"),
Profile::Debug => (),
}
if enable_messagebox {
common_flags.push("--features");
common_flags.push("alvr_common/enable-messagebox");
}
if reproducible {
common_flags.push("--locked");
}
Expand Down Expand Up @@ -191,7 +196,7 @@ pub fn build_streamer(
}
}

pub fn build_launcher(profile: Profile, reproducible: bool) {
pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: bool) {
let sh = Shell::new().unwrap();

let mut common_flags = vec![];
Expand All @@ -203,6 +208,10 @@ pub fn build_launcher(profile: Profile, reproducible: bool) {
Profile::Release => common_flags.push("--release"),
Profile::Debug => (),
}
if enable_messagebox {
common_flags.push("--features");
common_flags.push("alvr_common/enable-messagebox");
}
if reproducible {
common_flags.push("--locked");
}
Expand Down
12 changes: 7 additions & 5 deletions alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,26 @@ fn main() {
dependencies::build_android_deps(for_ci);
}
}
"build-streamer" => build::build_streamer(profile, gpl, None, false, keep_config),
"build-launcher" => build::build_launcher(profile, false),
"build-streamer" => {
build::build_streamer(profile, true, gpl, None, false, keep_config)
}
"build-launcher" => build::build_launcher(profile, true, false),
"build-client" => build::build_android_client(profile),
"build-client-lib" => build::build_client_lib(profile, link_stdcpp),
"run-streamer" => {
if !no_rebuild {
build::build_streamer(profile, gpl, None, false, keep_config);
build::build_streamer(profile, true, gpl, None, false, keep_config);
}
run_streamer();
}
"run-launcher" => {
if !no_rebuild {
build::build_launcher(profile, false);
build::build_launcher(profile, true, false);
}
run_launcher();
}
"package-streamer" => packaging::package_streamer(gpl, root, appimage, zsync),
"package-launcher" => packaging::package_launcher(),
"package-launcher" => packaging::package_launcher(appimage),
"package-client" => build::build_android_client(Profile::Distribution),
"package-client-lib" => packaging::package_client_lib(link_stdcpp),
"clean" => clean(),
Expand Down
6 changes: 3 additions & 3 deletions alvr/xtask/src/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn include_licenses(root_path: &Path, gpl: bool) {
pub fn package_streamer(gpl: bool, root: Option<String>, appimage: bool, zsync: bool) {
let sh = Shell::new().unwrap();

build::build_streamer(Profile::Distribution, gpl, root, true, false);
build::build_streamer(Profile::Distribution, !appimage, gpl, root, true, false);

include_licenses(&afs::streamer_build_dir(), gpl);

Expand All @@ -166,10 +166,10 @@ pub fn package_streamer(gpl: bool, root: Option<String>, appimage: bool, zsync:
}
}

pub fn package_launcher() {
pub fn package_launcher(appimage: bool) {
let sh = Shell::new().unwrap();

build::build_launcher(Profile::Distribution, true);
build::build_launcher(Profile::Distribution, !appimage, true);

include_licenses(&afs::launcher_build_dir(), false);

Expand Down

0 comments on commit 5e8a9da

Please sign in to comment.