Skip to content

Commit 265c238

Browse files
refactor(cli&bundler): avoid renaming main executable and preserve cargo name (#9375)
* refactor(cli&bundler): avoid renaming main executable and reserve cargo name closes #8109 closes #8349 * fix bundler * fix test * Discard changes to core/tauri-build/Cargo.toml * revert Cargo.toml changes * Discard changes to Cargo.lock * Discard changes to tooling/cli/Cargo.lock * lock file * use product name for installers * only warn for sign on windows --------- Co-authored-by: Lucas Nogueira <lucas@tauri.studio> Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
1 parent e8f6eb5 commit 265c238

22 files changed

Lines changed: 116 additions & 241 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-cli": "patch:breaking"
3+
"@tauri-apps/cli": "patch:breaking"
4+
---
5+
6+
Avoid renaming main binary to product name and perserve the name generated by cargo.
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-utils": "patch:breaking"
3+
---
4+
5+
Removed `Config::binary_name` and `PackageInfo::package_name`
6+

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri-utils/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ dunce = "1"
4343
log = "0.4.21"
4444
cargo_metadata = { version = "0.18", optional = true }
4545

46-
[target."cfg(target_os = \"linux\")".dependencies]
47-
heck = "0.5"
48-
4946
[target."cfg(target_os = \"macos\")".dependencies]
5047
swift-rs = { version = "1.0.6", optional = true, features = [ "build" ] }
5148

core/tauri-utils/src/config.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! This is a core functionality that is not considered part of the stable API.
1111
//! If you use it, note that it may include breaking changes in the future.
1212
13-
#[cfg(target_os = "linux")]
14-
use heck::ToKebabCase;
1513
#[cfg(feature = "schema")]
1614
use schemars::JsonSchema;
1715
use semver::Version;
@@ -2115,21 +2113,6 @@ pub struct Config {
21152113
pub plugins: PluginConfig,
21162114
}
21172115

2118-
impl Config {
2119-
/// The binary name. Returns the product name as kebab-case on Linux,
2120-
/// and returns it as is on all other platforms.
2121-
pub fn binary_name(&self) -> Option<String> {
2122-
#[cfg(target_os = "linux")]
2123-
{
2124-
self.product_name.as_ref().map(|n| n.to_kebab_case())
2125-
}
2126-
#[cfg(not(target_os = "linux"))]
2127-
{
2128-
self.product_name.clone()
2129-
}
2130-
}
2131-
}
2132-
21332116
/// The plugin configs holds a HashMap mapping a plugin name to its configuration object.
21342117
///
21352118
/// See more: <https://tauri.app/v1/api/config#pluginconfig>

core/tauri-utils/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@ pub struct PackageInfo {
5757
pub crate_name: &'static str,
5858
}
5959

60-
impl PackageInfo {
61-
/// Returns the application package name.
62-
/// On macOS and Windows it's the `name` field, and on Linux it's the `name` in `kebab-case`.
63-
pub fn package_name(&self) -> String {
64-
#[cfg(target_os = "linux")]
65-
{
66-
use heck::ToKebabCase;
67-
self.name.clone().to_kebab_case()
68-
}
69-
#[cfg(not(target_os = "linux"))]
70-
self.name.clone()
71-
}
72-
}
73-
7460
#[allow(deprecated)]
7561
mod window_effects {
7662
use super::*;

core/tauri-utils/src/platform.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,21 @@ fn resource_dir_from<P: AsRef<Path>>(
292292
res = if curr_dir.ends_with("/data/usr/bin") {
293293
// running from the deb bundle dir
294294
exe_dir
295-
.join(format!("../lib/{}", package_info.package_name()))
295+
.join(format!("../lib/{}", package_info.crate_name))
296296
.canonicalize()
297297
.map_err(Into::into)
298298
} else if let Some(appdir) = &env.appdir {
299299
let appdir: &std::path::Path = appdir.as_ref();
300300
Ok(PathBuf::from(format!(
301301
"{}/usr/lib/{}",
302302
appdir.display(),
303-
package_info.package_name()
303+
package_info.crate_name
304304
)))
305305
} else {
306306
// running bundle
307307
Ok(PathBuf::from(format!(
308308
"/usr/lib/{}",
309-
package_info.package_name()
309+
package_info.crate_name
310310
)))
311311
};
312312
}
@@ -357,7 +357,7 @@ mod tests {
357357
version: "1.0.0".parse().unwrap(),
358358
authors: "",
359359
description: "",
360-
crate_name: "",
360+
crate_name: "my-app",
361361
};
362362
let env = Env::default();
363363

core/tauri/src/window/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,16 +1991,7 @@ tauri::Builder::default()
19911991
.set_progress_bar(crate::runtime::ProgressBarState {
19921992
status: progress_state.status,
19931993
progress: progress_state.progress,
1994-
desktop_filename: Some(format!(
1995-
"{}.desktop",
1996-
heck::AsKebabCase(
1997-
self
1998-
.config()
1999-
.product_name
2000-
.as_deref()
2001-
.unwrap_or_else(|| self.package_info().crate_name)
2002-
)
2003-
)),
1994+
desktop_filename: Some(format!("{}.desktop", self.package_info().crate_name)),
20041995
})
20051996
.map_err(Into::into)
20061997
}

examples/api/src-tauri/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/bundler/src/bundle.rs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,38 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
6363
log::warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
6464
}
6565

66-
if settings.can_sign() {
67-
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
68-
for bin in settings.binaries() {
69-
let bin_path = settings.binary_path(bin);
70-
windows::sign::try_sign(&bin_path, &settings)?;
71-
}
72-
73-
// Sign the sidecar binaries
74-
for bin in settings.external_binaries() {
75-
let path = bin?;
76-
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
77-
if skip {
78-
continue;
66+
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
67+
if target_os == "windows" {
68+
if settings.can_sign() {
69+
for bin in settings.binaries() {
70+
let bin_path = settings.binary_path(bin);
71+
windows::sign::try_sign(&bin_path, &settings)?;
7972
}
8073

81-
#[cfg(windows)]
82-
if windows::sign::verify(&path)? {
83-
log::info!(
84-
"sidecar at \"{}\" already signed. Skipping...",
85-
path.display()
86-
);
87-
continue;
88-
}
74+
// Sign the sidecar binaries
75+
for bin in settings.external_binaries() {
76+
let path = bin?;
77+
let skip =
78+
std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
79+
if skip {
80+
continue;
81+
}
8982

90-
windows::sign::try_sign(&path, &settings)?;
83+
#[cfg(windows)]
84+
if windows::sign::verify(&path)? {
85+
log::info!(
86+
"sidecar at \"{}\" already signed. Skipping...",
87+
path.display()
88+
);
89+
continue;
90+
}
91+
92+
windows::sign::try_sign(&path, &settings)?;
93+
}
94+
} else {
95+
#[cfg(not(target_os = "windows"))]
96+
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
9197
}
92-
} else {
93-
#[cfg(not(target_os = "windows"))]
94-
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
9598
}
9699

97100
for package_type in &package_types {

0 commit comments

Comments
 (0)