This commit is contained in:
23
crates/kreuzberg-ffi/build.rs
generated
Normal file
23
crates/kreuzberg-ffi/build.rs
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
// This file is auto-generated by alef. DO NOT EDIT.
|
||||
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||||
fn main() {
|
||||
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("Unable to generate C bindings")
|
||||
.write_to_file("include/kreuzberg.h");
|
||||
|
||||
// Set @rpath-relative install_name on macOS so the cdylib can be relocated
|
||||
// (bundled into language packages like packages/go/.lib/<rid>/, packages/
|
||||
// java/src/main/resources/natives/<rid>/, etc.) and located via the consumer
|
||||
// binary's rpath at runtime. Without this, the install_name embeds the CI
|
||||
// runner build path (`/Users/runner/work/.../target/.../deps/lib<name>.dylib`)
|
||||
// and dyld fails to load the bundled copy from its actual location.
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
|
||||
println!("cargo:rustc-link-arg-cdylib=-Wl,-install_name,@rpath/libkreuzberg_ffi.dylib");
|
||||
}
|
||||
|
||||
let go_include_dir = std::path::Path::new("../../../packages/go/v5/include");
|
||||
std::fs::create_dir_all(go_include_dir).expect("Unable to create Go include directory");
|
||||
std::fs::copy("include/kreuzberg.h", go_include_dir.join("kreuzberg.h"))
|
||||
.expect("Unable to copy header to Go include directory");
|
||||
}
|
||||
Reference in New Issue
Block a user