From 4bffa5cff04a3f5da8c2493f835f560ac4a31247 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Tue, 2 Jul 2024 12:38:46 +0200 Subject: [PATCH] fix(core): fix compilation when `shell-execute` or `shell-sidecar` (#10174) * fix(core): fix compilation when `shell-execute` or `shell-sidecar` (#9729) * fix(core): fix compilation when `shell-execute` or `shell-sidecar` regression from: https://github.com/tauri-apps/tauri/pull/9706 * change file * lint --------- Co-authored-by: Amr Bashir Co-authored-by: Lucas Nogueira --- .changes/shell-execute.md | 5 ++++ core/tauri/src/endpoints.rs | 1 + core/tauri/src/endpoints/notification.rs | 2 ++ core/tauri/src/endpoints/shell.rs | 6 +++-- tooling/bundler/src/bundle/macos/sign.rs | 30 ++++++++++------------ tooling/bundler/src/bundle/path_utils.rs | 1 + tooling/bundler/src/bundle/windows/sign.rs | 2 ++ 7 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 .changes/shell-execute.md diff --git a/.changes/shell-execute.md b/.changes/shell-execute.md new file mode 100644 index 000000000000..1f014e0a5b8e --- /dev/null +++ b/.changes/shell-execute.md @@ -0,0 +1,5 @@ +--- +"tauri": "patch:bug" +--- + +Fix compilation error when `shell-execute` or `shell-sidecar` features are not active \ No newline at end of file diff --git a/core/tauri/src/endpoints.rs b/core/tauri/src/endpoints.rs index 5a942a0e9565..491b8262f065 100644 --- a/core/tauri/src/endpoints.rs +++ b/core/tauri/src/endpoints.rs @@ -40,6 +40,7 @@ mod window; /// The context passed to the invoke handler. pub struct InvokeContext { pub window: Window, + #[allow(dead_code)] pub config: Arc, pub package_info: PackageInfo, } diff --git a/core/tauri/src/endpoints/notification.rs b/core/tauri/src/endpoints/notification.rs index 87a1d21c593f..d822a34c4053 100644 --- a/core/tauri/src/endpoints/notification.rs +++ b/core/tauri/src/endpoints/notification.rs @@ -18,6 +18,7 @@ const PERMISSION_GRANTED: &str = "granted"; const PERMISSION_DENIED: &str = "denied"; #[derive(Debug, Clone)] +#[allow(dead_code)] pub enum SoundDto { Default, Custom(String), @@ -49,6 +50,7 @@ impl<'de> Deserialize<'de> for SoundDto { /// The options for the notification API. #[derive(Debug, Clone, Deserialize)] +#[allow(dead_code)] pub struct NotificationOptions { /// The notification title. pub title: String, diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index d40689f8f5a9..ec138f82212c 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -110,7 +110,8 @@ impl Cmd { let encoding = options .encoding .as_ref() - .and_then(|encoding| crate::api::process::Encoding::for_label(encoding.as_bytes())); + .and_then(|encoding| encoding_rs::Encoding::for_label(encoding.as_bytes())); + let command = prepare_cmd(&context, &program, args, options)?; let mut command: std::process::Command = command.into(); @@ -236,6 +237,7 @@ impl Cmd { } } +#[cfg(any(shell_execute, shell_sidecar))] fn prepare_cmd( context: &InvokeContext, program: &String, @@ -301,7 +303,7 @@ fn prepare_cmd( command = command.env_clear(); } if let Some(encoding) = &options.encoding { - if let Some(encoding) = crate::api::process::Encoding::for_label(encoding.as_bytes()) { + if let Some(encoding) = encoding_rs::Encoding::for_label(encoding.as_bytes()) { command = command.encoding(encoding); } else { return Err(anyhow::anyhow!(format!("unknown encoding {encoding}"))); diff --git a/tooling/bundler/src/bundle/macos/sign.rs b/tooling/bundler/src/bundle/macos/sign.rs index bbdcd55daae2..48f7bfcddcbd 100644 --- a/tooling/bundler/src/bundle/macos/sign.rs +++ b/tooling/bundler/src/bundle/macos/sign.rs @@ -305,23 +305,21 @@ pub fn notarize( log::info!(action = "Notarizing"; "{}", log_message); staple_app(app_bundle_path)?; Ok(()) - } else { - if let Ok(output) = Command::new("xcrun") - .args(["notarytool", "log"]) - .arg(&submit_output.id) - .notarytool_args(&auth) - .output_ok() - { - Err( - anyhow::anyhow!( - "{log_message}\nLog:\n{}", - String::from_utf8_lossy(&output.stdout) - ) - .into(), + } else if let Ok(output) = Command::new("xcrun") + .args(["notarytool", "log"]) + .arg(&submit_output.id) + .notarytool_args(&auth) + .output_ok() + { + Err( + anyhow::anyhow!( + "{log_message}\nLog:\n{}", + String::from_utf8_lossy(&output.stdout) ) - } else { - Err(anyhow::anyhow!("{log_message}").into()) - } + .into(), + ) + } else { + Err(anyhow::anyhow!("{log_message}").into()) } } else { Err(anyhow::anyhow!("failed to parse notarytool output as JSON: `{output_str}`").into()) diff --git a/tooling/bundler/src/bundle/path_utils.rs b/tooling/bundler/src/bundle/path_utils.rs index ef9c0fea7732..f3adfe0f4a10 100644 --- a/tooling/bundler/src/bundle/path_utils.rs +++ b/tooling/bundler/src/bundle/path_utils.rs @@ -18,6 +18,7 @@ pub struct DirOpts { pub struct FileOpts { pub overwrite: bool, pub skip: bool, + #[allow(dead_code)] pub buffer_size: usize, } diff --git a/tooling/bundler/src/bundle/windows/sign.rs b/tooling/bundler/src/bundle/windows/sign.rs index 6e6033ca9320..2ea1cadbc462 100644 --- a/tooling/bundler/src/bundle/windows/sign.rs +++ b/tooling/bundler/src/bundle/windows/sign.rs @@ -42,6 +42,8 @@ impl Settings { } } } + +#[allow(dead_code)] pub struct SignParams { pub product_name: String, pub digest_algorithm: String,