In general, build scripts should not modify any files outside of OUT_DIR. It may seem fine on the first blush, but it does cause problems when you use such crate as a dependency, because there's an implicit invariant that sources in .cargo/registry should be immutable. cargo won't allow such scripts when packaging.
Generated files should no longer go into the src directory. Instead OUT_DIR should be used.
This is as currently documented: https://doc.rust-lang.org/cargo/reference/build-scripts.html#case-study-code-generation
There is even a feature in cargo to block added in https://github.com/rust-lang/cargo/pull/5584