Our lib.rs is mostly just a directory listing of all the other .rs files in the project. When we add a new file we need to add it to the lib.rs and its a very mundane task.
I wrote a script to automate it and put it in src/bin/rebuild_lib.rs
. I developed it as a separate project and it built and ran fine, however, once I moved it into the project I want to use it in it no longer works. When I try to run it with cargo run --bin rebuild_lib.rs -- --out src/lib.rs
cargo tries to compile the lib.rs
as dependency which fails because lib.rs
is out of date.
This is a catch 22 situation now; rebuild_lib.rs
is fully self contained (with the exception of the regex crate) so it doesn't need lib.rs or any of the other code in the project, but cargo refuses to build it until the rest of the project also compiles.
How can I tell cargo to build / run the script without trying to build the rest of the project? Or am I barking up the wrong tree here and should be trying some other way to automate generating the lib file? (e.g. installing ts-node in our dev environment and using the original version of the script I wrote in typescript?)