Currently if a Rust module does not have src/lib.rs or src/main.rs, it will not even build. The build script should still have a life cycle so those files could be generated from the build script itself, additionally, a cargo.toml flag could be set, that this is a "build" module and run the build script on cargo build, but not have any Rust code, here is the use case:
A workspace with mostly Rust code, but also non-rust javascript frontend and directories with other programming languages. I think it'd be pretty neat if running I could startup all these components from a single cargo command. This way Rust could be used to execute build scripts for non-Rust fragments.
On top of that, Cargo enumerates all build-targets at the very beginning and allowing dynamically generated build-targets would be a massive undertaking and may even run into fundamental problems where we need to know something before we know it. Requiring users to explicitly enumerate these in Cargo.toml may help. In fact, you might even be able to do that today.