`rust_test()` doesn't set `OUT_DIR`
My use case is calling a Rust macro in my test which expects to find generated code relative to the OUT_DIR compilation-time environment variable. It's likely that rust_binary() doesn't set this either; I haven't checked because I use a genrule to create the output files.
Note, I don't use cargo_build_script() here due to compilation difficulties.
There isn't a general concept of an OUT_DIR independent of a cargo_build_script - your genrule can output code, but it won't know what a shared directory exposed to the rust code would be.
You can use cargo_build_script to write to the OUT_DIR, or you can use some other way of passing the path to the rust code being compiled.
Got it. It appears some third party Rust code always assumes OUT_DIR exists, thus my question. I've worked around it via env, but that is a bit tricky as it's somewhat restrictive what can be set to an environment variable in Bazel. Maybe this is uncommon, but might be useful to compile rust code generally if code like this is in wide circulation. Feel free to close.