Skip to content

Commit 192c8cd

Browse files
authored
Add libaom, libde265, libheif support, for imagick AVIF format support (#575)
* Add libaom, libde265, libheif support, for imagick AVIF format support * Fix aom optimization * Fix aom build command * Fix libheif build command * Fix libheif build * cs fix
1 parent d4ec366 commit 192c8cd

File tree

14 files changed

+303
-31
lines changed

14 files changed

+303
-31
lines changed

config/ext.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,19 @@
560560
"source": "rar",
561561
"cpp-extension": true
562562
},
563+
"rdkafka": {
564+
"support": {
565+
"BSD": "wip",
566+
"Windows": "wip"
567+
},
568+
"type": "external",
569+
"source": "ext-rdkafka",
570+
"arg-type": "custom",
571+
"cpp-extension": true,
572+
"lib-depends": [
573+
"librdkafka"
574+
]
575+
},
563576
"readline": {
564577
"support": {
565578
"Windows": "wip",
@@ -708,19 +721,6 @@
708721
"zlib"
709722
]
710723
},
711-
"rdkafka": {
712-
"support": {
713-
"BSD": "wip",
714-
"Windows": "wip"
715-
},
716-
"type": "external",
717-
"source": "ext-rdkafka",
718-
"arg-type": "custom",
719-
"cpp-extension": true,
720-
"lib-depends": [
721-
"librdkafka"
722-
]
723-
},
724724
"swoole": {
725725
"support": {
726726
"Windows": "no",

config/lib.json

+41-13
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@
176176
"libjpeg",
177177
"libwebp",
178178
"freetype",
179-
"libtiff"
179+
"libtiff",
180+
"libheif"
180181
],
181182
"lib-suggests": [
182183
"zstd",
@@ -208,6 +209,13 @@
208209
"libsodium"
209210
]
210211
},
212+
"libaom": {
213+
"source": "libaom",
214+
"static-libs-unix": [
215+
"libaom.a"
216+
],
217+
"cpp-library": true
218+
},
211219
"libargon2": {
212220
"source": "libargon2",
213221
"static-libs-unix": [
@@ -235,6 +243,13 @@
235243
"ares_rules.h"
236244
]
237245
},
246+
"libde265": {
247+
"source": "libde265",
248+
"static-libs-unix": [
249+
"libde265.a"
250+
],
251+
"cpp-library": true
252+
},
238253
"libevent": {
239254
"source": "libevent",
240255
"static-libs-unix": [
@@ -276,6 +291,19 @@
276291
"fficonfig.h"
277292
]
278293
},
294+
"libheif": {
295+
"source": "libheif",
296+
"static-libs-unix": [
297+
"libheif.a"
298+
],
299+
"lib-depends": [
300+
"libde265",
301+
"libwebp",
302+
"libaom",
303+
"zlib",
304+
"brotli"
305+
]
306+
},
279307
"libiconv": {
280308
"source": "libiconv",
281309
"static-libs-unix": [
@@ -355,6 +383,18 @@
355383
"openssl"
356384
]
357385
},
386+
"librdkafka": {
387+
"source": "librdkafka",
388+
"static-libs-unix": [
389+
"librdkafka.a",
390+
"librdkafka++.a",
391+
"librdkafka-static.a"
392+
],
393+
"cpp-library": true,
394+
"lib-suggests": [
395+
"zstd"
396+
]
397+
},
358398
"libsodium": {
359399
"source": "libsodium",
360400
"static-libs-unix": [
@@ -558,18 +598,6 @@
558598
"pkg-config": {
559599
"source": "pkg-config"
560600
},
561-
"librdkafka": {
562-
"source": "librdkafka",
563-
"static-libs-unix": [
564-
"librdkafka.a",
565-
"librdkafka++.a",
566-
"librdkafka-static.a"
567-
],
568-
"cpp-library": true,
569-
"lib-suggests": [
570-
"zstd"
571-
]
572-
},
573601
"postgresql": {
574602
"source": "postgresql",
575603
"static-libs-unix": [

config/source.json

+32
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@
303303
"path": "LICENSE"
304304
}
305305
},
306+
"libaom": {
307+
"type": "git",
308+
"rev": "main",
309+
"url": "https://aomedia.googlesource.com/aom",
310+
"provide-pre-built": true,
311+
"license": {
312+
"type": "file",
313+
"path": "LICENSE"
314+
}
315+
},
306316
"libargon2": {
307317
"type": "git",
308318
"rev": "master",
@@ -338,6 +348,17 @@
338348
"path": "LICENSE.md"
339349
}
340350
},
351+
"libde265": {
352+
"type": "ghrel",
353+
"repo": "strukturag/libde265",
354+
"match": "libde265-.+\\.tar\\.gz",
355+
"prefer-stable": true,
356+
"provide-pre-built": true,
357+
"license": {
358+
"type": "file",
359+
"path": "COPYING"
360+
}
361+
},
341362
"libevent": {
342363
"type": "ghrel",
343364
"repo": "libevent/libevent",
@@ -368,6 +389,17 @@
368389
"path": "LICENSE"
369390
}
370391
},
392+
"libheif": {
393+
"type": "ghrel",
394+
"repo": "strukturag/libheif",
395+
"match": "libheif-.+\\.tar\\.gz",
396+
"prefer-stable": true,
397+
"provide-pre-built": true,
398+
"license": {
399+
"type": "file",
400+
"path": "COPYING"
401+
}
402+
},
371403
"libiconv": {
372404
"type": "filelist",
373405
"url": "https://ftp.gnu.org/gnu/libiconv/",
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class libaom extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libaom;
10+
11+
public const NAME = 'libaom';
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class libde265 extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libde265;
10+
11+
public const NAME = 'libde265';
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class libheif extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libheif;
10+
11+
public const NAME = 'libheif';
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class libaom extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libaom;
10+
11+
public const NAME = 'libaom';
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class libde265 extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libde265;
10+
11+
public const NAME = 'libde265';
12+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
use SPC\store\FileSystem;
8+
9+
class libheif extends MacOSLibraryBase
10+
{
11+
use \SPC\builder\unix\library\libheif;
12+
13+
public const NAME = 'libheif';
14+
15+
public function patchBeforeBuild(): bool
16+
{
17+
if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) {
18+
FileSystem::replaceFileStr(
19+
$this->source_dir . '/CMakeLists.txt',
20+
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")',
21+
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")'
22+
);
23+
return true;
24+
}
25+
return false;
26+
}
27+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\exception\FileSystemException;
8+
use SPC\exception\RuntimeException;
9+
use SPC\store\FileSystem;
10+
11+
trait libaom
12+
{
13+
/**
14+
* @throws RuntimeException
15+
* @throws FileSystemException
16+
*/
17+
protected function build(): void
18+
{
19+
// CMake needs a clean build directory
20+
FileSystem::resetDir($this->source_dir . '/builddir');
21+
// Start build
22+
shell()->cd($this->source_dir . '/builddir')
23+
->exec(
24+
'cmake ' .
25+
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
26+
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
27+
'-DCMAKE_BUILD_TYPE=Release ' .
28+
'-DBUILD_SHARED_LIBS=OFF ' .
29+
'-DAOM_TARGET_CPU=generic ' .
30+
'..'
31+
)
32+
->exec("cmake --build . -j {$this->builder->concurrency}")
33+
->exec('make install');
34+
$this->patchPkgconfPrefix(['aom.pc']);
35+
}
36+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\exception\FileSystemException;
8+
use SPC\exception\RuntimeException;
9+
use SPC\store\FileSystem;
10+
11+
trait libde265
12+
{
13+
/**
14+
* @throws RuntimeException
15+
* @throws FileSystemException
16+
*/
17+
protected function build(): void
18+
{
19+
// CMake needs a clean build directory
20+
FileSystem::resetDir($this->source_dir . '/build');
21+
// Start build
22+
shell()->cd($this->source_dir . '/build')
23+
->exec(
24+
'cmake ' .
25+
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
26+
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
27+
'-DCMAKE_BUILD_TYPE=Release ' .
28+
'-DBUILD_SHARED_LIBS=OFF ' .
29+
'-DENABLE_SDL=OFF ' . // Disable SDL, currently not supported
30+
'..'
31+
)
32+
->exec("cmake --build . -j {$this->builder->concurrency}")
33+
->exec('make install');
34+
$this->patchPkgconfPrefix(['libde265.pc']);
35+
}
36+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\exception\FileSystemException;
8+
use SPC\exception\RuntimeException;
9+
use SPC\store\FileSystem;
10+
11+
trait libheif
12+
{
13+
/**
14+
* @throws RuntimeException
15+
* @throws FileSystemException
16+
*/
17+
protected function build(): void
18+
{
19+
// CMake needs a clean build directory
20+
FileSystem::resetDir($this->source_dir . '/build');
21+
// Start build
22+
shell()->cd($this->source_dir . '/build')
23+
->exec(
24+
'cmake ' .
25+
'--preset=release ' .
26+
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
27+
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
28+
'-DCMAKE_BUILD_TYPE=Release ' .
29+
'-DBUILD_SHARED_LIBS=OFF ' .
30+
'-DWITH_EXAMPLES=OFF ' .
31+
'-DWITH_GDK_PIXBUF=OFF ' .
32+
'-DBUILD_TESTING=OFF ' .
33+
'-DWITH_LIBSHARPYUV=ON ' . // optional: libwebp
34+
'-DENABLE_PLUGIN_LOADING=OFF ' .
35+
'..'
36+
)
37+
->exec("cmake --build . -j {$this->builder->concurrency}")
38+
->exec('make install');
39+
$this->patchPkgconfPrefix(['libheif.pc']);
40+
}
41+
}

0 commit comments

Comments
 (0)