diff --git a/CHANGES.md b/CHANGES.md index 367deda0..0e1e05e4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,11 @@ ## Unreleased + - Fixed build script error with development GDAL versions + + + - + ## 0.16 - **Breaking**: `Dataset::close` now consumes `self` diff --git a/build.rs b/build.rs index 6303f68b..8e11ed96 100644 --- a/build.rs +++ b/build.rs @@ -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: diff --git a/gdal-sys/build.rs b/gdal-sys/build.rs index fcd3c9ff..fcccea4a 100644 --- a/gdal-sys/build.rs +++ b/gdal-sys/build.rs @@ -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); } }