build.rs 918 B

12345678910111213141516171819202122232425262728
  1. fn main() {
  2. println!("cargo:rustc-link-search=native=./build/gblibstdc++");
  3. println!("cargo:rustc-link-lib=static=gblibstdc++");
  4. let headers = [
  5. "include/kernel/process.hpp",
  6. "include/kernel/hw/pci.hpp",
  7. ];
  8. let bindings = bindgen::Builder::default()
  9. .use_core()
  10. .ctypes_prefix("core::ffi")
  11. .headers(headers)
  12. .clang_arg("-I./gblibstdc++/include")
  13. .clang_arg("-I./gblibc/include")
  14. .clang_arg("-I./include")
  15. .clang_arg("-std=c++20")
  16. .opaque_type("std::.*")
  17. .enable_cxx_namespaces()
  18. .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
  19. .generate()
  20. .expect("Unable to generate bindings");
  21. let out_path = std::path::PathBuf::from(std::env::var("PWD").unwrap());
  22. bindings
  23. .write_to_file(out_path.join("src/bindings.rs"))
  24. .expect("Couldn't write bindings!");
  25. }