rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Support sorting items by name

Open bjorn3 opened this issue 1 year ago • 3 comments

Currently there is only --sort-semantically to sort by item type. Sorting by name would make it easier to diff bindings generated for different platforms that have different order of items in their headers.

bjorn3 avatar Oct 15 '24 09:10 bjorn3

Maybe --sort-semantically should be superseded by a ParseCallback that gives you the necessary info to sort it however you want.

pvdrz avatar Oct 15 '24 14:10 pvdrz

I'm using the bindgen cli, so a callback won't work. I don't really care about the exact order in which items are sorted for as long as the output doesn't depend on the order of items in the C source and is robust against additions and removals of items in the C source.

bjorn3 avatar Oct 17 '24 11:10 bjorn3

This issue makes me think that we need some standard way to turn ParseCallbacks into some kind of interface that works nicely with bindgen-cli.

The easiest thing that comes to mind is probably being able to specify a command that can communicate with bindgen via stdio, but that means that we need to agree on the input and output format and maintain it under our stability guarantees.

Another option would be to allow bindgen to dynamically load a library that does this for us. The advantage there is that we can "just" use the C ABI for everything but at the same time it means that you cannot just write a bash script for it.

pvdrz avatar Oct 17 '24 15:10 pvdrz