Created
February 21, 2024 21:24
-
-
Save mishushakov/b88eabb1f10fed48da648921040eb54d to your computer and use it in GitHub Desktop.
Hermes bindgen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::path::PathBuf; | |
fn main() { | |
let hermes_src_dir = "./hermes"; | |
let hermes_build_dir = "./release_debug"; | |
// Tell cargo to invalidate the built crate whenever the wrapper changes | |
println!("cargo:rerun-if-changed=wrapper.h"); | |
// Add include paths | |
let bindings = bindgen::Builder::default() | |
.header("wrapper.h") | |
.clang_arg(format!("-I{}/API/hermes_abi", hermes_src_dir)) | |
.layout_tests(false) | |
.generate() | |
.expect("Unable to generate bindings"); | |
// Write the bindings to the $OUT_DIR/bindings.rs file. | |
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | |
bindings | |
.write_to_file(out_path.join("bindings.rs")) | |
.expect("Couldn't write bindings!"); | |
// Add link paths and libraries | |
println!("cargo:rustc-link-search=native={}/API/hermes_abi", hermes_build_dir); | |
println!("cargo:rustc-link-lib=dylib=hermesabi"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hermes_abi.h> | |
#include <hermes_vtable.h> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment