The problem is that the project's entry point, src/app/main.rs, is wrapped by another entry point. The purpose of wrapping it is to setup some internal variables (and possibly more, futurely). Such wrapper entry point will be generated by build.rs. Here's what the entry point generated by build.rs will look like:
The conventional way to customize program start is not to generate files but to provide an attribute macro that can be applied to main(), like for example tokio::main. This will be a simpler file structure and more familiar to Rust programmers who have used other frameworks.
But that means I'll have to create a separate crate on each rebuild... (For example, there's no way to put a crate on crates.io for that, because the script generated by build.rs will contain project settings such as short-id, full-id etc.). Maybe it could work, yeah... but I still didn't understand how to mimmick tokio::main's approach: Wrap entry point - #5 by Michael-F-Bryan Anyway, I'll still have to generate files on build as I said.
That seems complicated. Say, I'd have to generate a crate at OUT_DIR, right? The problem is, how will I refer to its macro since the crate will be in a very variable location? I just did this in build.rs:
Compiling foo-rs v0.1.0 (C:\Users\matheus-pc\Documents\foo-rs)
error: failed to run custom build command for `foo-rs v0.1.0 (C:\Users\matheus-pc\Documents\foo-rs)`
process didn't exit successfully: `C:\Users\matheus-pc\Documents\foo-rs\target\debug\build\foo-rs-b04af091b1b406d0\build-script-build` (exit code: 101)
thread 'main' panicked at 'C:\Users\matheus-pc\Documents\foo-rs\target\debug\build\foo-rs-6da59176a7067545\out', build.rs:2:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace