Closed blueglyph closed 1 year ago
Hi
I've added a new option which allows to generate the Rust file with the directives preamble:
fn main() {
println!("cargo:rerun-if-changed=src/myuifile.fl");
println!("cargo:rerun-if-changed=src/myuifile.rs");
let g = fl2rust::Generator::default();
g.in_out_with_directives_preamble("src/myuifile.fl", "src/myuifile.rs").expect("Failed to generate rust from fl file!");
}
It won't be the default though since the convention with generated files is to include them from OUT_DIR, that's how bindgen does it for example.
You can try it using the main branch. If it's ok I'll publish a new release.
It works well, thanks a lot!
Curiously now the OUT_DIR is set when I test it, I have no idea why it wasn't working yesterday. Perhaps a quirk with the IntelliJ plugin, perhaps I did something wrong? It also detects when to run the script correctly, which it wasn't yesterday.
Description
I would suggest to add an option or to directly add this preamble to the generated Rust code:
This removes the necessity to create an intermediate file with that preamble that must include the generated file, which is awkward.
Temporary work-around
As a work-around, here is how I modified the build.rs example to make it work (removing the
OUT_DIR
which is not defined by the tools and should be modified for each project):Note: the build.rs file must be in the same directory as Cargo.toml, NOT in the src directory!
Unfortunately it has to read the whole content and re-write the generated file, but it's fine to store that in a buffer as long as the generated file is not too large.
Version
fl2rust doesn't show a version, but it must correspond to the crate version 0.4.17