Skip to content

Commit 54ef44f

Browse files
committed
Provide a bundled flag for gdal-sys
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
1 parent 87497bf commit 54ef44f

File tree

10 files changed

+686
-2
lines changed

10 files changed

+686
-2
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "gdal-src/source"]
2+
path = gdal-src/source
3+
url = https://github.com/OSGeo/gdal
4+
rev = 654f4907abbbf6bf4226d58a8c067d134eaf3ce9

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changes
22

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

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ tempfile = "3.8"
3636
arrow2 = "0.18"
3737

3838
[workspace]
39-
members = ["gdal-sys"]
39+
members = ["gdal-src", "gdal-sys"]
4040

4141
# docs.rs-specific configuration
4242
[package.metadata.docs.rs]
4343
# include `array` feature in documentation
4444
features = ["array"]
4545
# define attribute `docsrs` for feature badges
4646
rustdoc-args = ["--cfg", "docsrs"]
47+
48+
49+
[patch.crates-io]
50+
proj-sys = { git = "https://github.com/GiGainfosystems/proj", rev = "dc67b5afc17bc7d330371e4406dffd65cf9321cd" }
51+
libsqlite3-sys = { git = "https://github.com/rusqlite/rusqlite/", rev = "42a82fb" }
52+
pq-sys = { git = "https://github.com/sgrif/pq-sys", rev = "77e6729" }

