Skip to content

Option for only generating bindings for filenames matching a pattern #303

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

Closed
crumblingstatue opened this issue Nov 22, 2016 · 3 comments
Closed

Comments

@crumblingstatue
Copy link

Yamakaky/rust-bindgen has this option, which allows only generating bindings for filenames matching a pattern.

I make use of this feature for rust-sfml, where there are multiple auto-generated bindings that depend on each other, so I don't want to regenerate all the bindings for each library.

I'm trying out servo/rust-bindgen because Yamakaky/rust-bindgen is broken with Clang 3.9, but I cannot make the switch without this feature.

@emilio
Copy link
Contributor

emilio commented Nov 22, 2016

So the idea was replacing that --matches flag, which is particularly tricky (stuff can be declared in multiple files, also in C++), with the --whitelist flags.

Note that, even though it's not too well documented, the --whitelist flags accept a regex, so for sfml-audio-sys you could do something like --whitelist-type "sfMusic.*" --whitelist-type "sfSound.*" --whitelist-function "sfSound.*" ....

If your functions depend on other, you can explicitly blacklist the types that depend on other libraries and use other flags for the imports.

This is relatively hard for sfml because as you said there are a lot of inter-dependencies. Let me know if the white/blacklisting approach works for you.

I can try to implement --matches looking for the definition of stuff, but it can be relatively tricky with a bunch of things that clang doesn't expose.

For the record what the Yamakaky's bindgen does is just not parse the rest of files, which is easy, but it's also a source of internal problems inside that bindgen that we don't have to deal with (that kind of stuff is what made me do #37).

@crumblingstatue
Copy link
Author

crumblingstatue commented Nov 22, 2016

I find constructing a whitelist manually for each type, function, constant, etc. too tedious to deal with. Especially since I was spoiled by --matches, and it works without problems for rust-sfml.

@pvdrz
Copy link
Contributor

pvdrz commented Sep 15, 2022

This was fixed when Builder::allowlisted_files was introduced.

@pvdrz pvdrz closed this as completed Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants