Skip to content

Commit

Permalink
fix --strip arg
Browse files Browse the repository at this point in the history
  • Loading branch information
fredszaq authored and kali committed Jul 6, 2022
1 parent d7d76be commit 31aafd4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cargo-dinghy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn run_command(cli: DinghyCli) -> Result<()> {
let envs_ref = cli.args.env.iter().map(|s| &s[..]).collect::<Vec<_>>();
platform.setup_env(&project, &setup_args)?;

let build = Build {
let mut build = Build {
setup_args,
// TODO these should be probably read from the executable file
dynamic_libraries: vec![],
Expand All @@ -129,7 +129,7 @@ fn run_command(cli: DinghyCli) -> Result<()> {

// TODO make the run of the app use the stripped binary
if cli.args.strip {
platform.strip(&build)?;
platform.strip(&mut build)?;
}

let bundle = device.run_app(
Expand Down
4 changes: 2 additions & 2 deletions dinghy-lib/src/host/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ impl Platform for HostPlatform {
std::env!("TARGET")
}

fn strip(&self, build: &Build) -> Result<()> {
fn strip(&self, build: &mut Build) -> Result<()> {
log::info!("Stripping {}", build.runnable.exe.display());
platform::strip_runnable(&build.runnable, Command::new("strip"))?;
build.runnable = platform::strip_runnable(&build.runnable, Command::new("strip"))?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions dinghy-lib/src/ios/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ impl Platform for IosPlatform {
&self.toolchain.rustc_triple
}

fn strip(&self, build: &Build) -> Result<()> {
fn strip(&self, build: &mut Build) -> Result<()> {
let mut command = ::std::process::Command::new("xcrun");
command.arg("strip");
crate::platform::strip_runnable(&build.runnable, command)?;
build.runnable = crate::platform::strip_runnable(&build.runnable, command)?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion dinghy-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub trait Platform: std::fmt::Debug {
fn is_host(&self) -> bool;
fn rustc_triple(&self) -> &str;

fn strip(&self, build: &Build) -> Result<()>;
fn strip(&self, build: &mut Build) -> Result<()>;
fn sysroot(&self) -> Result<Option<path::PathBuf>>;
}

Expand Down
4 changes: 2 additions & 2 deletions dinghy-lib/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use log::debug;

pub mod regular_platform;

pub fn strip_runnable(runnable: &Runnable, mut command: Command) -> Result<()> {
pub fn strip_runnable(runnable: &Runnable, mut command: Command) -> Result<Runnable> {
let exe_stripped_name = file_name_as_str(&runnable.exe)?;

let mut stripped_runnable = runnable.clone();
Expand Down Expand Up @@ -40,5 +40,5 @@ pub fn strip_runnable(runnable: &Runnable, mut command: Command) -> Result<()> {
fs::metadata(&runnable.exe)?.len(),
fs::metadata(&stripped_runnable.exe)?.len()
);
Ok(())
Ok(stripped_runnable)
}
4 changes: 2 additions & 2 deletions dinghy-lib/src/platform/regular_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ impl Platform for RegularPlatform {
&self.toolchain.rustc_triple
}

fn strip(&self, build: &Build) -> Result<()> {
platform::strip_runnable(
fn strip(&self, build: &mut Build) -> Result<()> {
build.runnable = platform::strip_runnable(
&build.runnable,
Command::new(self.toolchain.binutils_executable("strip")),
)?;
Expand Down

0 comments on commit 31aafd4

Please sign in to comment.