-
Notifications
You must be signed in to change notification settings - Fork 468
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
Autoformat build!
macros with new windows_fmt
crate
#828
Conversation
Now we have an example of a failed CI run at https://github.com/microsoft/windows-rs/actions/runs/887995007, including the Follow the CI link to see the full diff output. |
Sweet - will take a look soon! |
I had a quick look and not knowing anything about PowerShell am a little concerned about what this actually does and how. It would also be great if I could run it locally to observe its behavior, but when I run it I get errors.
Another option is to write a Rust command to perform this operation. I think that would ultimately be a better choice anyway e.g. |
That is unfortunate, I had assumed PowerShell to be the go-to scripting language for Microsoft projects, like how win32metadata exists almost exclusively of PS scripts (and some C#). Would it help if I document it with some comments?
Definitely! It runs fine on the CI under Windows and has me curious what's going on on your system.
This makes zero sense.
I'm not a fan of binaries that have to be installed first, but it seems the
The Let me know if you'd like to debug this script a little or jump to an extra Rust crate immediately. |
It could be something simpler like the the way the "bindings" crate is run. The simplest possible solution (in Rust) would be ideal. |
198327d
to
7633eaf
Compare
build!
macros with PowerShell scriptbuild!
macros with new windows_fmt
crate
This allows a future change to more easily find-replace the `build! {` part of the macro with a `use build_macro::{` with matching `};` already in-place, allowing rustfmt to autoformat the blocks.
https://github.com/microsoft/windows-rs/pull/828/checks?check_run_id=2766964459 Awesome, the new Rust script is still working exactly as PowerShell 🎉 |
Looks great! Looking forward to seeing a failed build. 😉 The only thing is I'd like to remove all "author" names from toml files. The only ones that should remain are those required by "cargo publish" for crates.io but the rest including examples/tests/tools should just be removed entirely. GitHub does a fine job of tracking contributors and I'd prefer not to manage that in text format as well. So just a heads up that I'll probably scrub these when I get a moment. |
That's fair; I think most community driven projects (ie. |
And after re-pushing the CI succeeds, as expected. @kennykerr given #842 (comment), in what steps do you want to land this? |
Looks great! It looks like this takes care of it all so I'm happy to just merge this in. |
Works for me! |
This reintroduces the "pipe Rust code through rustfmt before writing to disk" code from [microsoft#828] and yields a massive performance improvement for running in parallel over all files now, and not having to write, read, and write the same files over again. Unfortunately Rust's `Command` structure does not yet have proper support for forwarding stdout to a file (that's not unix-specific), though it could possibly be beneficial to write chunks read from stdout directly to a file instead of reading the whole lot into memory first. [microsoft#828]: microsoft#828
Closes #827
We convert the
build!
(andgenerate!
) macro calls to use curly braces, so that we can then replace the call with ause something::{
that allowsrustfmt
to perform all its formatting tricks like it normally would touse
trees, to clean up the blocks and make them look more like theuse
blocks inmain.rs
.This is wrapped up in a PowerShell script and pipes the replaced result through
rustfmt
to not modify and/or leave garbled files on disk. The script is ran in the CI to enforce proper formatting at all times; contributors are encouraged to run the script themselves if formatting differs.