Drop "buildtime-bindgen" feature flag, building without it almost never works in practice.
MODIFY
Cargo.toml
Cargo.toml
@@ -55,8 +55,7 @@ num-traits = "0.2"
once_cell = "1.0"
[features]
-default = ["opencv-4", "buildtime-bindgen"]
-buildtime-bindgen = ["binding-generator", "clang", "jobserver"]
+default = ["opencv-4"]
clang-runtime = ["clang/runtime"]
opencv-32 = []
opencv-34 = []
@@ -64,12 +63,12 @@ opencv-4 = []
docs-only = []
[build-dependencies]
-binding-generator = { package = "opencv-binding-generator", version = "0.26.0", path = "binding-generator", optional = true }
+binding-generator = { package = "opencv-binding-generator", version = "0.26.0", path = "binding-generator" }
cc = { version = "1.0", features = ["parallel"] }
-clang = { version = "1.0", features = ["clang_6_0"], optional = true }
+clang = { version = "1.0", features = ["clang_6_0"] }
dunce = "1.0"
glob = "0.3"
-jobserver = { version = "0.1", optional = true }
+jobserver = "0.1"
once_cell = "1.0"
pkg-config = "0.3"
semver = "0.11"

MODIFY
README.md
README.md
@@ -10,7 +10,8 @@ The API is usable, but unstable and not very battle-tested; use at your own risk
## Quickstart
-Make sure the supported OpenCV version (3.2, 3.4 or 4.x) is installed in your system.
+Make sure the supported OpenCV version (3.2, 3.4 or 4.x) and Clang (part of LLVM, needed for automatic binding
+generation) are installed in your system.
Update your Cargo.toml
```toml
@@ -19,7 +20,7 @@ opencv = "0.52"
Select OpenCV version if different from default (opencv-4) in Cargo.toml:
```toml
-opencv = {version = "0.52", default-features = false, features = ["opencv-34", "buildtime-bindgen"]}
+opencv = {version = "0.52", default-features = false, features = ["opencv-34"]}
```
Import prelude
@@ -92,9 +93,8 @@ You need to set up the following environment variables to point to the installed
1. One of the common problems is link errors in the end of the build.
- Make sure you're building with `buildtime-bindgen` feature enabled (requires installed clang/llvm), it will
- recreate rust and cpp files to match the version you have installed. Please be sure to also set up the
- relevant environment variables that will allow the linker to find the libraries it needs (see below).
+ Be sure to set up the relevant environment variables that will allow the linker to find the libraries it
+ needs (see below).
2. You're getting runtime errors like:
```
@@ -276,12 +276,8 @@ The following variables affect the building the of the `opencv` crate, but belon
source
* `opencv-34` - build against OpenCV 3.4.x
* `opencv-4` (default) - build against OpenCV 4.x
-* `buildtime-bindgen` (default) - regenerate all bindings, requires installed clang/llvm (minimum supported
- version is 6.0), with this feature enabled the bundled headers are no longer used for the code generation,
- the ones from the installed OpenCV are used instead
-* `clang-runtime` - only useful with the combination with `buildtime-bindgen`, enables the runtime detection
- of libclang (`runtime` feature of `clang-sys`). Useful as a workaround for when your dependencies (like
- `bindgen`) pull in `clang-sys` with hard `runtime` feature.
+* `clang-runtime` - enables the runtime detection of libclang (`runtime` feature of `clang-sys`). Useful as a
+ workaround for when your dependencies (like `bindgen`) pull in `clang-sys` with hard `runtime` feature.
* `docs-only` - internal usage, for building docs on [docs.rs](https://docs.rs/opencv)
## API details
@@ -386,9 +382,8 @@ version because the crate has gone through the considerable rewrite since.
## Contributor's Guide
The binding generator code lives in a separate crate under [binding-generator](binding-generator). During the
-build phase (with `buildtime-bindgen` feature enabled) it creates bindings from the header files and puts them
-into [bindings](bindings) directory. Those are then transferred to [src](src) for the consumption by the
-crate users.
+build phase it creates bindings from the header files and puts them into [bindings](bindings) directory. Those
+are then transferred to [src](src) for the consumption by the crate users.
The crate itself, as imported by users, consists of generated rust code in [src](src) committed to the repo.
This way, users don't have to handle the code generation overhead in their builds. When developing this crate,

MODIFY
build.rs
build.rs
@@ -18,7 +18,6 @@ use semver::{Version, VersionReq};
#[path = "build_cmake_probe.rs"]
mod cmake_probe;
-#[cfg(feature = "buildtime-bindgen")]
#[path = "build_generator.rs"]
mod generator;
@@ -785,7 +784,6 @@ fn main() -> Result<()> {
panic!("Please select exactly one of the features: opencv-32, opencv-34, opencv-4");
}
- #[cfg(feature = "buildtime-bindgen")]
let generator_build = if cfg!(feature = "clang-runtime") { // start building binding generator as early as possible
let cargo_bin = PathBuf::from(env::var_os("CARGO").unwrap_or_else(|| "cargo".into()));
let mut cargo = Command::new(cargo_bin);
@@ -847,13 +845,9 @@ fn main() -> Result<()> {
.map_err(|e| format!("{}, (version coming from the detected package/environment)", e))?;
}
let opencv_header_dir = env::var_os("OPENCV_HEADER_DIR").map(PathBuf::from).unwrap_or_else(|| {
- if cfg!(feature = "buildtime-bindgen") {
opencv.include_paths.iter()
.find(|p| p.join("opencv2/core/version.hpp").is_file() || p.join("Headers/core/version.hpp").is_file())
- .expect("Using buildtime-bindgen, but discovered OpenCV include paths is empty or contains non-existent paths").clone()
- } else {
- opencv_header_dir
- }
+ .expect("Discovered OpenCV include paths is empty or contains non-existent paths").clone()
});
make_modules(&opencv_header_dir.join("opencv2"))?;
@@ -867,7 +861,6 @@ fn main() -> Result<()> {
setup_rerun()?;
- #[cfg(feature = "buildtime-bindgen")]
generator::gen_wrapper(&opencv_header_dir, generator_build)?;
install_wrapper()?;
build_wrapper(&opencv);

MODIFY
ci/script.sh
ci/script.sh
@@ -51,7 +51,6 @@ rustc --print=cfg
cargo test -vv -p opencv-binding-generator
-CARGO_FEATURES="$CARGO_FEATURES,buildtime-bindgen"
cargo test -vv --no-default-features --features "$CARGO_FEATURES"
cargo test --release -vv --no-default-features --features "$CARGO_FEATURES"

MODIFY
ci/test-proj-clang-runtime/Cargo.toml
ci/test-proj-clang-runtime/Cargo.toml
@@ -11,7 +11,6 @@ opencv = { path = "../..", default-features = false, features = ["clang-runtime"
[workspace]
[features]
-buildtime-bindgen = ["opencv/buildtime-bindgen"]
opencv-32 = ["opencv/opencv-32"]
opencv-34 = ["opencv/opencv-34"]
opencv-4 = ["opencv/opencv-4"]

Drop "buildtime-bindgen" feature flag, building without it almost never works in practice.