Jelajahi Sumber

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 <amr.bashir2015@gmail.com>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Fabian-Lars 1 tahun lalu
induk
melakukan
4bffa5cff0

+ 5 - 0
.changes/shell-execute.md

@@ -0,0 +1,5 @@
+---
+"tauri": "patch:bug"
+---
+
+Fix compilation error when `shell-execute` or `shell-sidecar` features are not active

+ 1 - 0
core/tauri/src/endpoints.rs

@@ -40,6 +40,7 @@ mod window;
 /// The context passed to the invoke handler.
 pub struct InvokeContext<R: Runtime> {
   pub window: Window<R>,
+  #[allow(dead_code)]
   pub config: Arc<Config>,
   pub package_info: PackageInfo,
 }

+ 2 - 0
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,

+ 4 - 2
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<R: Runtime>(
   context: &InvokeContext<R>,
   program: &String,
@@ -301,7 +303,7 @@ fn prepare_cmd<R: Runtime>(
     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}")));

+ 14 - 16
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())

+ 1 - 0
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,
 }
 

+ 2 - 0
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,