Skip to content

Commit

Permalink
Merge #277
Browse files Browse the repository at this point in the history
277: Prebuilt bindings for GDAL 3.5 r=rmanoka a=MrMuetze

Hey 👋 

Here is my attempt to provide the prebuilt bindings for GDAL 3.5. I had a look at the previous PR for GDAL 3.4 and I hope I did everything in a similar way 😅 

Please let me know if any changes need to be made.

Co-authored-by: Björn Wieczoreck <bjoern.wieczoreck@giga-infosystems.com>
  • Loading branch information
bors[bot] and Björn Wieczoreck committed Jun 23, 2022
2 parents af69b1d + 912e9df commit 69e77cc
Show file tree
Hide file tree
Showing 3 changed files with 13,765 additions and 39 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Expand Up @@ -9,11 +9,11 @@ on:
workflow_dispatch:

jobs:
gdal_34:
name: "ci gdal-34"
gdal_35:
name: "ci gdal-35"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.4.0
image: osgeo/gdal:ubuntu-full-3.5.0

strategy:
matrix:
Expand Down Expand Up @@ -57,12 +57,11 @@ jobs:
with:
command: test
args: ${{ matrix.features }} --verbose

gdal_33:
name: "ci gdal-33"
gdal_34:
name: "ci gdal-34"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.3.0
image: osgeo/gdal:ubuntu-full-3.4.0

strategy:
matrix:
Expand Down Expand Up @@ -107,11 +106,11 @@ jobs:
command: test
args: ${{ matrix.features }} --verbose

gdal_32:
name: "ci gdal-32"
gdal_33:
name: "ci gdal-33"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.2.0
image: osgeo/gdal:ubuntu-full-3.3.0

strategy:
matrix:
Expand Down Expand Up @@ -156,11 +155,11 @@ jobs:
command: test
args: ${{ matrix.features }} --verbose

gdal_31:
name: "ci gdal-31"
gdal_32:
name: "ci gdal-32"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.1.0
image: osgeo/gdal:ubuntu-full-3.2.0

strategy:
matrix:
Expand Down
49 changes: 23 additions & 26 deletions build.rs
@@ -1,8 +1,8 @@
use semver::Version;
use std::str::FromStr;

#[cfg(docsrs)]
pub fn gdal_version_info(_key: &str) -> String {
"GDAL 3.2.0, released 2222/02/22".to_string()
"3020000".to_string()
}

#[cfg(not(docsrs))]
Expand All @@ -17,46 +17,43 @@ pub fn gdal_version_info(key: &str) -> String {
}

fn main() {
let gdal_version_string = gdal_version_info("--version"); // This expects GDAL to repond with "GDAL Semver , RELEASE DATE"
let gdal_version_string = gdal_version_info("VERSION_NUM");
println!("GDAL version string: \"{}\"", gdal_version_string);

let semver_substring =
&gdal_version_string[4..gdal_version_string.find(',').unwrap_or(12)].trim();
println!("GDAL semver string: \"{}\"", semver_substring);
// this version string is the result of:
// #define GDAL_COMPUTE_VERSION(maj,min,rev) ((maj)*1000000+(min)*10000+(rev)*100)
// so we can get the parts by doing the following
let gdal_version = i64::from_str(&gdal_version_string)
.expect("Could not convert gdal version string into number.");
let major = gdal_version / 1000000;
let minor = (gdal_version - major * 1000000) / 10000;
let patch = (gdal_version - major * 1000000 - minor * 10000) / 100;

let detected_version = Version::parse(semver_substring).expect("Could not parse gdal version!");

if detected_version.major < 2 {
if major < 2 {
panic!(
"The GDAL crate requires a GDAL version >= 2.0.0. Found {}",
detected_version
"The GDAL crate requires a GDAL version >= 2.0.0. Found {}.{}.{}",
major, minor, patch
);
}

println!("cargo:rustc-cfg=gdal_{}", detected_version.major);
println!(
"cargo:rustc-cfg=gdal_{}_{}",
detected_version.major, detected_version.minor
);
println!(
"cargo:rustc-cfg=gdal_{}_{}_{}",
detected_version.major, detected_version.minor, detected_version.patch
);
println!("cargo:rustc-cfg=gdal_{}", major);
println!("cargo:rustc-cfg=gdal_{}_{}", major, minor);
println!("cargo:rustc-cfg=gdal_{}_{}_{}", major, minor, patch);

println!("cargo:rustc-cfg=major_is_{}", detected_version.major);
println!("cargo:rustc-cfg=minor_is_{}", detected_version.minor);
println!("cargo:rustc-cfg=patch_is_{}", detected_version.patch);
println!("cargo:rustc-cfg=major_is_{}", major);
println!("cargo:rustc-cfg=minor_is_{}", minor);
println!("cargo:rustc-cfg=patch_is_{}", patch);

// we only support GDAL >= 2.0.
for major in 2..=detected_version.major {
for major in 2..=major {
println!("cargo:rustc-cfg=major_ge_{}", major);
}

for minor in 0..=detected_version.minor {
for minor in 0..=minor {
println!("cargo:rustc-cfg=minor_ge_{}", minor);
}

for patch in 0..=detected_version.patch {
for patch in 0..=patch {
println!("cargo:rustc-cfg=patch_ge_{}", patch);
}
}

0 comments on commit 69e77cc

Please sign in to comment.