cargo: patch zstd-sys to use system library

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-03-07 11:50:32 +01:00
parent cd3b9a068f
commit d04c67b8a9
5 changed files with 51 additions and 0 deletions

View File

@ -43,3 +43,6 @@ pam-sys = "0.5"
pam = "0.7" pam = "0.7"
zstd = "0.4" zstd = "0.4"
xdg = "2.2" xdg = "2.2"
[replace]
"zstd-sys:1.4.8" = { path = "zstd-sys" }

14
zstd-sys/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
edition = "2018"
name = "zstd-sys"
version = "1.4.8"
authors = [
"Wolfgang Bumiller <w.bumiller@proxmox.com>",
]
[build-dependencies]
bindgen = ">0.42.2"
[features]
default = ["legacy"]
legacy = []

27
zstd-sys/build.rs Normal file
View File

@ -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!");
}

5
zstd-sys/src/lib.rs Normal file
View File

@ -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"));

2
zstd-sys/wrapper.h Normal file
View File

@ -0,0 +1,2 @@
#include <zstd.h>
#include <zdict.h>