Skip to content

Commit 6bd7c68

Browse files
authored
Disable bzip2-sys build script if rust backend is enabled (#125)
* Disable bzip2-sys build script if rust backend is enabled Currently if one is to enable rust backend without disabling default features, the bzip2-sys build script would build the bzip2 again, making it meaningless to enable the feature. In many cases disabling default-features is hard (breaking backwards compatibility), so it'd be better to disable the bzip2-sys bulid-script, if the rust backend is enabled' It would still pull in cc-rs and pkg-config, but at least it won't compile the bzip2 c code again.' Signed-off-by: Jiahao XU <[email protected]> * Disable bzip2-sys build script if rust backend is enabled Currently if one is to enable rust backend without disabling default features, the bzip2-sys build script would build the bzip2 again, making it meaningless to enable the feature. In many cases disabling default-features is hard (breaking backwards compatibility), so it'd be better to disable the bzip2-sys bulid-script, if the rust backend is enabled' It would still pull in cc-rs and pkg-config, but at least it won't compile the bzip2 c code again.' Signed-off-by: Jiahao XU <[email protected]> * Disable bzip2-sys build script if rust backend is enabled Currently if one is to enable rust backend without disabling default features, the bzip2-sys build script would build the bzip2 again, making it meaningless to enable the feature. In many cases disabling default-features is hard (breaking backwards compatibility), so it'd be better to disable the bzip2-sys bulid-script, if the rust backend is enabled' It would still pull in cc-rs and pkg-config, but at least it won't compile the bzip2 c code again.' Signed-off-by: Jiahao XU <[email protected]> --------- Signed-off-by: Jiahao XU <[email protected]>
1 parent af06fd1 commit 6bd7c68

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ publish = true
2222
bzip2-sys = { version = "0.1.11", path = "bzip2-sys", optional = true }
2323

2424
[dependencies.libbz2-rs-sys]
25-
version = "0.1.1"
25+
version = "0.1.3"
2626
# Don't enable the stdio feature for better portability.
2727
default-features = false
28-
features = ["rust-allocator"]
28+
features = ["rust-allocator", "semver-prefix"]
2929
optional = true
3030

3131
[dev-dependencies]
@@ -37,7 +37,7 @@ quickcheck = "1.0"
3737
default = ["dep:bzip2-sys"]
3838
# Use the pure rust `libbz2-rs-sys` instead of the C FFI bindings of `bzip2-sys`
3939
# The rust bzip2 implementation is always statically linked.
40-
libbz2-rs-sys = ["dep:libbz2-rs-sys"]
40+
libbz2-rs-sys = ["dep:libbz2-rs-sys", "bzip2-sys?/__disabled"]
4141
# Always build `libbz2` from C source, and statically link it.
4242
# This flag is only meaningful when `bzip2-sys` is used,
4343
# and has no effect when `libbz2-rs-sys` is used as the bzip2 implementation.

bzip2-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ cc = "1.0"
2828
[features]
2929
# Enable this feature if you want to have a statically linked bzip2
3030
static = []
31+
__disabled = []

bzip2-sys/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ use std::path::PathBuf;
55
use std::{env, fs};
66

77
fn main() {
8+
// skip building the C library when libbzip2-rs is also used
9+
if cfg!(feature = "__disabled") {
10+
return;
11+
}
12+
813
let mut cfg = cc::Build::new();
914
let target = env::var("TARGET").unwrap();
1015
cfg.warnings(false);

0 commit comments

Comments
 (0)