Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around GDAL dev version numbering #439

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

- Fixed build script error with development GDAL versions


- <https://github.com/georust/gdal/pull/439>

## 0.16

- **Breaking**: `Dataset::close` now consumes `self`
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{env, str::FromStr};

fn main() {
let gdal_version_string = env::var("DEP_GDAL_VERSION_NUMBER")
.expect("The GDAL-SYS crate must emit the version of libgdal via cargo:version_number");
.expect("The gdal-sys crate must emit the version of libgdal via cargo:version_number");
println!("GDAL version string: \"{gdal_version_string}\"");

// this version string is the result of:
Expand Down
10 changes: 9 additions & 1 deletion gdal-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,15 @@ fn main() {
include_paths.push(dir.to_str().unwrap().to_string());
}
if version.is_none() {
if let Ok(pkg_version) = Version::parse(gdal.version.trim()) {
// development GDAL versions look like 3.7.2dev, which is not valid semver
let mut version_string = gdal.version.trim().to_string();
if let Some(idx) = version_string.rfind(|c: char| c.is_ascii_digit()) {
if idx + 1 < version_string.len() && !version_string[idx + 1..].starts_with('-') {
version_string.insert(idx + 1, '-');
}
}

if let Ok(pkg_version) = Version::parse(&version_string) {
version.replace(pkg_version);
}
}
Expand Down