gdal-src/Cargo.toml

Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
[package]
2+
name = "gdal-src"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
proj-sys = { version = "0.23.2", features = ["bundled_proj"] }
10+
libsqlite3-sys = { version = "0.27.0", features = ["bundled"], optional = true }
11+
hdf5-src = { version = "0.8.1", optional = true, features = ["hl"] }
12+
hdf5-sys = { version = "0.8.1", optional = true, features = ["static"] }
13+
netcdf-src = { version = "0.3.2", optional = true }
14+
pq-src = { version = "0.1", optional = true }
15+
curl-sys = { version = "0.4.70", features = ["static-curl"], optional = true }
16+
libz-sys = { version = "1.1.15", features = ["static"], optional = true }
17+
18+
[build-dependencies]
19+
cmake = "0.1.50"
20+
21+
[features]
22+
default = []
23+
enable_all_drivers = [
24+
"enable_all_internal",
25+
"DRIVER_SQLITE",
26+
"DRIVER_GPKG",
27+
"DRIVER_VFK",
28+
"DRIVER_HDF5",
29+
"DRIVER_NETCDF",
30+
"DRIVER_AMIGOCLOUD",
31+
"DRIVER_CARTO",
32+
"DRIVER_DAAS",
33+
"DRIVER_EEDA",
34+
"DRIVER_ELASTIC",
35+
"DRIVER_NGW",
36+
"DRIVER_OGCAPI",
37+
"DRIVER_PLMOSAIC",
38+
"DRIVER_WCS",
39+
"DRIVER_WMS",
40+
"DRIVER_WMTS",
41+
"DRIVER_PG",
42+
"DRIVER_POSTGIS_RASTER",
43+
]
44+
45+
enable_all_internal = [
46+
# ogr internal,
47+
"DRIVER_AVC",
48+
"DRIVER_CAD",
49+
"DRIVER_CSV",
50+
"DRIVER_DGN",
51+
"DRIVER_DXF",
52+
"DRIVER_EDIGEO",
53+
"DRIVER_FLATGEOBUF",
54+
"DRIVER_GEOCONCEPT",
55+
"DRIVER_GEOJSON",
56+
"DRIVER_GMT",
57+
"DRIVER_GTFS",
58+
"DRIVER_JSONFG",
59+
"DRIVER_MAPML",
60+
"DRIVER_OPENFILEGDB",
61+
"DRIVER_PGDUMP",
62+
"DRIVER_NTF",
63+
"DRIVER_S57",
64+
"DRIVER_SELAFIN",
65+
"DRIVER_SHAPE",
66+
"DRIVER_SXF",
67+
"DRIVER_TAB",
68+
"DRIVER_TIGER",
69+
"DRIVER_VDV",
70+
"DRIVER_WASP",
71+
# gdal internal
72+
"DRIVER_AAIGRID",
73+
"DRIVER_ADRG",
74+
"DRIVER_AIGRID",
75+
"DRIVER_AIRSAR",
76+
"DRIVER_BLX",
77+
"DRIVER_BMP",
78+
"DRIVER_BSB",
79+
"DRIVER_CALS",
80+
"DRIVER_CEOS",
81+
"DRIVER_COASP",
82+
"DRIVER_COSAR",
83+
"DRIVER_CTG",
84+
"DRIVER_DIMAP",
85+
"DRIVER_DTED",
86+
"DRIVER_ELAS",
87+
"DRIVER_ENVISAT",
88+
"DRIVER_ERS",
89+
"DRIVER_FIT",
90+
"DRIVER_GFF",
91+
"DRIVER_GIF",
92+
"DRIVER_GRIB",
93+
"DRIVER_GSG",
94+
"DRIVER_GTIFF",
95+
"DRIVER_GXF",
96+
"DRIVER_HF2",
97+
"DRIVER_HFA",
98+
"DRIVER_ILWIS",
99+
"DRIVER_IRIS",
100+
"DRIVER_JAXAPALSAR",
101+
"DRIVER_JDEM",
102+
"DRIVER_JPEG",
103+
"DRIVER_KMLSUPEROVERLAY",
104+
"DRIVER_L1B",
105+
"DRIVER_LEVELLER",
106+
"DRIVER_MAP",
107+
"DRIVER_MRF",
108+
"DRIVER_MSGN",
109+
"DRIVER_NGSGEOID",
110+
"DRIVER_NIFT",
111+
"DRIVER_NORTHWOOD",
112+
"DRIVER_OZI",
113+
"DRIVER_PCIDSK",
114+
"DRIVER_PCRASTER",
115+
"DRIVER_PNG",
116+
"DRIVER_PRF",
117+
"DRIVER_R",
118+
"DRIVER_RAW",
119+
"DRIVER_RIK",
120+
"DRIVER_RMF",
121+
"DRIVER_RS2",
122+
"DRIVER_SAFE",
123+
"DRIVER_SAGA",
124+
"DRIVER_SAR_CEOS",
125+
"DRIVER_SENTINEL2",
126+
"DRIVER_SGI",
127+
"DRIVER_SIGDEM",
128+
"DRIVER_SRTMHGT",
129+
"DRIVER_STACIT",
130+
"DRIVER_STACTA",
131+
"DRIVER_TERRAGEN",
132+
"DRIVER_TGA",
133+
"DRIVER_TIL",
134+
"DRIVER_TSX",
135+
"DRIVER_USGSDEM",
136+
"DRIVER_XPM",
137+
"DRIVER_XYZ",
138+
"DRIVER_ZMAP",
139+
140+
# ogr and gdal
141+
"DRIVER_IDRISI",
142+
"DRIVER_PDS",
143+
"DRIVER_SDTS",
144+
"DRIVER_VRT",
145+
"DRIVER_MEM",
146+
]
147+
148+
# ogr internal
149+
DRIVER_AVC = []
150+
DRIVER_CAD = []
151+
DRIVER_CSV = []
152+
DRIVER_DGN = []
153+
DRIVER_DXF = []
154+
DRIVER_EDIGEO = []
155+
DRIVER_FLATGEOBUF = []
156+
DRIVER_GEOCONCEPT = []
157+
DRIVER_GEOJSON = []
158+
DRIVER_GMT = []
159+
DRIVER_GTFS = []
160+
DRIVER_JSONFG = []
161+
DRIVER_MAPML = []
162+
DRIVER_OPENFILEGDB = []
163+
DRIVER_PGDUMP = []
164+
DRIVER_NTF = []
165+
DRIVER_S57 = []
166+
DRIVER_SELAFIN = []
167+
DRIVER_SHAPE = []
168+
DRIVER_SXF = []
169+
DRIVER_TAB = []
170+
DRIVER_TIGER = []
171+
DRIVER_VDV = []
172+
DRIVER_WASP = []
173+
174+
#gdal internal
175+
DRIVER_AAIGRID = []
176+
DRIVER_ADRG = []
177+
DRIVER_AIGRID = []
178+
DRIVER_AIRSAR = []
179+
DRIVER_BLX = []
180+
DRIVER_BMP = []
181+
DRIVER_BSB = []
182+
DRIVER_CALS = []
183+
DRIVER_CEOS = []
184+
DRIVER_COASP = []
185+
DRIVER_COSAR = []
186+
DRIVER_CTG = []
187+
DRIVER_DIMAP = []
188+
DRIVER_DTED = []
189+
DRIVER_ELAS = []
190+
DRIVER_ENVISAT =[]
191+
DRIVER_ERS = []
192+
DRIVER_FIT = []
193+
DRIVER_GFF = []
194+
DRIVER_GIF = []
195+
DRIVER_GRIB = []
196+
DRIVER_GSG = []
197+
DRIVER_GTIFF = []
198+
DRIVER_GXF = []
199+
DRIVER_HF2 = []
200+
DRIVER_HFA = []
201+
DRIVER_ILWIS = []
202+
DRIVER_IRIS = []
203+
DRIVER_JAXAPALSAR = []
204+
DRIVER_JDEM = []
205+
DRIVER_JPEG = []
206+
DRIVER_KMLSUPEROVERLAY = []
207+
DRIVER_L1B = []
208+
DRIVER_LEVELLER = []
209+
DRIVER_MAP = []
210+
DRIVER_MRF = []
211+
DRIVER_MSGN = []
212+
DRIVER_NGSGEOID = []
213+
DRIVER_NIFT = []
214+
DRIVER_NORTHWOOD = []
215+
DRIVER_OZI = []
216+
DRIVER_PCIDSK = []
217+
DRIVER_PCRASTER = []
218+
DRIVER_PNG = []
219+
DRIVER_PRF = []
220+
DRIVER_R = []
221+
DRIVER_RAW = []
222+
DRIVER_RIK = []
223+
DRIVER_RMF = []
224+
DRIVER_RS2 = []
225+
DRIVER_SAFE = []
226+
DRIVER_SAGA = []
227+
DRIVER_SAR_CEOS = []
228+
DRIVER_SENTINEL2 = []
229+
DRIVER_SGI = []
230+
DRIVER_SIGDEM = []
231+
DRIVER_SRTMHGT = []
232+
DRIVER_STACIT = []
233+
DRIVER_STACTA = []
234+
DRIVER_TERRAGEN = []
235+
DRIVER_TGA = []
236+
DRIVER_TIL = []
237+
DRIVER_TSX = []
238+
DRIVER_USGSDEM = []
239+
DRIVER_XPM = []
240+
DRIVER_XYZ = []
241+
DRIVER_ZMAP = []
242+
243+
# ogr and gdal
244+
DRIVER_IDRISI = []
245+
DRIVER_PDS = []
246+
DRIVER_SDTS = []
247+
DRIVER_VRT = []
248+
DRIVER_MEM = []
249+
250+
# external
251+
252+
# sqlite
253+
DRIVER_SQLITE = ["dep:libsqlite3-sys"]
254+
DRIVER_GPKG = ["DRIVER_SQLITE"]
255+
DRIVER_VFK = ["DRIVER_SQLITE"]
256+
DRIVER_RASTERLITE = [] # unclear how to handle that
257+
258+
# curl
259+
DRIVER_AMIGOCLOUD = ["curl-sys"]
260+
DRIVER_CARTO = ["curl-sys"]
261+
DRIVER_DAAS = ["curl-sys"]
262+
DRIVER_EEDA = ["curl-sys"]
263+
DRIVER_ELASTIC = ["curl-sys"]
264+
DRIVER_NGW = ["curl-sys"]
265+
266+
DRIVER_OGCAPI = ["curl-sys"]
267+
DRIVER_PLMOSAIC = ["curl-sys"]
268+
DRIVER_WCS = ["curl-sys"]
269+
DRIVER_WMS = ["curl-sys"]
270+
DRIVER_WMTS = ["curl-sys"]
271+
272+
# libexpat
273+
# (there exists no expat-sys crate)
274+
# DRIVER_GEORSS = []
275+
# DRIVER_GML = []
276+
# DRIVER_GPSBABEL = []
277+
# DRIVER_GPX = []
278+
# DRIVER_JML = []
279+
# DRIVER_KML = []
280+
# DRIVER_LVBAG = []
281+
# DRIVER_ODS = []
282+
# DRIVER_SVG = []
283+
# DRIVER_XLSX = []
284+
285+
# libmysqlclient
286+
# (there is currently no bundling support in libmysqlclient)
287+
# DRIVER_MYSQL = []
288+
289+
# libpq
290+
DRIVER_PG = ["dep:pq-src"]
291+
DRIVER_POSTGIS_RASTER = ["DRIVER_PG"]
292+
293+
# libhdf5
294+
DRIVER_HDF5 = ["dep:hdf5-src", "dep:libz-sys"]
295+
296+
# libnetcdf
297+
DRIVER_NETCDF = ["dep:netcdf-src", "DRIVER_HDF5", "dep:hdf5-sys"]
298+
299+
# poppler
300+
#DRIVER_PDF = []
301+
302+
# combined
303+
# these miss at least one dependency
304+
# DRIVER_MVT = [] # requires sqlite + geos
305+
# DRIVER_OSM = [] # requires sqlite + libexpat
306+
# DRIVER_ZARR = [] # requires liblz4, libxz, libzstd and libblocs
307+
# DRIVER_MBTILES = ["DRIVER_SQLITE", "DRIVER_MVT"] # also requires mvt (so geos)
308+
# DRIVER_PMTILES = ["DRIVER_MVT"] # depends on driver_mvt
309+
# DRIVER_CSW = ["curl-sys", "DRIVER_GML"] # depends on gml driver
310+
# DRIVER_WFS = ["curl-sys", "DRIVER_GML"]
311+
312+
# unclear
313+
DRIVER_HTTP = []
314+
DRIVER_ARG = []

0 commit comments

Comments
 (0)