-
Notifications
You must be signed in to change notification settings - Fork 747
Omit contents of #includes in final generated rust file #1200
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
Comments
You can use the whitelisting arguments to whitelist just what you need, like |
yes, that will work, thanks! |
Ok, great, thanks again for filing! :) |
You can whitelist specifics from the headers, but the larger the library, the more cruft you need in your bindgen configuration. You also have to keep it up to date as the library changes, which seems to go against the goal of bindgen taking away this work. Has anyone else had trouble with this, or come up with a way to exclude system includes? Funny enough, I see that the bindgen CI checks that there are no system includes... https://github.com/rust-lang-nursery/rust-bindgen/blob/master/ci/no-includes.sh |
Yeah, that's intentional to avoid non-deterministic bindings.
The idea is to use regexes to catch items using the naming convention of the library. Then after that all gets whitelisted recursively. See https://github.com/servo/mozangle/blob/3da78f0a27399a4673520d26ad5e7b9be559d07e/build.rs#L21 for example. If the library you're binding against doesn't have any sort of type / function naming convention or what not, that can indeed be a problem. If you point me to an specific example we can try to figure out what's the best solution for that. Mind opening a new issue for it though? |
Try Windows SDK. 100KB header in -> 4MB .rs out with loads of useless junk inside mixed with what was in the actual header. |
Input C/C++ Header
Bindgen Invocation
Actual Results
It creates a bindgen file for everything within the #included header, when in fact I just want that header for its preprocessor defines.
Expected Results
I'd like some way to have it just emit the contents of the file, and thus only use the #includes to set up the preprocessor to parse the contents of the file.
The text was updated successfully, but these errors were encountered: