extern crate bindgen; extern crate cmake; use cmake::Config; use std::env; use std::path::PathBuf; fn main() { let dst = Config::new("sandboxed-system-primitives").build(); println!("cargo:rustc-link-search=native={}", dst.display()); println!("cargo:rustc-link-lib=static=SandboxedSystemPrimitives"); let bindings_builder = bindgen::Builder::default() .header("sandboxed-system-primitives/include/wasmtime_ssp.h") .header("sandboxed-system-primitives/src/posix.h") .whitelist_function("wasmtime_ssp_.*") .whitelist_function("fd_table_init") .whitelist_function("fd_table_insert_existing") .whitelist_function("fd_prestats_init") .whitelist_function("fd_prestats_insert") .whitelist_function("argv_environ_init") .whitelist_type("__wasi_.*") .whitelist_type("fd_table") .whitelist_type("fd_prestats") .whitelist_type("argv_environ_values") .whitelist_var("__WASI_.*") .blacklist_item("__WASI_ESUCCESS") .blacklist_item("__WASI_E2BIG") .blacklist_item("__WASI_EACCES") .blacklist_item("__WASI_EADDRINUSE") .blacklist_item("__WASI_EADDRNOTAVAIL") .blacklist_item("__WASI_EAFNOSUPPORT") .blacklist_item("__WASI_EAGAIN") .blacklist_item("__WASI_EALREADY") .blacklist_item("__WASI_EBADF") .blacklist_item("__WASI_EBADMSG") .blacklist_item("__WASI_EBUSY") .blacklist_item("__WASI_ECANCELED") .blacklist_item("__WASI_ECHILD") .blacklist_item("__WASI_ECONNABORTED") .blacklist_item("__WASI_ECONNREFUSED") .blacklist_item("__WASI_ECONNRESET") .blacklist_item("__WASI_EDEADLK") .blacklist_item("__WASI_EDESTADDRREQ") .blacklist_item("__WASI_EDOM") .blacklist_item("__WASI_EDQUOT") .blacklist_item("__WASI_EEXIST") .blacklist_item("__WASI_EFAULT") .blacklist_item("__WASI_EFBIG") .blacklist_item("__WASI_EHOSTUNREACH") .blacklist_item("__WASI_EIDRM") .blacklist_item("__WASI_EILSEQ") .blacklist_item("__WASI_EINPROGRESS") .blacklist_item("__WASI_EINTR") .blacklist_item("__WASI_EINVAL") .blacklist_item("__WASI_EIO") .blacklist_item("__WASI_EISCONN") .blacklist_item("__WASI_EISDIR") .blacklist_item("__WASI_ELOOP") .blacklist_item("__WASI_EMFILE") .blacklist_item("__WASI_EMLINK") .blacklist_item("__WASI_EMSGSIZE") .blacklist_item("__WASI_EMULTIHOP") .blacklist_item("__WASI_ENAMETOOLONG") .blacklist_item("__WASI_ENETDOWN") .blacklist_item("__WASI_ENETRESET") .blacklist_item("__WASI_ENETUNREACH") .blacklist_item("__WASI_ENFILE") .blacklist_item("__WASI_ENOBUFS") .blacklist_item("__WASI_ENODEV") .blacklist_item("__WASI_ENOENT") .blacklist_item("__WASI_ENOEXEC") .blacklist_item("__WASI_ENOLCK") .blacklist_item("__WASI_ENOLINK") .blacklist_item("__WASI_ENOMEM") .blacklist_item("__WASI_ENOMSG") .blacklist_item("__WASI_ENOPROTOOPT") .blacklist_item("__WASI_ENOSPC") .blacklist_item("__WASI_ENOSYS") .blacklist_item("__WASI_ENOTCONN") .blacklist_item("__WASI_ENOTDIR") .blacklist_item("__WASI_ENOTEMPTY") .blacklist_item("__WASI_ENOTRECOVERABLE") .blacklist_item("__WASI_ENOTSOCK") .blacklist_item("__WASI_ENOTSUP") .blacklist_item("__WASI_ENOTTY") .blacklist_item("__WASI_ENXIO") .blacklist_item("__WASI_EOVERFLOW") .blacklist_item("__WASI_EOWNERDEAD") .blacklist_item("__WASI_EPERM") .blacklist_item("__WASI_EPIPE") .blacklist_item("__WASI_EPROTO") .blacklist_item("__WASI_EPROTONOSUPPORT") .blacklist_item("__WASI_EPROTOTYPE") .blacklist_item("__WASI_ERANGE") .blacklist_item("__WASI_EROFS") .blacklist_item("__WASI_ESPIPE") .blacklist_item("__WASI_ESRCH") .blacklist_item("__WASI_ESTALE") .blacklist_item("__WASI_ETIMEDOUT") .blacklist_item("__WASI_ETXTBSY") .blacklist_item("__WASI_EXDEV") .blacklist_item("__WASI_ENOTCAPABLE"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings_builder .generate() .expect("Unable to generate bindings") .write_to_file(out_path.join("wasmtime_ssp.rs")) .expect("Couldn't write bindings!"); }