-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add bindings for target_env = "libnx" #1829
Conversation
r? @JohnTitor (rust_highfive has picked a reviewer for you, use r? to override) |
I fixed most of the style issues, but the item ordering seems like it could be really annoying to fix by hand. Is there anything that automates this? |
I wrote this tool to sort the items: use quote::ToTokens;
use std::env;
use std::fs;
use syn::Item;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let code = fs::read_to_string(env::args().nth(1).unwrap())?;
let mut file = syn::parse_file(&code)?;
let (foreign, mut items): (Vec<_>, Vec<_>) = file
.items
.iter()
.cloned()
.partition(|x| matches!(x, Item::ForeignMod(_)));
let mut foreign_iter = foreign.into_iter().map(|x| {
if let Item::ForeignMod(x) = x {
x
} else {
unreachable!()
}
});
let mut foreign_mod = foreign_iter.next().unwrap();
foreign_mod.items.extend(foreign_iter.flat_map(|x| x.items));
items.push(Item::ForeignMod(foreign_mod));
file.items = items;
file.items.sort_by_key(|x| match x {
Item::Use(_) => 1,
Item::Type(_) => 2,
Item::Struct(_) => 3,
Item::Union(_) => 3,
Item::Enum(_) => 3,
Item::Const(_) => 4,
Item::Static(_) => 4,
Item::Fn(_) => 5,
Item::ForeignMod(_) => 6,
_ => 7,
});
println!("{}", file.into_token_stream().to_string());
Ok(())
} |
CI failure seems to be spurious (looks like something's broken in the latest cargo-xbuild release). |
It's due to rust-lang/rust#74577. |
@leo60228 Could I hold off this until rust-lang/rust#74567 gets an approval from the team, and naming and other matters are stabilized? (At least we should wait for fixing nightly though.) |
9db9538
to
84597a8
Compare
☔ The latest upstream changes (presumably #1975) made this pull request unmergeable. Please resolve the merge conflicts. |
Looks like the above PR was closed due to inactivity. I'm going to close this as well but feel free to re-open once you get some time to work on. Thanks! |
This target is added by rust-lang/rust#74567. This was originally generated through rust-bindgen, then cleaned up by hand.