Skip to content

Commit 339ce96

Browse files
committed
Make sys package build more robust
Remove `lib` from name to follow conventions and add sys packages for libz and lz4 to make sure they link properly.
1 parent 42c2cba commit 339ce96

20 files changed

+46
-288
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
target
22
src/*.bk
3+
*.lock

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "librdkafka-sys/librdkafka"]
2-
path = librdkafka-sys/librdkafka
1+
[submodule "librdkafka"]
2+
path = rdkafka-sys/librdkafka
33
url = https://github.com/edenhill/librdkafka.git

Cargo.lock

Lines changed: 0 additions & 219 deletions
This file was deleted.

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Rust wrapper for librdkafka"
99
keywords = ["kafka", "rdkafka"]
1010

1111
[dependencies]
12-
librdkafka-sys = { path = "librdkafka-sys", version = "0.9.2-0" }
12+
rdkafka-sys = { path = "rdkafka-sys", version = "0.9.2-0" }
1313
clap = "2.18.0"
1414
env_logger = "^0.3.0"
1515
errno = "^0.1.8"
@@ -18,8 +18,7 @@ libc = "^0.2.0"
1818
log = "^0.3.0"
1919

2020
[features]
21-
default = ["zlib"]
21+
default = []
2222

23-
zlib = ["librdkafka-sys/zlib"]
24-
ssl = ["librdkafka-sys/ssl"]
25-
sasl = ["librdkafka-sys/sasl", "ssl"]
23+
ssl = ["rdkafka-sys/ssl"]
24+
sasl = ["rdkafka-sys/sasl", "ssl"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ executable. To compile librdkafka you'll need:
4242
* the GNU toolchain
4343
* GNU `make`
4444
* `pthreads`
45-
* `zlib`: optional, included by default (feature: `zlib`).
45+
* `zlib`
4646
* `libssl-dev`: optional, *not* included by default (feature: `ssl`).
4747
* `libsasl2-dev`: optional, *not* included by default (feature: `sasl`).
4848

librdkafka-sys/Cargo.lock

Lines changed: 0 additions & 23 deletions
This file was deleted.

librdkafka-sys/librdkafka

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "librdkafka-sys"
2+
name = "rdkafka-sys"
33
version = "0.9.2-0"
44
authors = ["Federico Giraud <[email protected]>"]
55
build = "build.rs"
@@ -10,17 +10,19 @@ description = "Native bindings to the librdkafka library"
1010
keywords = ["kafka", "rdkafka"]
1111

1212
[dependencies]
13+
lz4-sys = { git = "https://github.com/thijsc/lz4-rs.git" }
14+
libz-sys = ">= 1.0.7"
15+
openssl-sys = "> 0.7.0"
1316

1417
[build-dependencies]
15-
num_cpus = "0.2"
18+
num_cpus = "~ 0.2.0"
1619

1720
[lib]
18-
name = "librdkafka_sys"
21+
name = "rdkafka_sys"
1922
path = "src/lib.rs"
2023

2124
[features]
22-
default = ["zlib"]
25+
default = []
2326

24-
zlib = []
2527
ssl = []
2628
sasl = ["ssl"]
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate num_cpus;
22

3-
// use std::path::Path;
3+
use std::path::Path;
44
use std::process::Command;
55
use std::io::Write;
66
use std::env;
@@ -24,25 +24,27 @@ fn run_command_or_fail(dir: &str, cmd: &str, args: &[&str]) {
2424
}
2525

2626
fn main() {
27-
// if !Path::new("librdkafka/.git").exists() {
28-
// println!("Setting up submodules");
29-
// run_command_or_fail(".", "git", &["submodule", "update", "--init"]);
30-
// }
31-
32-
let feature_sasl = env::var("CARGO_FEATURE_SASL").is_ok();
33-
let feature_ssl = env::var("CARGO_FEATURE_SSL").is_ok();
34-
let feature_zlib = env::var("CARGO_FEATURE_ZLIB").is_ok();
27+
if !Path::new("librdkafka/LICENCE").exists() {
28+
println!("Setting up submodules");
29+
run_command_or_fail("../", "git", &["submodule", "update", "--init"]);
30+
}
3531

3632
let mut configure_flags = Vec::new();
3733

38-
if !feature_sasl {
34+
if env::var("CARGO_FEATURE_SASL").is_ok() {
35+
configure_flags.push("--enable-sasl");
36+
} else {
3937
configure_flags.push("--disable-sasl");
4038
}
4139

42-
if !feature_ssl {
40+
if env::var("CARGO_FEATURE_SSL").is_ok() {
41+
configure_flags.push("--enable-ssl");
42+
} else {
4343
configure_flags.push("--disable-ssl");
4444
}
4545

46+
configure_flags.push("--enable-static");
47+
4648
println!("Configuring librdkafka");
4749
run_command_or_fail("librdkafka", "./configure", configure_flags.as_slice());
4850

@@ -51,17 +53,4 @@ fn main() {
5153

5254
println!("cargo:rustc-link-search=native={}/librdkafka/src", env::current_dir().expect("Can't find current dir").display());
5355
println!("cargo:rustc-link-lib=static=rdkafka");
54-
55-
if feature_ssl {
56-
println!("cargo:rustc-link-lib=dylib=crypto");
57-
println!("cargo:rustc-link-lib=dylib=ssl");
58-
}
59-
60-
if feature_zlib {
61-
println!("cargo:rustc-link-lib=dylib=z");
62-
}
63-
64-
// println!("cargo:rustc-link-search=/usr/local/opt/openssl/lib");
65-
// println!("cargo:libdir=/usr/local/opt/openssl/lib");
66-
// println!("cargo:include=/usr/local/opt/openssl/include");
6756
}

rdkafka-sys/librdkafka

Submodule librdkafka added at c5f4b53
File renamed without changes.

rdkafka-sys/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[cfg(feature = "ssl")]
2+
extern crate openssl_sys;
3+
4+
extern crate lz4_sys;
5+
extern crate libz_sys;
6+
7+
pub mod bindings;
8+
9+
pub use bindings::*;

0 commit comments

Comments
 (0)