Skip to content

Commit

Permalink
refactor: drop strip from build command. closes #3559 (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg authored Apr 6, 2022
1 parent 2c1c5ab commit 6210622
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
7 changes: 7 additions & 0 deletions .changes/cli-drop-strip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"cli.rs": patch
---

The CLI will not automatically run `strip` on release binaries anymore. Use the [`strip`] profile setting stabilized with Cargo 1.59.

[`strip`]: https://doc.rust-lang.org/cargo/reference/profiles.html#strip
36 changes: 0 additions & 36 deletions tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ pub fn command(options: Options) -> Result<()> {
crate::interface::rust::build_project(runner, args).with_context(|| "failed to build app")?;
}

#[cfg(unix)]
if !options.debug {
strip(&bin_path, &logger)?;
}

if let Some(product_name) = config_.package.product_name.clone() {
#[cfg(windows)]
let product_path = out_dir.join(format!("{}.exe", product_name));
Expand Down Expand Up @@ -364,34 +359,3 @@ fn print_signed_updater_archive(output_paths: &[PathBuf]) -> crate::Result<()> {
}
Ok(())
}

// TODO: drop this when https://github.com/rust-lang/rust/issues/72110 is stabilized
#[cfg(unix)]
fn strip(path: &std::path::Path, logger: &Logger) -> crate::Result<()> {
use humansize::{file_size_opts, FileSize};

let filesize_before = std::fs::metadata(&path)
.with_context(|| "failed to get executable file size")?
.len();

// Strip the binary
Command::new("strip")
.arg(&path)
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.with_context(|| "failed to execute strip")?;

let filesize_after = std::fs::metadata(&path)
.with_context(|| "failed to get executable file size")?
.len();

logger.log(format!(
"Binary stripped, size reduced by {}",
(filesize_before - filesize_after)
.file_size(file_size_opts::CONVENTIONAL)
.unwrap(),
));

Ok(())
}

0 comments on commit 6210622

Please sign in to comment.