forked from tokio-rs/io-uring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
36 lines (31 loc) · 1 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#[cfg(not(feature = "bindgen"))]
fn main() {}
#[cfg(feature = "bindgen")]
fn main() {
use std::env;
use std::path::PathBuf;
const INCLUDE: &str = r#"
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/time_types.h>
#include <linux/stat.h>
#include <linux/openat2.h>
#include <linux/io_uring.h>
"#;
#[cfg(not(feature = "overwrite"))]
let outdir = PathBuf::from(env::var("OUT_DIR").unwrap());
#[cfg(feature = "overwrite")]
let outdir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("src/sys");
bindgen::Builder::default()
.header_contents("include-file.h", INCLUDE)
.ctypes_prefix("libc")
.derive_default(true)
.generate_comments(true)
.use_core()
.whitelist_type("io_uring_.*|io_.qring_.*|__kernel_timespec|open_how")
.whitelist_var("__NR_io_uring.*|IOSQE_.*|IORING_.*|IO_URING_.*|SPLICE_F_FD_IN_FIXED")
.generate()
.unwrap()
.write_to_file(outdir.join("sys.rs"))
.unwrap();
}