georust / gdal

Rust bindings for GDAL
https://crates.io/crates/gdal
MIT License
339 stars 92 forks source link

Provide a `bundled` feature #465

Open weiznich opened 8 months ago

weiznich commented 8 months ago

This is mostly a feature request. Many *-sys crates provide a bundled or vendored feature that builds and links static version of the corresponding C dependency as part of the build process. It would be great if gdal would provide a similar feature as well.

The main motivation for such a feature is that it would greatly simplify setting up the development/deploy environment as everything would be build as part of the build process.

lnicola commented 8 months ago

I'm not sure how feasible this is. GDAL can link to dozens of external libraries, and I don't think it reliably auto-detects all of them (haven't played much with the new CMake-based build system, though). Even if detection worked, you'd still have to install other libraries.

proj-sys managed to make it work, but it still depends on SQLite, libtiff and probably even cURL.

weiznich commented 7 months ago

I'm aware that gdal itself has quite a lot of external dependencies, as I've a local setup that statically links gdal anyway. What we do there is to disable as many of the external dependencies as possible. That's feasible for us as we don't require much of the optional functionality anyway.

For SQLlite it should be as simple as optionally including the libsqlite3-sys crate with the "bundled" feature behind a feature flag.

If bundling support is something that would be acceptable for the gdal crate as well I might give it a try someday and open a PR if that is successful.

lnicola commented 7 months ago

I think it would be nice to have, but I don't know how configuring it would ideally work. E.g. I'd find it sweet if I could build GDAL from source, but with the system SQLite.

metasim commented 7 months ago

We build GDAL from scratch all the time (we license the JPKAK driver). The new cmake system is much much better, particularly given it has a principled way of allowing you to override paths, settings, etc.

One thing I've never been able to do is statically link GDAL into Rust code. @weiznich Any tips/tricks you can share?

lnicola commented 7 months ago

IIRC static linking worked for me in the past, but I can't easily try it on my current distro because of a package (libgta) that's missing a static library.

weiznich commented 5 months ago

I've opened #517 That builds a more or less minimal version of gdal during cargo build. proj seems to be the only required external dependency, and there we can just use proj-sys + the bundled feature there to get a in tree build + static linking.