Skip to content

Commit

Permalink
Provide a bundled flag for gdal-sys
Browse files Browse the repository at this point in the history
This commit introduces a new `gdal-src` crate which bundles gdal and
builds by default a minimal version from source via `build.rs`. It
exposes feature flags for many drivers and adds the neccesary
dependencies to keep the build fully static.

Fixes #465
  • Loading branch information
weiznich committed Jan 30, 2024
1 parent 87497bf commit 8db29ac
Show file tree
Hide file tree
Showing 10 changed files with 679 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "gdal-src/source"]
path = gdal-src/source
url = https://github.com/OSGeo/gdal
rev = 654f4907abbbf6bf4226d58a8c067d134eaf3ce9
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes

## Unreleased
- Add a `bundled` feature for `gdal-sys` that allows to build and statically link a minimal bundled version of gdal during `cargo build`
- Add `DriverIterator` format to iterate through drivers, as well as `DriverManager::all()` method that provides the iterator.
- <https://github.com/georust/gdal/pull/512>

Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ tempfile = "3.8"
arrow2 = "0.18"

[workspace]
members = ["gdal-sys"]
members = ["gdal-src", "gdal-sys"]

# docs.rs-specific configuration
[package.metadata.docs.rs]
# include `array` feature in documentation
features = ["array"]
# define attribute `docsrs` for feature badges
rustdoc-args = ["--cfg", "docsrs"]


[patch.crates-io]
proj-sys = { git = "https://github.com/GiGainfosystems/proj", rev = "dc67b5afc17bc7d330371e4406dffd65cf9321cd" }
libsqlite3-sys = { git = "https://github.com/rusqlite/rusqlite/", rev = "42a82fb" }
pq-sys = { git = "https://github.com/sgrif/pq-sys", rev = "77e6729" }
314 changes: 314 additions & 0 deletions gdal-src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
[package]
name = "gdal-src"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
proj-sys = { version = "0.23.2", features = ["bundled_proj"] }
libsqlite3-sys = { version = "0.27.0", features = ["bundled"], optional = true }
hdf5-src = { version = "0.8.1", optional = true, features = ["hl"] }
hdf5-sys = { version = "0.8.1", optional = true, features = ["static"] }
netcdf-src = { version = "0.3.2", optional = true }
pq-src = { version = "0.1", optional = true }
curl-sys = { version = "0.4.70", features = ["static-curl"], optional = true }
libz-sys = { version = "1.1.15", features = ["static"], optional = true }

[build-dependencies]
cmake = "0.1.50"

[features]
default = []
enable_all_drivers = [
"enable_all_internal",
"DRIVER_SQLITE",
"DRIVER_GPKG",
"DRIVER_VFK",
"DRIVER_HDF5",
"DRIVER_NETCDF",
"DRIVER_AMIGOCLOUD",
"DRIVER_CARTO",
"DRIVER_DAAS",
"DRIVER_EEDA",
"DRIVER_ELASTIC",
"DRIVER_NGW",
"DRIVER_OGCAPI",
"DRIVER_PLMOSAIC",
"DRIVER_WCS",
"DRIVER_WMS",
"DRIVER_WMTS",
"DRIVER_PG",
"DRIVER_POSTGIS_RASTER",
]

