Skip to content

Commit

Permalink
Add zstd_errors.h to bindgen generator when using experimental feature (
Browse files Browse the repository at this point in the history
#224)

* Add zstd_errors.h to bindgen generator when using experimental feature

* Refactor to use ifdef instead of separate header
  • Loading branch information
DoumanAsh authored Jul 21, 2023
1 parent 5872d29 commit 042f231
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions zstd-safe/zstd-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ fn generate_bindings(defs: Vec<&str>, headerpaths: Vec<PathBuf>) {
let bindings = bindgen::Builder::default().header("zstd.h");
#[cfg(feature = "zdict_builder")]
let bindings = bindings.header("zdict.h");
#[cfg(feature = "experimental")]
let bindings = bindings.clang_arg("-DZSTD_RUST_BINDINGS_EXPERIMENTAL");
let bindings = bindings
.blocklist_type("max_align_t")
.size_t_is_usize(true)
Expand Down
7 changes: 6 additions & 1 deletion zstd-safe/zstd-sys/zstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

/* Just use installed headers */
#include <zstd.h>
// Don't use experimental features like zstdmt
#ifdef ZSTD_RUST_BINDINGS_EXPERIMENTAL
#include <zstd_errors.h>
#endif

#else // #ifdef PKG_CONFIG

#include "zstd/lib/zstd.h"
#ifdef ZSTD_RUST_BINDINGS_EXPERIMENTAL
#include "zstd/lib/zstd_errors.h"
#endif

#endif // #ifdef PKG_CONFIG

Expand Down

0 comments on commit 042f231

Please sign in to comment.