]> git.proxmox.com Git - proxmox-backup.git/commitdiff
cargo: patch zstd-sys to use system library
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 7 Mar 2019 10:50:32 +0000 (11:50 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 7 Mar 2019 11:18:38 +0000 (12:18 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cargo.toml
zstd-sys/Cargo.toml [new file with mode: 0644]
zstd-sys/build.rs [new file with mode: 0644]
zstd-sys/src/lib.rs [new file with mode: 0644]
zstd-sys/wrapper.h [new file with mode: 0644]

index ab9f7842335032d066fc67bb41f8d6277a701989..6670ac945306f03bfc924084584be488bec150e1 100644 (file)
@@ -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 (file)
index 0000000..03db191
--- /dev/null
@@ -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 = []
diff --git a/zstd-sys/build.rs b/zstd-sys/build.rs
new file mode 100644 (file)
index 0000000..f945ccf
--- /dev/null
@@ -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 (file)
index 0000000..a38a13a
--- /dev/null
@@ -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 (file)
index 0000000..6e07bad
--- /dev/null
@@ -0,0 +1,2 @@
+#include <zstd.h>
+#include <zdict.h>