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 22, 2023
1 parent 43d23d2 commit 834b747
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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
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 834b747

Please sign in to comment.