Skip to content

Commit 6120416

Browse files
committed
Depend on libsqlite3-sys for bundled builds
This commit adds an optional dependency to libsqlite3-sys to provide a bundled version of libsqlite3 as well instead of relying on a system provided version.
1 parent ae91aba commit 6120416

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

proj-sys/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ links = "proj"
1212
rust-version = "1.70"
1313

1414
[dependencies]
15+
libsqlite3-sys = { version = "0.28", features = ["bundled"], optional = true }
1516

1617
[build-dependencies]
1718
bindgen = "0.68.1"
@@ -22,7 +23,7 @@ tar = "0.4.40"
2223

2324
[features]
2425
nobuild = []
25-
bundled_proj = []
26+
bundled_proj = ["dep:libsqlite3-sys"]
2627
# `pkg_config` feature is deprecated and does nothing
2728
pkg_config = []
2829
network = ["tiff"]

proj-sys/build.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
8080
}
8181
}
8282

83-
// NOTE: The PROJ build expects Sqlite3 to be present on the system.
8483
let path = "PROJSRC/proj-9.3.1.tar.gz";
8584
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
8685
let tar_gz = File::open(path)?;
@@ -98,6 +97,14 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
9897
config.define("BUILD_PROJINFO", "OFF");
9998
config.define("BUILD_PROJSYNC", "OFF");
10099
config.define("ENABLE_CURL", "OFF");
100+
config.define(
101+
"SQLITE3_INCLUDE_DIR",
102+
std::env::var("DEP_SQLITE3_INCLUDE").expect("This is set by libsqlite3-sys"),
103+
);
104+
config.define(
105+
"SQLITE3_LIBRARY",
106+
format!("{}/libsqlite3.a", std::env::var("DEP_SQLITE3_LIB_DIR").unwrap()),
107+
);
101108

102109
if cfg!(feature = "tiff") {
103110
eprintln!("enabling tiff support");
@@ -132,9 +139,6 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
132139
&out_path.join("build/lib").display()
133140
);
134141

135-
// The PROJ library needs SQLite and the C++ standard library.
136-
println!("cargo:rustc-link-lib=dylib=sqlite3");
137-
138142
if cfg!(feature = "tiff") {
139143
// On platforms like apples aarch64, users are likely to have installed libtiff with homebrew,
140144
// which isn't in the default search path, so try to determine path from pkg-config

proj-sys/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
//! implement your own set of callbacks if you wish to make use of them (see the
2929
//! [`proj`](https://crates.io/crates/proj) crate for an example).
3030
31+
#[cfg(feature = "bundled_proj")]
32+
extern crate libsqlite3_sys;
33+
3134
#[cfg(not(feature = "nobuild"))]
3235
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
3336

0 commit comments

Comments
 (0)