From 5c8ec7a56d70e5e5230f473caa5586ca57a53404 Mon Sep 17 00:00:00 2001 From: henderkes Date: Fri, 22 May 2026 15:28:36 +0700 Subject: [PATCH] fix libheif --- src/SPC/builder/unix/library/libheif.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/libheif.php b/src/SPC/builder/unix/library/libheif.php index 095a1f82..f691a3ab 100644 --- a/src/SPC/builder/unix/library/libheif.php +++ b/src/SPC/builder/unix/library/libheif.php @@ -11,15 +11,28 @@ trait libheif { public function patchBeforeBuild(): bool { + $patched = false; if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) { FileSystem::replaceFileStr( $this->source_dir . '/CMakeLists.txt', 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")', 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")' ); - return true; + $patched = true; } - return false; + // libheif 1.22+ ships a C-incompatible header: `struct heif_bad_pixel` + $heif_properties = $this->source_dir . '/libheif/api/libheif/heif_properties.h'; + if (file_exists($heif_properties) + && str_contains(file_get_contents($heif_properties), 'struct heif_bad_pixel { uint32_t row; uint32_t column; };') + ) { + FileSystem::replaceFileStr( + $heif_properties, + 'struct heif_bad_pixel { uint32_t row; uint32_t column; };', + 'typedef struct heif_bad_pixel { uint32_t row; uint32_t column; } heif_bad_pixel;' + ); + $patched = true; + } + return $patched; } protected function build(): void