This seems like an oversight, since build.rs files can have arbitrary useful outputs.
In my case, I'm trying to wrap the intel_tex_2 crate, which appears to require that the build script is run in the same directory that compilation happens.
Specifically, it writes an absolute path to an env_var via cargo:rustc-env=ISPC_OUT_DIR, which means that variable can't be overridden by
either rustc_env, or build_script_rustc_env.
That path is then used inside a macro during compilation, so I must either
- Set the build script run directory to the execroot for the package which winds up with the rather brittle
external/rules_rust++crate+crates__intel_tex_2-0.5.0 so that the path when running the build script matches the basic symlink
or
- Use cargo_manifest_dir_filename_suffixes_to_retain and globally retain
.rs files
There's a variety of possible solutions here, but the one I think would be best is probably allowing per-crate overrides of the retain list.