-
Notifications
You must be signed in to change notification settings - Fork 92
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
Detect GDAL version at build time / remove version features #92
Conversation
I guess there are some other tasks which should be addressed as separate issues:
|
I think that's a typo, shouldn't it be:
Otherwise it seems like To make sure I understand, this is equivalent to (but sometimes more ergonomic than) something like:
Is my understanding correct? It might be helpful to see them used in practice to evaluate their fitness. It looks like the code is still checking for the no-longer existing features, e.g.:
|
yes this is a typo.
This is correct. I don't think there is a more maintainable way to handle the versioning.
oh I must have missed that |
i replaced all the |
Which is accurate - there are no bindings for 3.1 currently. It might be nice to include the version number in the error message and some potential next steps. Maybe something like:
And when I run with bindgen:
Which are exactly the tests fixed by #86 (which I can rebase after this is merged). So, LGTM Nice work! |
Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
This PR changes the build.rs file for gdal-sys and introduces a build.rs for gdal. It makes conditional compilation for version handling more convenient. However, it is still not very pretty.
In gdal-sys, the lib version is now used to select the correct binding file. On Linux it is provided by pkg-config if the gdal lib is detected.
In gdal, the features for versions are removed. The actual GDAL version is requested from gdal-sys and the config parameters are generated.
The changes for gdal-sys are:
GDAL_VERSION
variable to be set).The changes for gdal are:
The following parameters are generated in gdals build.rs:
For example GDAL 3.1.2 will have: --cfg major_is_3 --cfg minor_is_1 --cfg patch_is_2 --cfg major_ge_2 --cfg major_ge_3 --cfg minor_ge_0 --cfg minor_ge_1 --cfg patch_ge_0 --cfg patch_ge_1 --cfg patch_ge_2
This allows to enable methods based on versions: