Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/bundler-show-sizes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-bundler": "minor:feat"
Comment thread
Legend-Master marked this conversation as resolved.
Resolved
"tauri-cli": "minor:feat"
"@tauri-apps/cli": "minor:feat"
---

The bundler now prints the size of each generated bundle next to its path in the `Finished N bundles at:` output (directories such as macOS `.app` bundles are measured recursively).
11 changes: 9 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/tauri-bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ serde = { version = "1", features = ["derive"] }
strsim = "0.11"
tar = "0.4"
walkdir = "2"
bytesize = "2"
handlebars = "6"
tempfile = "3"
log = { version = "0.4.21", features = ["kv"] }
Expand Down
20 changes: 19 additions & 1 deletion crates/tauri-bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod windows;

use crate::error::ErrorExt;
use anyhow::Context;
use bytesize::ByteSize;
use std::{
fmt::Write,
io::{Seek, SeekFrom},
Expand Down Expand Up @@ -290,7 +291,10 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> {
""
};
let path_display = display_path(path);
writeln!(printable_paths, " {path_display}{note}").unwrap();
let size = bundle_size(path)
.map(|bytes| format!(" ({:.2})", ByteSize::b(bytes).display()))
.unwrap_or_default();
writeln!(printable_paths, " {path_display}{note}{size}").unwrap();
}
}

Expand All @@ -299,6 +303,20 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> {
Ok(bundles)
}

/// Total size in bytes of a bundle path, recursing into directories (e.g. macOS `.app`).
fn bundle_size(path: &std::path::Path) -> crate::Result<u64> {
let metadata = std::fs::symlink_metadata(path)?;
if metadata.is_dir() {
let mut total = 0;
for entry in walkdir::WalkDir::new(path) {
total += entry?.metadata()?.len();
}
Ok(total)
} else {
Ok(metadata.len())
}
}

fn sign_binaries_if_needed(settings: &Settings, target_os: &TargetPlatform) -> crate::Result<()> {
if matches!(target_os, TargetPlatform::Windows) {
if settings.windows().can_sign() {
Expand Down
Loading