alef 0.25.39

Opinionated polyglot binding generator for Rust libraries
Documentation
// This file is auto-generated by alef. DO NOT EDIT.
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/{{ header_name }}");

    // 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.
    //
    // Also add `@loader_path` as an LC_RPATH so transitively-linked dylibs
    // (e.g. `@rpath/libonnxruntime.<ver>.dylib` referenced by ort-bundled) can
    // be resolved against the same directory the consumer ships the FFI
    // cdylib in. NuGet/Maven/wheels all co-locate the bundled native deps
    // alongside the cdylib, so `@loader_path` is the universally correct rpath.
    // Without LC_RPATH entries, dyld reports `no LC_RPATH's found` and the
    // load fails even though the sibling dylib is present.
    if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
        println!("cargo:rustc-link-arg-cdylib=-Wl,-install_name,@rpath/{{ lib_name }}.dylib");
        println!("cargo:rustc-link-arg-cdylib=-Wl,-rpath,@loader_path");
    }
{{ go_copy_step }}}