diff --git a/Cargo.toml b/Cargo.toml index 4767899..2f473bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libczirw-sys" -version = "0.4.0" +version = "0.5.0" edition = "2024" rust-version = "1.85.1" authors = ["Wim Pomp "] diff --git a/build.rs b/build.rs index bc1cd47..386d77b 100644 --- a/build.rs +++ b/build.rs @@ -45,7 +45,10 @@ fn lib_name_from_path( if target_is_windows { Ok(file_name.to_string()) } else { - Ok(file_name.strip_prefix("lib").unwrap_or(file_name).to_string()) + Ok(file_name + .strip_prefix("lib") + .unwrap_or(file_name) + .to_string()) } } @@ -156,11 +159,7 @@ fn main() -> Result<(), Box> { let host = env::var("HOST")?; let target = env::var("TARGET")?; let is_cross = host != target - || env::var(format!( - "CMAKE_TOOLCHAIN_FILE_{}", - target.replace('-', "_") - )) - .is_ok() + || env::var(format!("CMAKE_TOOLCHAIN_FILE_{}", target.replace('-', "_"))).is_ok() || env::var("TARGET_CMAKE_TOOLCHAIN_FILE").is_ok() || env::var("CMAKE_TOOLCHAIN_FILE").is_ok(); let is_windows = target.contains("windows"); @@ -175,10 +174,7 @@ fn main() -> Result<(), Box> { let mut cmake_config = cmake::Config::new(&libczi_dir); cmake_config .cxxflag("-fms-extensions") - .define( - "ADDITIONAL_LIBS_REQUIRED_FOR_ATOMIC", - "", - ) + .define("ADDITIONAL_LIBS_REQUIRED_FOR_ATOMIC", "") .define("LIBCZI_BUILD_UNITTESTS", "OFF") .define("LIBCZI_BUILD_CZICMD", "OFF") .define("LIBCZI_BUILD_DYNLIB", "OFF") @@ -197,11 +193,8 @@ fn main() -> Result<(), Box> { .define("CRASH_ON_UNALIGNED_ACCESS", "FALSE"); let has_toolchain_file = env::var("TARGET_CMAKE_TOOLCHAIN_FILE").is_ok() - || env::var(format!( - "CMAKE_TOOLCHAIN_FILE_{}", - target.replace('-', "_") - )) - .is_ok() + || env::var(format!("CMAKE_TOOLCHAIN_FILE_{}", target.replace('-', "_"))) + .is_ok() || env::var("CMAKE_TOOLCHAIN_FILE").is_ok(); if !has_toolchain_file { @@ -304,16 +297,10 @@ fn main() -> Result<(), Box> { println!("cargo::rustc-link-lib=static={}", libcziapi_name); if libczi_dir.exists() { - println!( - "cargo::rustc-link-search=native={}", - libczi_dir.display() - ); + println!("cargo::rustc-link-search=native={}", libczi_dir.display()); } if libczi_dir2.exists() { - println!( - "cargo::rustc-link-search=native={}", - libczi_dir2.display() - ); + println!("cargo::rustc-link-search=native={}", libczi_dir2.display()); } println!("cargo::rustc-link-lib=static={}", libczi_name); @@ -329,20 +316,17 @@ fn main() -> Result<(), Box> { let zstd_dir = dst.join("build/_deps/zstd-build/lib"); let zstd_dir2 = dst.join("_deps/zstd-build/lib"); if zstd_dir.exists() { - println!( - "cargo::rustc-link-search=native={}", - zstd_dir.display() - ); + println!("cargo::rustc-link-search=native={}", zstd_dir.display()); } if zstd_dir2.exists() { - println!( - "cargo::rustc-link-search=native={}", - zstd_dir2.display() - ); + println!("cargo::rustc-link-search=native={}", zstd_dir2.display()); } let zstd_name = find_static_lib(&zstd_dir, "zstd_static", is_windows) .or_else(|| find_static_lib(&zstd_dir2, "zstd_static", is_windows)) - .map(|p| lib_name_from_path(&p, is_windows).unwrap_or_else(|_| "zstd_static".to_string())) + .map(|p| { + lib_name_from_path(&p, is_windows) + .unwrap_or_else(|_| "zstd_static".to_string()) + }) .unwrap_or_else(|| "zstd_static".to_string()); println!("cargo::rustc-link-lib=static={}", zstd_name); } else { @@ -368,5 +352,6 @@ fn main() -> Result<(), Box> { } } println!("cargo::rerun-if-changed=build.rs"); + println!("cargo::rerun-if-changed=libczi"); Ok(()) } diff --git a/libczi b/libczi index 16b30e7..61f74ff 160000 --- a/libczi +++ b/libczi @@ -1 +1 @@ -Subproject commit 16b30e7407f370e0dbbb10fe031b119fc938055c +Subproject commit 61f74ff097d6d0fbe6e36f204ff59d92e299d7cd diff --git a/src/lib.rs b/src/lib.rs index 9017dbc..f0b6c1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,8 +38,8 @@ mod tests { for (i, d) in dimensions.iter().enumerate() { println!("{:?}: {}", d, size[i]); } - println!("X: {}", bounding_box.get_w()); - println!("Y: {}", bounding_box.get_h()); + assert_eq!(bounding_box.get_w(), 1280); + assert_eq!(bounding_box.get_h(), 1280); Ok(()) } @@ -62,6 +62,16 @@ mod tests { ); let bytes = bitmap.lock_info.get_data_roi(); println!("bytes: {:?}", bytes.as_slice()[..100].to_vec()); + assert_eq!( + bytes.as_slice()[..100], + [ + 95, 0, 100, 0, 98, 0, 117, 0, 89, 0, 100, 0, 103, 0, 105, 0, 115, 0, 93, 0, 94, 0, + 89, 0, 93, 0, 95, 0, 111, 0, 87, 0, 103, 0, 107, 0, 103, 0, 104, 0, 113, 0, 112, 0, + 108, 0, 123, 0, 110, 0, 99, 0, 98, 0, 100, 0, 91, 0, 95, 0, 91, 0, 90, 0, 102, 0, + 93, 0, 95, 0, 92, 0, 101, 0, 93, 0, 94, 0, 97, 0, 88, 0, 104, 0, 99, 0, 104, 0, + 117, 0, 101, 0, 110, 0, 97, 0, 103, 0, 112, 0 + ] + ); Ok(()) } @@ -77,6 +87,15 @@ mod tests { let xml = metadata_segment.get_metadata_as_xml()?; let s = String::try_from(&xml)?; println!("xml: {}", &s[..s.len().min(100)]); + assert_eq!( + s[..s.len().min(100)].lines().collect::>(), + vec![ + "", + " ", + r#" "#, + " OptimizeBeforePerformE", + ] + ); Ok(()) } @@ -90,6 +109,10 @@ mod tests { czi.open(open_info)?; let s = czi.get_pyramid_statistics()?; println!("xml: {}", &s[..s.len().min(100)]); + assert_eq!( + &s[..s.len().min(100)], + r###"{"scenePyramidStatistics":{"2147483647":[{"layerInfo":{"minificationFactor":0,"pyramidLayerNo":0},"c"### + ); Ok(()) } @@ -108,6 +131,10 @@ mod tests { "xml: {}", &general_document_info[..general_document_info.len().min(100)] ); + assert_eq!( + &general_document_info[..general_document_info.len().min(100)], + r###"{"user_name":"zeiss","creation_date_time":"2023-11-27T14:35:29.3983006+01:00"}"### + ); Ok(()) } @@ -124,6 +151,10 @@ mod tests { build_info.get_repository_branch() ); println!("repository tag: {:?}", build_info.get_repository_tag()); + assert_eq!( + build_info.get_repository_tag(), + "61f74ff097d6d0fbe6e36f204ff59d92e299d7cd" + ); Ok(()) } }