use std::{fs, io::Write as _, path::PathBuf};
fn main() {
}
fn build() {
let librs_path = PathBuf::from("src").join("lib.rs");
println!("cargo:rustc-link-lib=swiftCore");
if librs_path.exists() {
fs::remove_file(&librs_path).unwrap();
}
let bindings = bindgen::Builder::default()
.clang_arg("-x")
.clang_arg("c++")
.clang_arg("-std=c++14")
.header("wrapper.h")
.raw_line("#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals, improper_ctypes)]")
.blocklist_item("template")
.blocklist_item("_Pred")
.blocklist_item("_Tp")
.blocklist_type("template")
.opaque_type("_Tp")
.opaque_type("std::.+")
.enable_cxx_namespaces()
.clang_arg("-Ifake")
.clang_arg("-Iswift/include")
.clang_arg("-Iswift/stdlib/public/SwiftShims/")
.raw_line("pub type _Tp = ();")
.raw_line("pub type _Pred = ();")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("Unable to generate bindings");
let code = bindings.to_string().replace("extern \"swift\" {", "extern \"C\" {");
let mut file = fs::OpenOptions::new()
.write(true)
.truncate(true)
.create(true)
.open(librs_path).unwrap();
file.write_all(code.as_bytes()).unwrap();
}