Kaynağa Gözat

Remove target triple from sidecar bin paths, closes #3355 (#3356)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Didrik Nordström 3 yıl önce
ebeveyn
işleme
3035e4581c

+ 6 - 0
.changes/sidecar-runtime-rename.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch
+"tauri-bundler": patch
+---
+
+**Breaking change**: The sidecar's target triple suffix is now removed at build time.

+ 9 - 0
.changes/universal-apple-target-sidecar.md

@@ -0,0 +1,9 @@
+---
+"tauri-bundler": patch
+"api": patch
+---
+
+When building Universal macOS Binaries through the virtual target `universal-apple-darwin`:
+
+- Expect a universal binary to be created by the user
+- Ensure that binary is bundled and accessed correctly at runtime

+ 1 - 6
core/tauri/src/api/process/command.rs

@@ -177,12 +177,7 @@ impl Command {
   /// A sidecar program is a embedded external binary in order to make your application work
   /// or to prevent users having to install additional dependencies (e.g. Node.js, Python, etc).
   pub fn new_sidecar<S: Into<String>>(program: S) -> crate::Result<Self> {
-    let program = format!(
-      "{}-{}",
-      program.into(),
-      platform::target_triple().expect("unsupported platform")
-    );
-    Ok(Self::new(relative_command_path(program)?))
+    Ok(Self::new(relative_command_path(program.into())?))
   }
 
   /// Appends arguments to the command.

+ 13 - 5
tooling/bundler/src/bundle/settings.rs

@@ -287,12 +287,18 @@ pub struct BundleSettings {
   pub bin: Option<HashMap<String, BundleSettings>>,
   /// External binaries to add to the bundle.
   ///
-  /// Note that each binary name will have the target platform's target triple appended,
-  /// so if you're bundling the `sqlite3` app, the bundler will look for e.g.
-  /// `sqlite3-x86_64-unknown-linux-gnu` on linux,
+  /// Note that each binary name should have the target platform's target triple appended,
+  /// as well as `.exe` for Windows.
+  /// For example, if you're bundling a sidecar called `sqlite3`, the bundler expects
+  /// a binary named `sqlite3-x86_64-unknown-linux-gnu` on linux,
   /// and `sqlite3-x86_64-pc-windows-gnu.exe` on windows.
   ///
-  /// The possible target triples can be seen by running `$ rustup target list`.
+  /// Run `tauri build --help` for more info on targets.
+  ///
+  /// If you are building a universal binary for MacOS, the bundler expects
+  /// your external binary to also be universal, and named after the target triple,
+  /// e.g. `sqlite3-universal-apple-darwin`. See
+  /// https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
   pub external_bin: Option<Vec<String>>,
   /// Debian-specific settings.
   pub deb: DebianSettings,
@@ -617,7 +623,9 @@ impl Settings {
       let dest = path.join(
         src
           .file_name()
-          .expect("failed to extract external binary filename"),
+          .expect("failed to extract external binary filename")
+          .to_string_lossy()
+          .replace(&format!("-{}", self.target), ""),
       );
       common::copy_file(&src, &dest)?;
     }