fix libheif (#1153)

This commit is contained in:
Marc
2026-05-22 16:20:10 +07:00
committed by GitHub

View File

@@ -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