refactor: drop strip from build command. closes #3559 (#3863)

This commit is contained in:
Jonas Kruckenberg 2022-04-06 14:45:55 +02:00 committed by GitHub
parent 2c1c5ab13f
commit 621062246d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 36 deletions

View File

@ -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

View File

@ -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));
@ -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(())
}