The order of operations in a Cargo build is that first all of your dependencies are built, and only then does any code from your own package get compiled or run. The build script runs before anything else in your package is compiled, but it does not run before your dependencies are analyzed and compiled. Not only that, but also, Cargo determines the entire dependency graph before anything else is done.
If you want to control the path where a dependency is found, you must write a program that generates the Cargo.toml file before the cargo build command is issued.
And if you want to share some common local dependency, you probably either want a workspace (if there's some relatively small amount of crates depending on it) or want to publish it separately (possibly to some private registry instead of crates.io).