I have two crates A and B, where A has a build script requiring some configurations (some absolute paths which cannot be recorded in git) set by user and B dependents on A (with A uploaded in local gitlab). I want users using B can successfully transfer information to A's build script.
I do not want to use environment variables to pass such information since the cargo configuration is also recorded in git repository for some other reasons. So I want users to put such configurations in B's project root directory, and let A to read such file and get the information. However,
CARGO_MANIFEST_DIR in A's build script turns out to always be A's path, even called in B. I cannot find a way to get B's project root path.
What kind of information?
If it’s a simple flag, a feature can do the job. B can set features on A, and it can do it conditionally, allowing you to “plumb” the feature through the tree to its leaves.
If it’s more complicated, you’d want cargo globals, a proposal that hasn’t been implemented.
Thank you for your reply. I want to pass an absolute path from downstream to upstream. It seems that the [env] section in cargo configuration is the only possible way right now.
(P.S. I think tauri has implemented this ability, since the upstream can read the tauri.conf.json file located in downstream's project root. However, their codes are too complicated that I cannot find out how they implemented it.)
Isn’t that because the downstream crate generated by create-tauri-app provides it at runtime?
// ^^^ store the configuration in the Builder at runtime
.expect("error while running tauri application");
Seems I misunderstood tauri. Thank you for clarification:)