diff --git a/Cargo.toml b/Cargo.toml index ab9f7842..6670ac94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,3 +43,6 @@ pam-sys = "0.5" pam = "0.7" zstd = "0.4" xdg = "2.2" + +[replace] +"zstd-sys:1.4.8" = { path = "zstd-sys" } diff --git a/zstd-sys/Cargo.toml b/zstd-sys/Cargo.toml new file mode 100644 index 00000000..03db1916 --- /dev/null +++ b/zstd-sys/Cargo.toml @@ -0,0 +1,14 @@ +[package] +edition = "2018" +name = "zstd-sys" +version = "1.4.8" +authors = [ + "Wolfgang Bumiller ", +] + +[build-dependencies] +bindgen = ">0.42.2" + +[features] +default = ["legacy"] +legacy = [] diff --git a/zstd-sys/build.rs b/zstd-sys/build.rs new file mode 100644 index 00000000..f945ccf2 --- /dev/null +++ b/zstd-sys/build.rs @@ -0,0 +1,27 @@ +extern crate bindgen; + +use std::env; +use std::path::PathBuf; + +fn main() { + // Tell cargo to tell rustc to link the system libzstd + println!("cargo:rustc-link-lib=zstd"); + + // The bindgen::Builder is the main entry point + // to bindgen, and lets you build up options for + // the resulting bindings. + let bindings = bindgen::Builder::default() + .header("wrapper.h") + .blacklist_type("max_align_t") + .use_core() + .rustified_enum(".*") + .clang_arg("-DZSTD_STATIC_LINKING_ONLY") + .generate() + .expect("Unable to generate bindings"); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} diff --git a/zstd-sys/src/lib.rs b/zstd-sys/src/lib.rs new file mode 100644 index 00000000..a38a13a8 --- /dev/null +++ b/zstd-sys/src/lib.rs @@ -0,0 +1,5 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/zstd-sys/wrapper.h b/zstd-sys/wrapper.h new file mode 100644 index 00000000..6e07bad8 --- /dev/null +++ b/zstd-sys/wrapper.h @@ -0,0 +1,2 @@ +#include +#include