Skip to content

Commit

Permalink
Add libaom, libde265, libheif support, for imagick AVIF format support (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
crazywhalecc authored Dec 19, 2024
1 parent d4ec366 commit 192c8cd
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 31 deletions.
26 changes: 13 additions & 13 deletions config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,19 @@
"source": "rar",
"cpp-extension": true
},
"rdkafka": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "external",
"source": "ext-rdkafka",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"librdkafka"
]
},
"readline": {
"support": {
"Windows": "wip",
Expand Down Expand Up @@ -708,19 +721,6 @@
"zlib"
]
},
"rdkafka": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "external",
"source": "ext-rdkafka",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"librdkafka"
]
},
"swoole": {
"support": {
"Windows": "no",
Expand Down
54 changes: 41 additions & 13 deletions config/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
"libjpeg",
"libwebp",
"freetype",
"libtiff"
"libtiff",
"libheif"
],
"lib-suggests": [
"zstd",
Expand Down Expand Up @@ -208,6 +209,13 @@
"libsodium"
]
},
"libaom": {
"source": "libaom",
"static-libs-unix": [
"libaom.a"
],
"cpp-library": true
},
"libargon2": {
"source": "libargon2",
"static-libs-unix": [
Expand Down Expand Up @@ -235,6 +243,13 @@
"ares_rules.h"
]
},
"libde265": {
"source": "libde265",
"static-libs-unix": [
"libde265.a"
],
"cpp-library": true
},
"libevent": {
"source": "libevent",
"static-libs-unix": [
Expand Down Expand Up @@ -276,6 +291,19 @@
"fficonfig.h"
]
},
"libheif": {
"source": "libheif",
"static-libs-unix": [
"libheif.a"
],
"lib-depends": [
"libde265",
"libwebp",
"libaom",
"zlib",
"brotli"
]
},
"libiconv": {
"source": "libiconv",
"static-libs-unix": [
Expand Down Expand Up @@ -355,6 +383,18 @@
"openssl"
]
},
"librdkafka": {
"source": "librdkafka",
"static-libs-unix": [
"librdkafka.a",
"librdkafka++.a",
"librdkafka-static.a"
],
"cpp-library": true,
"lib-suggests": [
"zstd"
]
},
"libsodium": {
"source": "libsodium",
"static-libs-unix": [
Expand Down Expand Up @@ -558,18 +598,6 @@
"pkg-config": {
"source": "pkg-config"
},
"librdkafka": {
"source": "librdkafka",
"static-libs-unix": [
"librdkafka.a",
"librdkafka++.a",
"librdkafka-static.a"
],
"cpp-library": true,
"lib-suggests": [
"zstd"
]
},
"postgresql": {
"source": "postgresql",
"static-libs-unix": [
Expand Down
32 changes: 32 additions & 0 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@
"path": "LICENSE"
}
},
"libaom": {
"type": "git",
"rev": "main",
"url": "https://aomedia.googlesource.com/aom",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libargon2": {
"type": "git",
"rev": "master",
Expand Down Expand Up @@ -338,6 +348,17 @@
"path": "LICENSE.md"
}
},
"libde265": {
"type": "ghrel",
"repo": "strukturag/libde265",
"match": "libde265-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libevent": {
"type": "ghrel",
"repo": "libevent/libevent",
Expand Down Expand Up @@ -368,6 +389,17 @@
"path": "LICENSE"
}
},
"libheif": {
"type": "ghrel",
"repo": "strukturag/libheif",
"match": "libheif-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libiconv": {
"type": "filelist",
"url": "https://ftp.gnu.org/gnu/libiconv/",
Expand Down
12 changes: 12 additions & 0 deletions src/SPC/builder/linux/library/libaom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SPC\builder\linux\library;

class libaom extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libaom;

public const NAME = 'libaom';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/linux/library/libde265.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SPC\builder\linux\library;

class libde265 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libde265;

public const NAME = 'libde265';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/linux/library/libheif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SPC\builder\linux\library;

class libheif extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libheif;

public const NAME = 'libheif';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/macos/library/libaom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SPC\builder\macos\library;

class libaom extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libaom;

public const NAME = 'libaom';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/macos/library/libde265.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SPC\builder\macos\library;

class libde265 extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libde265;

public const NAME = 'libde265';
}
27 changes: 27 additions & 0 deletions src/SPC/builder/macos/library/libheif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace SPC\builder\macos\library;

use SPC\store\FileSystem;

class libheif extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libheif;

public const NAME = 'libheif';

public function patchBeforeBuild(): bool
{
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;
}
return false;
}
}
36 changes: 36 additions & 0 deletions src/SPC/builder/unix/library/libaom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace SPC\builder\unix\library;

use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;

trait libaom
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/builddir');
// Start build
shell()->cd($this->source_dir . '/builddir')
->exec(
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DAOM_TARGET_CPU=generic ' .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['aom.pc']);
}
}
36 changes: 36 additions & 0 deletions src/SPC/builder/unix/library/libde265.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace SPC\builder\unix\library;

use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;

trait libde265
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DENABLE_SDL=OFF ' . // Disable SDL, currently not supported
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['libde265.pc']);
}
}
41 changes: 41 additions & 0 deletions src/SPC/builder/unix/library/libheif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace SPC\builder\unix\library;

use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;

trait libheif
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'--preset=release ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DWITH_EXAMPLES=OFF ' .
'-DWITH_GDK_PIXBUF=OFF ' .
'-DBUILD_TESTING=OFF ' .
'-DWITH_LIBSHARPYUV=ON ' . // optional: libwebp
'-DENABLE_PLUGIN_LOADING=OFF ' .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
$this->patchPkgconfPrefix(['libheif.pc']);
}
}
Loading

0 comments on commit 192c8cd

Please # to comment.