You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a library that needs to access the CARGO_MANIFEST_DIR from the app that uses it, is that possible? The objective is read application assets at compile time.
The text was updated successfully, but these errors were encountered:
I'm not sure I understand the question. You can can call std::env::var("CARGO_MANIFEST_DIR") from a build script to get the project directory (whichever project is using the build script).
When cargo starts building my crate (let's name it my-tool), it assigns the CARGO_MANIFEST_DIR environment variable to the path of this crate's manifest (e.g. /path/to/my-tool). What I'd like to know is the path of the manifest of the crate that's using my-tool as a dependency (let's name it my-app).
Is the only option here to force the my-app/build.rs to call my-tool/build.rs?
Ah, I think I see what you mean. No, dependencies do not have any information about the packages that depend on it. Your my-app/build.rs would need to specy my-tool as a build dependency and interact with it via its API. Perhaps an analogous example is the cc crate where you load it as a build dependency, and then pass relative paths into it.
I'm writing a library that needs to access the CARGO_MANIFEST_DIR from the app that uses it, is that possible? The objective is read application assets at compile time.
The text was updated successfully, but these errors were encountered: