Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put bindgen behind a seperate feature #191

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading