-
Notifications
You must be signed in to change notification settings - Fork 480
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
Introducing bindgen #695
Introducing bindgen #695
Conversation
Wow, that's a lot of stuff! I didn't expect that for sure! Great work overall! I have a few concerns though, I haven't look into it in details but it looks like someone on Linux without the SDL2 headers installed wouldn't be able to compile at all, because there is no alternative to bindgen with that PR. On Windows, people would be even more screwed, since headers and stuff like that are a pain to install on WIndows. Same comment with the feature pkg-config being the default: what would happen on Windows? I think this PR is great, but overall I would still like people to be able to build stuff with SDL2 without the bindgen dependency if they choose to. So I actually have 2 ideas:
|
About your first proposal: this is hingly impractical, beacuse you would need a pregenerated sdl2-sys for each target (and there are just too many). In the meantime I've added Also now the fail of I've also moved the default |
While rebasing with the "bundled" feature would be an acceptable idea, I just want to make sure we are on the same page about what is going to be done there. Basically we will have only one feature:
That should cover every case: even if I don't want to compile the SDL2 source myself or/and I am not on Linux, I can still compile this crate with the included headers in the include/ directory If I want a custom version of the headers, I can always set myself the SDL2_INCLUDE_PATH environment variable beforehand. How does that sound to you? |
I almost completely agree: I just think the priority of All of those changes have landed with the last commit. |
Sounds good to me! Let me just check locally that it works correctly on Linux (I'll try to get myself a Windows as well), and I think we should be good to go. Ideally I would like someone with OSX to test with and without framework as well (and make sure it's still functional). |
I should have mentioned that I've worked on this PR using Linux (Arch Linux to be specific) with rustc 1.21.0-nightly, so I've only tested it for this platform. |
This may sound like a dumb question but can bindgen detect cross compiles? What happens if I use rustup and say compile to a win32 target from a Linux? |
This last matter is especially going to be useful for those who cross compile to Android and iOS, as you simply cannot compile rust programs on those platforms without cross compiling. |
Just tried to cross-compile some of the examples from Arch Linux with target |
As you suspected the generated headers were the same, because |
If there is anything else I can do for this PR let me know. |
I would like to test this on OSX before moving on, if you know someone or if you have a Mac yourself available (I don't), then I'd love to make sure everything work both with and without framework with this PR. |
After having tested it, it works perfectly, however I'm getting this message: "warning: redundant linker flag specified for library Also, I'm getting some warnings that can be very easily fixed:
Would you mind cleaning as much as possible before moving on? Thank you! |
I've resolved all |
After discussing with some people on IRC, it looks like it's a bad idea to force everyone to use this by default; bindgen uses llvm, and while on linux systems it's pretty easy to obtain via package managers, on Windows it's not. I don't really want to force everyone to make a hello_world test to have to install llvm dependencies on top of of everything else. Bindgen is pretty accurate in what it generates, so in most of the times a single bindgen on a linux will work out very well for other systems. I think one of the only exception to that rule is when system-specific defines are used in the headers; as far as I can recall, this is only used with the WM* methods in SDL2 -- it's not something everyone is going to need. So on one hand we can support everything and force users to install llvm just to build this crate, while on the other hand we could include a bindgen'd version that would be enough for 90% of the users without installing anything else. So the idea here is to have this as an optional feature, and if this feature is disabled, use a pre-generated bindgen output (that we could include directly in this repo). Everything else would stay the same. What do you think? |
As discussed on IRC, I've made the |
As discussed on IRC, before merging this I would like to add more documentation, especially in the README (and the changelog), concerning this new feature. I would have preferred #693 to be merged before this so that we could rebase and take the headers directly from the "source" package if we can, but that will be for another day. |
I've sync'd with the latest commit on
I don't think it has to do with this PR, but please confirm this. |
Yes it's to be expected, please do |
Yep, I confirm that with |
I've updated the pregenerated bindings to SDL2 version 2.0.6 |
Cheers! Sorry for the delay! I added an entry to the changelog and some documentation in the README, but otherwise it was good to go, at least on Linux. Like usual I would have liked to have some more testing on Windows & macOS, but I think it shouldn't affect them too much for now as the bindgen is an opt-in and not an opt-out. |
In order to fix #694 and others I've tried to replace sdl2-sys with a bindgen dynamically generated -sys crate.
In the
sdl2
crate only one method has changed (data1
anddata2
ofevent::Event::User
are now::std::os::raw::c_void
instead of::libc::c_void
), so the API practically hasn't changed.The
sdl2-sys
crate has an almost completely new API (begin now generated by bindgen).For now I don't feel like the other sdl related libraries (TTF, Mixer, Image and GFX) should be integrated in the
sdl2-sys
crate with this PR; maybe this will happen with a future one.sdl2
pass all the tests, andsdl2-sys
pass all the bindgen generated tests.The examples which work on
master
(for some reasonanimation.rs
doesn't work on my machine) also work with this PR.