I have a project that depends on a crate where a header file is generated with cbindgen. How can I get the path to this header file? I have external tools that need to include it.
I am using git dependencies in cargo. I can find the header file in two places:
- In cargo's global package registry/cache (for me it's
~/.local/share/cargo/git/checkouts/<my_repo>-<some_hash>/<commit_sha>/...
) - In the main project's
target
directory (if I use theOUT_DIR
environment variable in the dependency's build script, it puts it intarget/debug/build/<the_crate>-<some_hash>/out/include/header.h
)
Is there any way I can get programmatic access to the header? I do not know how the hashes are generated, and even if I did I feel it's a hack to try to get the path to the files that way.
Is there another environment variable I can use to tell cbindgen to put the file somewhere else accessible?
Edit: I know I can use the extra_bindings
option in cbindgen, but that puts all bindings in the same header, which is not desired.