-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a new `gdal-src` crate which bundles gdal and builds a minimal version from source via `build.rs` Fixes #465
- Loading branch information
Showing
10 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[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"] } | ||
|
||
[build-dependencies] | ||
cmake = "0.1.50" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
fn main() { | ||
let sqlite3_include_dir = | ||
std::env::var("DEP_SQLITE3_INCLUDE").expect("This is set by libsqlite3-sys"); | ||
let sqlite3_lib_dir = std::env::var("DEP_SQLITE3_LIB_DIR").expect("set by libsqlite3-sys"); | ||
let proj_root = std::path::PathBuf::from(std::env::var("DEP_PROJ_ROOT").expect("set by proj-sys")); | ||
let proj_lib = if proj_root.join("lib").join("proj_d.lib").exists() { | ||
"proj_d.lib" | ||
} else if proj_root.join("lib").join("proj.lib").exists() { | ||
"proj.lib" | ||
} else { | ||
"libproj.a" | ||
}; | ||
|
||
let res = cmake::Config::new("source") | ||
.define("GDAL_BUILD_OPTIONAL_DRIVERS", "OFF") | ||
.define("OGR_BUILD_OPTIONAL_DRIVERS", "OFF") | ||
.define("GDAL_USE_INTERNAL_LIBS", "ON") | ||
.define("GDAL_USE_EXTERNAL_LIBS", "OFF") | ||
.define("BUILD_SHARED_LIBS", "OFF") | ||
.define("BUILD_STATIC_LIBS", "ON") | ||
.define("BUILD_APPS", "OFF") | ||
.define("BUILD_DOCS", "OFF") | ||
.define("BUILD_TESTING", "OFF") | ||
.define("BUILD_GMOCK", "OFF") | ||
.define("PROJ_INCLUDE_DIR", format!("{}/include", proj_root.display())) | ||
.define("PROJ_LIBRARY", format!("{}/lib/{proj_lib}", proj_root.display())) | ||
// enable the gpkg driver | ||
.define("GDAL_USE_SQLITE3", "ON") | ||
.define("SQLite3_INCLUDE_DIR", sqlite3_include_dir) | ||
.define("SQLite3_LIBRARY", format!("{sqlite3_lib_dir}/libsqlite3.a")) | ||
.define("OGR_ENABLE_DRIVER_GPKG", "ON") | ||
.pic(true) | ||
.build(); | ||
|
||
// sometimes it's lib and sometimes it's lib64 and sometimes `build/lib` | ||
let lib_dir = res.join("lib64"); | ||
println!( | ||
"cargo:rustc-link-search=native={}", | ||
lib_dir.to_str().unwrap() | ||
); | ||
let lib_dir = res.join("lib"); | ||
println!( | ||
"cargo:rustc-link-search=native={}", | ||
lib_dir.to_str().unwrap() | ||
); | ||
let lib_dir = res.join("build/lib"); | ||
println!( | ||
"cargo:rustc-link-search=native={}", | ||
lib_dir.to_str().unwrap() | ||
); | ||
|
||
//gdal likes to create gdal_d when configured as debug and on MSVC, so link to that one if it exists | ||
if res.join("lib").join("gdald.lib").exists() { | ||
println!("cargo:rustc-link-lib=static=gdald"); | ||
} else { | ||
println!("cargo:rustc-link-lib=static=gdal"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extern crate libsqlite3_sys; | ||
extern crate proj_sys; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters