Skip to content

Commit

Permalink
Work around GDAL dev version numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Sep 23, 2023
1 parent 43d23d2 commit be0a362
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit be0a362

Please sign in to comment.