Add slice swap benchmark.
Adds a benchmark of various different ways of swapping the elements of
two slices, including several implementations in C.
Change-Id: I7ff490aefee6edfe5d7630b851278ce1fc385e8c
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..3bd87c0
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,24 @@
+use std::env;
+use std::path::PathBuf;
+
+fn main() {
+ // Generate C header bindings.
+ println!("cargo:rerun-if-changed=wrapper.h");
+
+ let bindings = bindgen::Builder::default()
+ .header("bindings.h")
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks))
+ .generate()
+ .expect("Unable to generate C bindings");
+
+ let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
+ bindings
+ .write_to_file(out_path.join("bindings.rs"))
+ .expect("Unable to write bindings.rs");
+
+ // Compile C code.
+ cc::Build::new()
+ .file("c/swap.c")
+ .flag("-std=c17")
+ .compile("swap");
+}