enable_all_internal = [
# ogr internal,
"DRIVER_AVC",
"DRIVER_CAD",
"DRIVER_CSV",
"DRIVER_DGN",
"DRIVER_DXF",
"DRIVER_EDIGEO",
"DRIVER_FLATGEOBUF",
"DRIVER_GEOCONCEPT",
"DRIVER_GEOJSON",
"DRIVER_GMT",
"DRIVER_GTFS",
"DRIVER_JSONFG",
"DRIVER_MAPML",
"DRIVER_OPENFILEGDB",
"DRIVER_PGDUMP",
"DRIVER_NTF",
"DRIVER_S57",
"DRIVER_SELAFIN",
"DRIVER_SHAPE",
"DRIVER_SXF",
"DRIVER_TAB",
"DRIVER_TIGER",
"DRIVER_VDV",
"DRIVER_WASP",
# gdal internal
"DRIVER_AAIGRID",
"DRIVER_ADRG",
"DRIVER_AIGRID",
"DRIVER_AIRSAR",
"DRIVER_BLX",
"DRIVER_BMP",
"DRIVER_BSB",
"DRIVER_CALS",
"DRIVER_CEOS",
"DRIVER_COASP",
"DRIVER_COSAR",
"DRIVER_CTG",
"DRIVER_DIMAP",
"DRIVER_DTED",
"DRIVER_ELAS",
"DRIVER_ENVISAT",
"DRIVER_ERS",
"DRIVER_FIT",
"DRIVER_GFF",
"DRIVER_GIF",
"DRIVER_GRIB",
"DRIVER_GSG",
"DRIVER_GTIFF",
"DRIVER_GXF",
"DRIVER_HF2",
"DRIVER_HFA",
"DRIVER_ILWIS",
"DRIVER_IRIS",
"DRIVER_JAXAPALSAR",
"DRIVER_JDEM",
"DRIVER_JPEG",
"DRIVER_KMLSUPEROVERLAY",
"DRIVER_L1B",
"DRIVER_LEVELLER",
"DRIVER_MAP",
"DRIVER_MRF",
"DRIVER_MSGN",
"DRIVER_NGSGEOID",
"DRIVER_NIFT",
"DRIVER_NORTHWOOD",
"DRIVER_OZI",
"DRIVER_PCIDSK",
"DRIVER_PCRASTER",
"DRIVER_PNG",
"DRIVER_PRF",
"DRIVER_R",
"DRIVER_RAW",
"DRIVER_RIK",
"DRIVER_RMF",
"DRIVER_RS2",
"DRIVER_SAFE",
"DRIVER_SAGA",
"DRIVER_SAR_CEOS",
"DRIVER_SENTINEL2",
"DRIVER_SGI",
"DRIVER_SIGDEM",
"DRIVER_SRTMHGT",
"DRIVER_STACIT",
"DRIVER_STACTA",
"DRIVER_TERRAGEN",
"DRIVER_TGA",
"DRIVER_TIL",
"DRIVER_TSX",
"DRIVER_USGSDEM",
"DRIVER_XPM",
"DRIVER_XYZ",
"DRIVER_ZMAP",

# ogr and gdal
"DRIVER_IDRISI",
"DRIVER_PDS",
"DRIVER_SDTS",
"DRIVER_VRT",
"DRIVER_MEM",
]

# ogr internal
DRIVER_AVC = []
DRIVER_CAD = []
DRIVER_CSV = []
DRIVER_DGN = []
DRIVER_DXF = []
DRIVER_EDIGEO = []
DRIVER_FLATGEOBUF = []
DRIVER_GEOCONCEPT = []
DRIVER_GEOJSON = []
DRIVER_GMT = []
DRIVER_GTFS = []
DRIVER_JSONFG = []
DRIVER_MAPML = []
DRIVER_OPENFILEGDB = []
DRIVER_PGDUMP = []
DRIVER_NTF = []
DRIVER_S57 = []
DRIVER_SELAFIN = []
DRIVER_SHAPE = []
DRIVER_SXF = []
DRIVER_TAB = []
DRIVER_TIGER = []
DRIVER_VDV = []
DRIVER_WASP = []

