diff --git a/.gitignore b/.gitignore index 1bc2069..e8c9165 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /target **/*.rs.bk -Cargo.lock .* !/.gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b511b4..b13a807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [Unreleased] - ReleaseDate + +- Updated version of `bindgen` to 0.65. +- Use `pkg-config` in `build.rs` ([#1](https://github.com/Cykooz/libheif-sys/pull/1)). + ## [1.14.2] - 2023-01-31 - Updated version of `bindgen` to 0.63.0. diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..929d9ae --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,258 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bindgen" +version = "0.65.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" + +[[package]] +name = "libheif-sys" +version = "1.14.2" +dependencies = [ + "bindgen", + "libc", + "pkg-config", +] + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "prettyplease" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "syn" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 699ac1a..137e0e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ use-bindgen = ["bindgen"] [build-dependencies] -bindgen = { version = "0.63.0", optional = true } +bindgen = { version = "0.65", optional = true } pkg-config = "0.3.15" diff --git a/README.md b/README.md index 4304bbc..a701e54 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,15 @@ ```rust use std::ffi; -use std::mem::MaybeUninit; use std::ptr; use libheif_sys as lh; +#[test] fn read_and_decode_heic_file() { unsafe { lh::heif_init(ptr::null_mut()); - + let ctx = lh::heif_context_alloc(); assert_ne!(ctx, ptr::null_mut()); @@ -26,11 +26,11 @@ fn read_and_decode_heic_file() { let err = lh::heif_context_read_from_file(ctx, c_name.as_ptr(), ptr::null()); assert_eq!(err.code, 0); - let mut handle = MaybeUninit::<_>::uninit(); - let err = lh::heif_context_get_primary_image_handle(ctx, handle.as_mut_ptr()); + let mut handle = ptr::null_mut(); + let err = lh::heif_context_get_primary_image_handle(ctx, &mut handle); assert_eq!(err.code, 0); + assert!(!handle.is_null()); - let handle = handle.assume_init(); let width = lh::heif_image_handle_get_width(handle); assert_eq!(width, 4032); let height = lh::heif_image_handle_get_height(handle); @@ -38,18 +38,18 @@ fn read_and_decode_heic_file() { let options = lh::heif_decoding_options_alloc(); - let mut image = MaybeUninit::<_>::uninit(); + let mut image = ptr::null_mut(); let err = lh::heif_decode_image( handle, - image.as_mut_ptr(), + &mut image, lh::heif_colorspace_heif_colorspace_RGB, lh::heif_chroma_heif_chroma_444, options, ); lh::heif_decoding_options_free(options); assert_eq!(err.code, 0); + assert!(!image.is_null()); - let image = image.assume_init(); let colorspace = lh::heif_image_get_colorspace(image); assert_eq!(colorspace, lh::heif_colorspace_heif_colorspace_RGB); let chroma_format = lh::heif_image_get_chroma_format(image); diff --git a/src/bindings.rs b/src/bindings.rs index e8b610e..346b359 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.63.0 */ +/* automatically generated by rust-bindgen 0.65.1 */ extern "C" { pub fn heif_get_version() -> *const libc::c_char; diff --git a/src/lib.rs b/src/lib.rs index 69befdc..5bfb6e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("../README.md")] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 13c092f..aa4d784 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,5 +1,3 @@ -use std::ffi; -use std::mem::MaybeUninit; use std::ptr; use libheif_sys as lh; @@ -10,60 +8,9 @@ fn create_heic_context() { lh::heif_init(ptr::null_mut()); let ctx = lh::heif_context_alloc(); - assert_ne!(ctx, ptr::null_mut()); + assert!(!ctx.is_null()); lh::heif_context_free(ctx); lh::heif_deinit(); } } - -#[test] -fn read_and_decode_heic_file() { - unsafe { - lh::heif_init(ptr::null_mut()); - - let ctx = lh::heif_context_alloc(); - assert_ne!(ctx, ptr::null_mut()); - - let c_name = ffi::CString::new("tests/window.heic").unwrap(); - let err = lh::heif_context_read_from_file(ctx, c_name.as_ptr(), ptr::null()); - assert_eq!(err.code, 0); - - let mut handle = MaybeUninit::<_>::uninit(); - let err = lh::heif_context_get_primary_image_handle(ctx, handle.as_mut_ptr()); - assert_eq!(err.code, 0); - - let handle = handle.assume_init(); - let width = lh::heif_image_handle_get_width(handle); - assert_eq!(width, 4032); - let height = lh::heif_image_handle_get_height(handle); - assert_eq!(height, 3024); - - let options = lh::heif_decoding_options_alloc(); - - let mut image = MaybeUninit::<_>::uninit(); - let err = lh::heif_decode_image( - handle, - image.as_mut_ptr(), - lh::heif_colorspace_heif_colorspace_RGB, - lh::heif_chroma_heif_chroma_444, - options, - ); - lh::heif_decoding_options_free(options); - assert_eq!(err.code, 0); - - let image = image.assume_init(); - let colorspace = lh::heif_image_get_colorspace(image); - assert_eq!(colorspace, lh::heif_colorspace_heif_colorspace_RGB); - let chroma_format = lh::heif_image_get_chroma_format(image); - assert_eq!(chroma_format, lh::heif_chroma_heif_chroma_444); - let width = lh::heif_image_get_width(image, lh::heif_channel_heif_channel_R); - assert_eq!(width, 4032); - let height = lh::heif_image_get_height(image, lh::heif_channel_heif_channel_R); - assert_eq!(height, 3024); - - lh::heif_context_free(ctx); - - lh::heif_deinit(); - }; -}