-
Notifications
You must be signed in to change notification settings - Fork 533
feat(rust_common): allow compile actions to declare more outdirs #3737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@UebelAndre ping! |
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks reasonable - could you add a small test showing this working? Thanks!
|
@illicitonion done, thanks PTAL |
5b828f6 to
ddd7571
Compare
…s will be created This technique is sometimes needed when a proc_macro derives information from the build, and it needs to be consumed by some other tool sort cursor wrote a new unit test for this PR fmt
ddd7571 to
e410375
Compare
|
Test failures do not look related to my change, FWICT |
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, thanks! A couple of small things :)
| ], | ||
| proc_macro_deps = [":write_outdirs_macro"], | ||
| rustc_env = { | ||
| "EXTRA_OUTDIRS": "test_dir,another_dir", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make sure the output dirs support location expansion? That's how I'd expect this to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added to the docstring:
"The paths are always relative to the output directory of the current Bazel package."
I would not expect them to support location expansion, but only because https://bazel.build/rules/lib/toplevel/attr#output_list doesn't have an equivalent output_dir_list, so there's no way during analysis to resolve such expansions.
Seems like a missing feature in Bazel to me.
This technique is sometimes needed when a proc_macro derives information from the build, and it needs to be consumed by some other tool.
For example this one generates a JSON file as an intermediate output
https://github.com/napi-rs/napi-rs/blob/main/crates/macro/src/expand/typedef/type_def.rs#L11-L12
and then expects developers to call this via a Node.js binary which wraps rustc and also transforms that file to a TypeScript type definition file.
Under Bazel, this is better modeled as a rust_shared_library that produces the binding file (
.soor.dylibfor example) along with that JSON output, then run the Node.js binary as a separate target.