-
Notifications
You must be signed in to change notification settings - Fork 503
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
bindgen: Add mode to skip API that relies on things defined outside --filter
#3157
Comments
If you skip over the APIs that don't satisfy --filter, the result would presumably be incomplete. Is that really desirable? |
@riverar if that portion of the API is needed, I'd add it to As a reminder we could also generate commented-out function signatures to indidcate what "could have been" there if a list of missing types is also provided? In any case this idea might be problematic when missing types are used in structs or type-definitions for vtables? |
Yes, this is a very difficult problem. I'd like filtering to be more intelligent though and it's something that I've been wanting to work on, so I'll noodle on this some more. |
Thanks @kennykerr! I wasn't exactly sure if the I thought since the |
We already include bindings for Windows.Gaming.Input, so I'm a bit confused. Can you provide a use case here? Am struggling to think of a reason why you'd want to emit types/APIs from If the goal is to generate the smallest set of bindings possible, for a specific set of APIs/types, maybe it makes more sense to accept an explicit list of APIs/types. |
@riverar you self-answered it:
Specifically this is what I want, with The use-case is no longer having to upgrade versions throughout a growing number of crates whenever yet another breaking |
I think I made some progress unraveling this one today. I hope to have something to share next week. |
I don't know if this is related to this issue, or if there's a separate issue for this request, but I'd also like a reverse functionality: specifying a single filter to include all the dependencies. E.g. for the use case in #3242 I'd rather have specified |
Yep, that's why this is not a simple fix. Both models are important but not very composable. |
Suggestion
When creating a single bindings file within another crate, I'd like to use
windows-bindgen
with the default options, i.e.:cfg
, because the fact that this file is part of the crate shouldn't leak to users of the crate;package
, because it's not a new package but a single file containing bindings to a subset of the Windows API specified via--filter
;flatten
, so that namespaces are preserved.Would it be possible to create a mode like that? Right now the default with this example
bindings.txt
:Generates non-compiling code because some functions depend on types outside of the
Windows.Gaming.Input
namespace.A workaround would be to include namespaces for the missing types, but they have dependencies as well and this quickly spirals out of control (as in: I end up listing most of the Windows API under
--filter
) to the point where using thewindows
crate directly makes more sense, both from a size as well as maintenance standpoint.Perhaps this should go into a separate issue, but when running with
flatten
(which seems to automatically pull in all dependencies), a bunch of definitions are duplicated, causing a failed compile as well:The text was updated successfully, but these errors were encountered: