Skip to content

Commit 9aca22c

Browse files
committed
Assume tiff to avoid unnecessary libproj builds.
This removes the bundled_proj_tiff feature (added in https://github.com/georust/proj/pull/58/files), and we now assume all proj installations support tiff. Meaning the user either: 1. If the user has a recent system installation of libproj, it supports libtiff. 2. Else if the user has no recent system installation of libproj, build.rs will compile it from source, which requires linking in libtiff The previous "bundled_proj_tiff" unfortunately conflated needing tiff with needing to build from source, even though most system proj installs will already support tiff. proj-sys requires a compatible libproj installation. build.rs will either use a pre-existing system installation of libproj or build libproj from source. Building from source takes a while, so it's preferable to use the system installation if it's compatible. tiff support is used by libproj's network grid. tiff support is required by libproj by default, though it's possible to opt out. When Apple first released aarch64 (M1), libtiff was failing to build, so as a stop gap we added a "bundled_proj_tiff" feature which: 1. forced a from-source build 2. explicitly enabled tiff support, else tiff support would be disabled, allowing us to build the proj crate on aarch64 The underlying build failures in libtiff have now been fixed, so the original motivation for this feature no longer exists. There was a cost associated with keeping it - unnecessarily triggering source builds from, e.g. georust/geo crate, whose `proj/network` feature wants to ensure tiff is enabled. Given that most installations will have this feature, I think it will give most of our users a better experience if we can avoid the compile. To be clear, there is potential downside with this approach. It's still conceivable that environments exists where tiff is not, or can not be installed, but weighing that against the more common case of having libproj installed with the default configuration, and I think this approach wins. If this poops on too many parties, we can revisit something like the former behavior in a way that's less deleterious to the default use case - e.g. have a `tiff` feature that will still use the local install if it supports tiff.
1 parent 801f653 commit 9aca22c

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

.github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
- "--features \"network bundled_proj\""
4040
- "--features \"network geo-types\""
4141
- "--features \"bundled_proj geo-types\""
42-
- "--features \"bundled_proj bundled_proj_tiff \""
4342
- "--features \"network bundled_proj geo-types\""
4443
container:
4544
image: ${{ matrix.container_image }}

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ members = ["proj-sys"]
2626
[features]
2727
default = ["geo-types"]
2828
bundled_proj = [ "proj-sys/bundled_proj" ]
29-
bundled_proj_tiff = [ "proj-sys/bundled_proj_tiff" ]
3029
pkg_config = [ "proj-sys/pkg_config" ]
31-
network = ["bundled_proj_tiff", "reqwest"]
30+
network = ["reqwest"]
3231

3332
[dev-dependencies]
3433
approx = "0.3"

proj-sys/CHANGES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# UNRELEASED
2+
3+
- BREAKING: Remove `bundled_proj_tiff` feature and assume system libproj has
4+
the default enabled tiff support. Otherwise, the current setup would
5+
unnecessarily build libproj from source in some cases, e.g. the geo crate's
6+
proj network integration would compile libproj from source.
7+
- <https://github.com/georust/proj/pull/92>
8+
19
# 0.20.1
210
- Fix docs to refer to correct libproj version
311

proj-sys/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ nobuild = []
2424
bundled_proj = []
2525
# `pkg_config` feature is deprecated and does nothing
2626
pkg_config = []
27-
bundled_proj_tiff = ["bundled_proj"]
2827

2928
[package.metadata.docs.rs]
3029
features = [ "nobuild" ] # This feature will be enabled during the docs.rs build

proj-sys/build.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,15 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
9595
config.define("BUILD_PROJINFO", "OFF");
9696
config.define("BUILD_PROJSYNC", "OFF");
9797
config.define("ENABLE_CURL", "OFF");
98-
let tiff_support = cfg!(feature = "bundled_proj_tiff");
99-
config.define("ENABLE_TIFF", if tiff_support { "ON" } else { "OFF" });
10098
let proj = config.build();
10199
// Tell cargo to tell rustc to link libproj, and where to find it
102100
// libproj will be built in $OUT_DIR/lib
103-
101+
104102
//proj likes to create proj_d when configured as debug and on MSVC, so link to that one if it exists
105103
if proj.join("lib").join("proj_d.lib").exists() {
106-
println!("cargo:rustc-link-lib=static=proj_d");
104+
println!("cargo:rustc-link-lib=static=proj_d");
107105
} else {
108-
println!("cargo:rustc-link-lib=static=proj");
106+
println!("cargo:rustc-link-lib=static=proj");
109107
}
110108
println!(
111109
"cargo:rustc-link-search=native={}",
@@ -121,9 +119,7 @@ fn build_from_source() -> Result<std::path::PathBuf, Box<dyn std::error::Error>>
121119
);
122120
// The PROJ library needs SQLite and the C++ standard library.
123121
println!("cargo:rustc-link-lib=dylib=sqlite3");
124-
if tiff_support {
125-
println!("cargo:rustc-link-lib=dylib=tiff");
126-
}
122+
println!("cargo:rustc-link-lib=dylib=tiff");
127123
if cfg!(target_os = "linux") {
128124
println!("cargo:rustc-link-lib=dylib=stdc++");
129125
} else if cfg!(target_os = "macos") {

0 commit comments

Comments
 (0)