Skip to content

Commit

Permalink
revert bin src_path
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 15, 2024
1 parent d733855 commit 5fff88e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
28 changes: 27 additions & 1 deletion crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,26 @@ pub struct BundleSettings {
pub struct BundleBinary {
name: String,
main: bool,
src_path: Option<String>,
}

impl BundleBinary {
/// Creates a new bundle binary.
pub fn new(name: String, main: bool) -> Self {
Self { name, main }
Self {
name,
main,
src_path: None,
}
}

/// Creates a new bundle binary with path.
pub fn with_path(name: String, main: bool, src_path: Option<String>) -> Self {
Self {
name,
src_path,
main,
}
}

/// Mark the binary as the main executable.
Expand All @@ -637,6 +651,13 @@ impl BundleBinary {
self.name = name;
}

/// Sets the src path of the binary.
#[must_use]
pub fn set_src_path(mut self, src_path: Option<String>) -> Self {
self.src_path = src_path;
self
}

/// Returns the binary `main` flag.
pub fn main(&self) -> bool {
self.main
Expand All @@ -646,6 +667,11 @@ impl BundleBinary {
pub fn name(&self) -> &str {
&self.name
}

/// Returns the binary source path.
pub fn src_path(&self) -> Option<&String> {
self.src_path.as_ref()
}
}

/// The Settings exposed by the module.
Expand Down
8 changes: 6 additions & 2 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ struct WorkspacePackageSettings {
#[derive(Clone, Debug, Deserialize)]
struct BinarySettings {
name: String,
path: Option<String>,
}

/// The package settings.
Expand Down Expand Up @@ -901,7 +902,7 @@ impl AppSettings for RustAppSettings {
for bin in bins {
let name = format!("{}{}", bin.name, ext);
let is_main = bin.name == self.cargo_package_settings.name || bin.name == default_run;
binaries.push(BundleBinary::new(name, is_main))
binaries.push(BundleBinary::with_path(name, is_main, bin.path.clone()))
}
}

Expand All @@ -911,7 +912,10 @@ impl AppSettings for RustAppSettings {
for entry in fs_bins {
let path = entry?.path();
if let Some(name) = path.file_stem() {
if !binaries.iter().any(|bin| bin.name() == name) {
let bin_exists = binaries.iter().any(|bin| {
bin.name() == name || path.ends_with(bin.src_path().unwrap_or(&"".to_string()))
});
if !bin_exists {
binaries.push(BundleBinary::new(
format!("{}{}", name.to_string_lossy(), ext),
false,
Expand Down

0 comments on commit 5fff88e

Please sign in to comment.