Some questions about binding another language to SDL2


#1

Hi all.

So I’m trying to hammer out some bindings to SDL2 in Rust. There’s a program called bindgen that Rust folk use, it parses out include files (including the whole CPP step) and then uses the generated C declarations to automatically generate the correct Rust bindings. Neat stuff.

First Question: Which Include Files
On the SDL-2.0 downloads page there’s a zip file for “Source”, which naturally has include files. There’s also a zip file for “Development Libraries”, and the Windows archives have some include files as well. However, just looking at the directory summary in windows explorer it looks like each of these include file sets is a little different:

  • source zip: 86 files, 1,709,281 bytes
  • msvc: 86 files, 1,709,076 bytes
  • mingw-i686: 73 files, 1,635,319 bytes
  • mingw-x86_64: 73 files, 1,798,144 bytes

If I want to target at least all three major desktop platforms, should I focus on using the includes from the “source” zip? Are those the “canonical” includes? Or should I just set aside a copy of the includes per OS target?

Second Question: iOS building
The iOS script at least seems to modify the includes a bit during its build script, what’s up with that? Part of build-scripts/iosbuild.sh performs cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h, but as far as I can see in SDL_config.h there’s already a conditional compile for that file:

#elif defined(__IPHONEOS__)
#include "SDL_config_iphoneos.h"

I don’t own a Mac myself at all, but I know a guy who’s interested in also making sure that the bindings work well with Mac and iOS. If there’s some obvious reason for this header file swapping thing that a seasoned iOS dev would understand my apologies in advance.

Third Question: Dynamic API
According to the Dynamic API Readme it seems like, at least with SDL2-2.0.9 or later, it’s entirely fine to just always static link to SDL2 as long as you leave the Dynamic API feature enabled. Is this a correct assessment and sane default compilation style?