Repository navigation
fix(cli): allow build --bundles nsis arg in linux+macOS
#14954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
58826c0
8e69607
b4fbfb2
1eda599
7766962
7bf8f16
904a9cd
e02c76a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri-cli": patch:bug | ||
| "@tauri-apps/cli": patch:bug | ||
| --- | ||
|
|
||
| Fix `build --bundles` to allow `nsis` arg in linux+macOS | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| // SPDX-License-Identifier: MIT | ||
|
|
||
| mod category; | ||
| #[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| mod kmp; | ||
| #[cfg(target_os = "linux")] | ||
| mod linux; | ||
|
|
@@ -17,10 +16,8 @@ mod windows; | |
|
|
||
| use tauri_utils::{display_path, platform::Target as TargetPlatform}; | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| const BUNDLE_VAR_TOKEN: &[u8] = b"__TAURI_BUNDLE_TYPE_VAR_UNK"; | ||
| /// Patch a binary with bundle type information | ||
| #[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| fn patch_binary(binary: &PathBuf, package_type: &PackageType) -> crate::Result<()> { | ||
| log::info!( | ||
| "Patching {} with bundle type information: {}", | ||
|
|
@@ -37,6 +34,8 @@ fn patch_binary(binary: &PathBuf, package_type: &PackageType) -> crate::Result<( | |
| crate::PackageType::Deb => b"__TAURI_BUNDLE_TYPE_VAR_DEB", | ||
| crate::PackageType::Rpm => b"__TAURI_BUNDLE_TYPE_VAR_RPM", | ||
| crate::PackageType::AppImage => b"__TAURI_BUNDLE_TYPE_VAR_APP", | ||
| // NSIS installers can be built in linux using cargo-xwin | ||
| crate::PackageType::Nsis => b"__TAURI_BUNDLE_TYPE_VAR_NSS", | ||
| _ => { | ||
| return Err(crate::Error::InvalidPackageType( | ||
| package_type.short_name().to_owned(), | ||
|
|
@@ -55,6 +54,17 @@ fn patch_binary(binary: &PathBuf, package_type: &PackageType) -> crate::Result<( | |
| )) | ||
| } | ||
| }; | ||
| #[cfg(target_os = "macos")] | ||
| let bundle_type = match package_type { | ||
| // NSIS installers can be built in macOS using cargo-xwin | ||
| crate::PackageType::Nsis => b"__TAURI_BUNDLE_TYPE_VAR_NSS", | ||
| _ => { | ||
| return Err(crate::Error::InvalidPackageType( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't test it but i think this will return an error when you're building for macos on macos now. I think we still should not patch these binaries but we could return
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops yeah it emitted a warning about but still but continued with the rest of the bundling process since patching is best-effort: if let Err(e) = patch_binary(&main_binary_path, package_type) {
log::warn!("Failed to add bundler type to the binary: {e}. Updater plugin may not be able to update this package. This shouldn't normally happen, please report it to https://github.com/tauri-apps/tauri/issues");
}I moved things around a bit, lmk what you think macos native bundle: macos host + cargo-xwin: linux host + cargo-xin: |
||
| package_type.short_name().to_owned(), | ||
| "macOS".to_owned(), | ||
| )) | ||
| } | ||
| }; | ||
|
|
||
| file_data[bundle_var_index..bundle_var_index + BUNDLE_VAR_TOKEN.len()] | ||
| .copy_from_slice(bundle_type); | ||
|
|
@@ -133,7 +143,6 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> { | |
| continue; | ||
| } | ||
|
|
||
| #[cfg(any(target_os = "linux", target_os = "windows"))] | ||
| if let Err(e) = patch_binary(&main_binary_path, package_type) { | ||
| log::warn!("Failed to add bundler type to the binary: {e}. Updater plugin may not be able to update this package. This shouldn't normally happen, please report it to https://github.com/tauri-apps/tauri/issues"); | ||
| } | ||
|
|
@@ -163,7 +172,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> { | |
|
|
||
| #[cfg(target_os = "windows")] | ||
| PackageType::WindowsMsi => windows::msi::bundle_project(settings, false)?, | ||
| // note: don't restrict to windows as NSIS installers can be built in linux using cargo-xwin | ||
| // don't restrict to windows as NSIS installers can be built in linux+macOS using cargo-xwin | ||
| PackageType::Nsis => windows::nsis::bundle_project(settings, false)?, | ||
|
|
||
| #[cfg(target_os = "linux")] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.