#gdal internal
DRIVER_AAIGRID = []
DRIVER_ADRG = []
DRIVER_AIGRID = []
DRIVER_AIRSAR = []
DRIVER_BLX = []
DRIVER_BMP = []
DRIVER_BSB = []
DRIVER_CALS = []
DRIVER_CEOS = []
DRIVER_COASP = []
DRIVER_COSAR = []
DRIVER_CTG = []
DRIVER_DIMAP = []
DRIVER_DTED = []
DRIVER_ELAS = []
DRIVER_ENVISAT =[]
DRIVER_ERS = []
DRIVER_FIT = []
DRIVER_GFF = []
DRIVER_GIF = []
DRIVER_GRIB = []
DRIVER_GSG = []
DRIVER_GTIFF = []
DRIVER_GXF = []
DRIVER_HF2 = []
DRIVER_HFA = []
DRIVER_ILWIS = []
DRIVER_IRIS = []
DRIVER_JAXAPALSAR = []
DRIVER_JDEM = []
DRIVER_JPEG = []
DRIVER_KMLSUPEROVERLAY = []
DRIVER_L1B = []
DRIVER_LEVELLER = []
DRIVER_MAP = []
DRIVER_MRF = []
DRIVER_MSGN = []
DRIVER_NGSGEOID = []
DRIVER_NIFT = []
DRIVER_NORTHWOOD = []
DRIVER_OZI = []
DRIVER_PCIDSK = []
DRIVER_PCRASTER = []
DRIVER_PNG = []
DRIVER_PRF = []
DRIVER_R = []
DRIVER_RAW = []
DRIVER_RIK = []
DRIVER_RMF = []
DRIVER_RS2 = []
DRIVER_SAFE = []
DRIVER_SAGA = []
DRIVER_SAR_CEOS = []
DRIVER_SENTINEL2 = []
DRIVER_SGI = []
DRIVER_SIGDEM = []
DRIVER_SRTMHGT = []
DRIVER_STACIT = []
DRIVER_STACTA = []
DRIVER_TERRAGEN = []
DRIVER_TGA = []
DRIVER_TIL = []
DRIVER_TSX = []
DRIVER_USGSDEM = []
DRIVER_XPM = []
DRIVER_XYZ = []
DRIVER_ZMAP = []

# ogr and gdal
DRIVER_IDRISI = []
DRIVER_PDS = []
DRIVER_SDTS = []
DRIVER_VRT = []
DRIVER_MEM = []

# external

# sqlite
DRIVER_SQLITE = ["dep:libsqlite3-sys"]
DRIVER_GPKG = ["DRIVER_SQLITE"]
DRIVER_VFK = ["DRIVER_SQLITE"]
DRIVER_RASTERLITE = [] # unclear how to handle that

# curl
DRIVER_AMIGOCLOUD = ["curl-sys"]
DRIVER_CARTO = ["curl-sys"]
DRIVER_DAAS = ["curl-sys"]
DRIVER_EEDA = ["curl-sys"]
DRIVER_ELASTIC = ["curl-sys"]
DRIVER_NGW = ["curl-sys"]

DRIVER_OGCAPI = ["curl-sys"]
DRIVER_PLMOSAIC = ["curl-sys"]
DRIVER_WCS = ["curl-sys"]
DRIVER_WMS = ["curl-sys"]
DRIVER_WMTS = ["curl-sys"]

# libexpat
# (there exists no expat-sys crate)
# DRIVER_GEORSS = []
# DRIVER_GML = []
# DRIVER_GPSBABEL = []
# DRIVER_GPX = []
# DRIVER_JML = []
# DRIVER_KML = []
# DRIVER_LVBAG = []
# DRIVER_ODS = []
# DRIVER_SVG = []
# DRIVER_XLSX = []

# libmysqlclient
# (there is currently no bundling support in libmysqlclient)
# DRIVER_MYSQL = []

# libpq
DRIVER_PG = ["dep:pq-src"]
DRIVER_POSTGIS_RASTER = ["DRIVER_PG"]

# libhdf5
DRIVER_HDF5 = ["dep:hdf5-src", "dep:libz-sys"]

# libnetcdf
DRIVER_NETCDF = ["dep:netcdf-src", "DRIVER_HDF5", "dep:hdf5-sys"]

# poppler
#DRIVER_PDF = []

# combined
# these miss at least one dependency
# DRIVER_MVT = [] # requires sqlite + geos
# DRIVER_OSM = [] # requires sqlite + libexpat
# DRIVER_ZARR = [] # requires liblz4, libxz, libzstd and libblocs
# DRIVER_MBTILES = ["DRIVER_SQLITE", "DRIVER_MVT"] # also requires mvt (so geos)
# DRIVER_PMTILES = ["DRIVER_MVT"] # depends on driver_mvt
# DRIVER_CSW = ["curl-sys", "DRIVER_GML"] # depends on gml driver
# DRIVER_WFS = ["curl-sys", "DRIVER_GML"]

# unclear
DRIVER_HTTP = []
DRIVER_ARG = []
Loading

0 comments on commit 8db29ac

Please sign in to comment.