build.rs 951 B

1234567891011121314151617181920212223242526272829
  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. "include/types/elf.hpp",
  8. ];
  9. let bindings = bindgen::Builder::default()
  10. .use_core()
  11. .ctypes_prefix("core::ffi")
  12. .headers(headers)
  13. .clang_arg("-I./gblibstdc++/include")
  14. .clang_arg("-I./gblibc/include")
  15. .clang_arg("-I./include")
  16. .clang_arg("-std=c++20")
  17. .opaque_type("std::.*")
  18. .enable_cxx_namespaces()
  19. .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
  20. .generate()
  21. .expect("Unable to generate bindings");
  22. let out_path = std::path::PathBuf::from(std::env::var("PWD").unwrap());
  23. bindings
  24. .write_to_file(out_path.join("src/bindings.rs"))
  25. .expect("Couldn't write bindings!");
  26. }