Skip to content

Commit 1c7a58c

Browse files
committed
Check in platform-independent bindings
Automatically generating bindings as part of the build process caused some user complaints, since installing clang/libclang can be a hassle. The rdkafka bindings are not particularly platform-dependent, and with a bit of work we can generate bindings that depend on platform-dependent types, like libc::FILE, so that we only need to run bindgen once. Fix #126.
1 parent 0b4e653 commit 1c7a58c

File tree

8 files changed

+2160
-33
lines changed

8 files changed

+2160
-33
lines changed

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ FROM ubuntu:16.04
22

33
RUN apt-get update && apt-get install -y build-essential \
44
curl \
5-
llvm-3.9-dev libclang-3.9-dev clang-3.9 \
65
openssl libssl-dev \
76
pkg-config \
87
python \

rdkafka-sys/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ keywords = ["kafka", "rdkafka"]
1111
categories = ["external-ffi-bindings"]
1212

1313
[dependencies]
14+
libc = "0.2.65"
1415
libz-sys = "1.0"
1516
zstd-sys = { version = "1.3", features = [], optional = true }
1617
openssl-sys = { version = "~ 0.9.0", optional = true }
1718
lz4-sys = { version = "1.8.3", optional = true }
1819

1920
[build-dependencies]
20-
bindgen = "0.51.1"
2121
num_cpus = "0.2.0"
2222
pkg-config = "0.3.9"
2323
cmake = { version = "^0.1", optional = true }

rdkafka-sys/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ To regenerate the bindings:
88

99
``` bash
1010
git submodule update --init
11-
cargo install bindgen --vers 0.30.0
12-
bindgen --builtins --no-doc-comments librdkafka/src/rdkafka.h -o src/bindings/{platform}.rs
11+
cargo install bindgen
12+
./update-bindings.sh
1313
```
1414

1515
## Version

rdkafka-sys/build.rs

-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ extern crate num_cpus;
44
extern crate pkg_config;
55

66
use std::env;
7-
use std::io::Write;
87
use std::path::{Path, PathBuf};
98
use std::process::{self, Command};
109

@@ -77,29 +76,6 @@ fn main() {
7776
eprintln!("Building and linking librdkafka statically");
7877
build_librdkafka();
7978
}
80-
81-
let bindings = bindgen::Builder::default()
82-
.header("librdkafka/src/rdkafka.h")
83-
.generate_comments(false)
84-
.emit_builtins()
85-
// TODO: using rustified_enum is somewhat dangerous, especially when
86-
// also using shared libraries.
87-
// For details: https://github.com/rust-lang/rust-bindgen/issues/758
88-
.rustified_enum("rd_kafka_vtype_t")
89-
.rustified_enum("rd_kafka_type_t")
90-
.rustified_enum("rd_kafka_conf_res_t")
91-
.rustified_enum("rd_kafka_resp_err_t")
92-
.rustified_enum("rd_kafka_timestamp_type_t")
93-
.rustified_enum("rd_kafka_admin_op_t")
94-
.rustified_enum("rd_kafka_ResourceType_t")
95-
.rustified_enum("rd_kafka_ConfigSource_t")
96-
.generate()
97-
.expect("failed to generate bindings");
98-
99-
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
100-
bindings
101-
.write_to_file(out_path.join("bindings.rs"))
102-
.expect("failed to write bindings");
10379
}
10480

10581
#[cfg(not(feature = "cmake_build"))]

0 commit comments

Comments
 (0)