Skip to content

Commit

Permalink
Put bindgen behind a seperate feature (#191)
Browse files Browse the repository at this point in the history
This commit changes proj-sys to not depend on bindgen by default as that
introduces a quite heavy build time dependency (libclang) which might
not be there on all systems. Instead bundled bindings for the proj
version build by the `bundled_proj` feature are provided.
  • Loading branch information
weiznich authored Jul 1, 2024
1 parent 86b2124 commit 46d46f2
Show file tree
Hide file tree
Showing 6 changed files with 4,933 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
- Update to proj-sys 0.24.0 (libproj 9.4.0)
- Provide bundled bindings by default and move support for build time generated bindings behind the `buildtime_bindgen` feature of proj-sys
- Bump MSRV to 1.65

## 0.27.2
Expand Down
10 changes: 10 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Development related notices


Bindings were generated with the following command:

```sh
bindgen --distrust-clang-mangling --blocklist-type max_align_t wrapper.h -- -I PROJSRC/proj-9.4.0/src
```

If you update the above command line you also need to update the arguments for the buildtime_bindgen feature in `build.rs`
3 changes: 2 additions & 1 deletion proj-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ libsqlite3-sys = "0.28"
link-cplusplus = "1.0"

[build-dependencies]
bindgen = "0.69.0"
bindgen = { version = "0.69", optional = true }
pkg-config = "0.3.25"
cmake = "0.1.50"
flate2 = "1.0.24"
Expand All @@ -29,6 +29,7 @@ bundled_proj = []
pkg_config = []
network = ["tiff"]
tiff = []
buildtime_bindgen = ["dep:bindgen"]

[package.metadata.docs.rs]
features = [ "nobuild" ] # This feature will be enabled during the docs.rs build
13 changes: 13 additions & 0 deletions proj-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
})?
};

#[cfg(feature = "buildtime_bindgen")]
generate_bindings(include_path)?;
#[cfg(not(feature = "buildtime_bindgen"))]
let _ = include_path;

Ok(())
}

#[cfg(feature = "buildtime_bindgen")]
fn generate_bindings(include_path: std::path::PathBuf) -> Result<(), Box<dyn std::error::Error>> {
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
// If you update the configuration here you also
// need to update the corresponding bindgen command in
// `DEVELOPMENT.md`
let bindings = bindgen::Builder::default()
.clang_arg(format!("-I{}", include_path.to_string_lossy()))
.trust_clang_mangling(false)
Expand Down
Loading

0 comments on commit 46d46f2

Please sign in to comment.