Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to have "corrosion_import_crate" import the crates at build time instead of configure time ? #390

Open
noufelez opened this issue May 15, 2023 · 1 comment

Comments

@noufelez
Copy link

Hello,

First of all, I'd like to thank you for what you are doing! I've been using corrosion to create a POC of the usability of rust in our codebase (currently in c++).

During our build process, we need to generate rust crates, let's call it generated_crate. Our main crate, let's call it main_crate has a dependency on generated_crate.

So we call corrosion_import_crate(MANIFEST_PATH main_crate/src/Cargo.toml) and corrosion imports all the dependencies but when it arrives at generated_crate, it crashes because it's not generated yet.

So my question is: is there a way to modify corrosion_import_crate to make it import the crates at build time (even tho that's not the idiomatic way of doing it).

It would be awesome if you can point me to a function or a piece of code which I can change.

Thanks!

@jschwe
Copy link
Collaborator

jschwe commented May 15, 2023

is there a way to modify corrosion_import_crate to make it import the crates at build time

No. At build time you can only evaluate generator expressions, and those are quite limited.

Instead I would suggest you to consider one of the following

a) Only generate the source code, but keep the Cargo.toml manifest static, so that it is available at configure time. This will not be an option if you generate your crate names too, but otherwise it should be possible.
b) Generate your source code at configure time and add a CONFIGURE_DEPENDS rule, which cause CMake to reconfigure when your code generator needs to be rerun.

@jschwe jschwe changed the title Is there a way to have "corrosion_import_crate" import the crates at configure time instead of build time ? Is there a way to have "corrosion_import_crate" import the crates at build time instead of configure time ? May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants