prebindgen-project-root

Crates.ioprebindgen-project-root
lib.rsprebindgen-project-root
version0.4.1
created_at2025-08-29 11:28:42.746962+00
updated_at2025-09-01 14:42:55.916696+00
descriptionUtility to expose the workspace project root at build time
homepage
repositoryhttps://github.com/milyin/prebindgen
max_upload_size
id1815730
size37,486
Michael Ilyin (milyin)

documentation

https://docs.rs/prebindgen

README

prebindgen-project-root

A tiny utility crate that, when built inside a Cargo workspace, discovers the workspace root.

The main purpose of this tool is to allow a crate installed from crates.io (i.e., not part of the workspace) to find the workspace's Cargo.lock at compile time. A simple call to the well-known project_root::get_project_root() doesn't work here because it searches upward from the current working directory, which during a build is inside $HOME/.cargo rather than your workspace.

This crate solves the problem by injecting itself into the user's workspace via the [patch] section. That is, the workspace contains a copy of the prebindgen-project-root crate which, being inside the workspace, can determine the workspace root. Any crate that depends on prebindgen-project-root will then use the copy from the user's workspace instead of the one in $HOME/.cargo.

The Cargo subcommand prebindgen-project-root automates this injection. Run:

cargo install prebindgen-project-root
cargo prebindgen-project-root install .
Commit count: 429

cargo fmt