Skip to content

Commit eb97711

Browse files
authored
fix libheif (#1153)
2 parents e85cd55 + 5c8ec7a commit eb97711

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/SPC/builder/unix/library/libheif.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,28 @@ trait libheif
1111
{
1212
public function patchBeforeBuild(): bool
1313
{
14+
$patched = false;
1415
if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) {
1516
FileSystem::replaceFileStr(
1617
$this->source_dir . '/CMakeLists.txt',
1718
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")',
1819
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")'
1920
);
20-
return true;
21+
$patched = true;
2122
}
22-
return false;
23+
// libheif 1.22+ ships a C-incompatible header: `struct heif_bad_pixel`
24+
$heif_properties = $this->source_dir . '/libheif/api/libheif/heif_properties.h';
25+
if (file_exists($heif_properties)
26+
&& str_contains(file_get_contents($heif_properties), 'struct heif_bad_pixel { uint32_t row; uint32_t column; };')
27+
) {
28+
FileSystem::replaceFileStr(
29+
$heif_properties,
30+
'struct heif_bad_pixel { uint32_t row; uint32_t column; };',
31+
'typedef struct heif_bad_pixel { uint32_t row; uint32_t column; } heif_bad_pixel;'
32+
);
33+
$patched = true;
34+
}
35+
return $patched;
2336
}
2437

2538
protected function build(): void

0 commit comments

Comments
 (0)