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!
The text was updated successfully, but these errors were encountered:
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
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
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!
The text was updated successfully, but these errors were encountered: