Skip to content

Commit

Permalink
Merge pull request #7 from ijl/strip
Browse files Browse the repository at this point in the history
--strip
  • Loading branch information
konstin authored Sep 26, 2018
2 parents da09811 + f9e9ae3 commit bade5e1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ FLAGS:
-h, --help Prints help information
--release Pass --release to cargo
--skip-auditwheel Don't check for manylinux compliance
--strip Strip the library for minimum file size
-V, --version Prints version information
OPTIONS:
Expand Down Expand Up @@ -116,6 +117,7 @@ FLAGS:
-h, --help Prints help information
--release Pass --release to cargo
--skip-auditwheel Don't check for manylinux compliance
--strip Strip the library for minimum file size
-V, --version Prints version information
OPTIONS:
Expand Down Expand Up @@ -154,6 +156,7 @@ USAGE:
FLAGS:
-h, --help Prints help information
--release Pass --release to cargo
--strip Strip the library for minimum file size
-V, --version Prints version information
OPTIONS:
Expand Down
2 changes: 2 additions & 0 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub struct BuildContext {
pub out: PathBuf,
/// Pass --release to cargo
pub release: bool,
/// Strip the library for minimum file size
pub strip: bool,
/// Don't check for manylinux compliance
pub skip_auditwheel: bool,
/// Extra arguments that will be passed to cargo as `cargo rustc [...] [arg1] [arg2] --`
Expand Down
5 changes: 5 additions & 0 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub struct BuildOptions {
/// Pass --release to cargo
#[structopt(long = "release")]
pub release: bool,
/// Strip the library for minimum file size
#[structopt(long = "strip")]
pub strip: bool,
/// Don't check for manylinux compliance
#[structopt(long = "skip-auditwheel")]
pub skip_auditwheel: bool,
Expand All @@ -64,6 +67,7 @@ impl Default for BuildOptions {
manifest_path: PathBuf::from("Cargo.toml"),
out: None,
release: false,
strip: false,
skip_auditwheel: false,
target: None,
cargo_extra_args: Vec::new(),
Expand Down Expand Up @@ -150,6 +154,7 @@ impl BuildOptions {
manifest_path: self.manifest_path,
out: wheel_dir,
release: self.release,
strip: self.strip,
skip_auditwheel: self.skip_auditwheel,
cargo_extra_args,
rustc_extra_args: self.rustc_extra_args,
Expand Down
4 changes: 4 additions & 0 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ pub fn compile(
}
}

if context.strip {
rustc_args.extend(&["-C", "link-arg=-s"]);
}

let build_args: Vec<_> = cargo_args
.iter()
.chain(&shared_args)
Expand Down
2 changes: 2 additions & 0 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn develop(
rustc_extra_args: Vec<String>,
venv_dir: &Path,
release: bool,
strip: bool,
) -> Result<(), Error> {
let target = Target::current();

Expand All @@ -37,6 +38,7 @@ pub fn develop(
skip_auditwheel: true,
target: None,
release,
strip,
cargo_extra_args,
rustc_extra_args,
};
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ enum Opt {
/// Pass --release to cargo
#[structopt(long = "release")]
release: bool,
/// Strip the library for minimum file size
#[structopt(long = "strip")]
strip: bool,
/// Extra arguments that will be passed to cargo as `cargo rustc [...] [arg1] [arg2] --`
#[structopt(long = "cargo-extra-args")]
cargo_extra_args: Vec<String>,
Expand Down Expand Up @@ -264,6 +267,7 @@ fn run() -> Result<(), Error> {
cargo_extra_args,
rustc_extra_args,
release,
strip,
} => {
let venv_dir = match env::var_os("VIRTUAL_ENV") {
Some(dir) => PathBuf::from(dir),
Expand All @@ -279,6 +283,7 @@ fn run() -> Result<(), Error> {
rustc_extra_args,
&venv_dir,
release,
strip,
)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn test_develop(package: &Path, bindings: Option<String>) {
}

let manifest_file = package.join("Cargo.toml");
develop(bindings, &manifest_file, vec![], vec![], &venv_dir, false).unwrap();
develop(bindings, &manifest_file, vec![], vec![], &venv_dir, false, false).unwrap();

check_installed(&package, &python).unwrap();
}

0 comments on commit bade5e1

Please sign in to comment.