mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 17:35:36 +08:00
Add libjpeg,libpng
This commit is contained in:
12
config/pkg/lib/libjpeg.yml
Normal file
12
config/pkg/lib/libjpeg.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
libjpeg:
|
||||||
|
type: library
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghtar
|
||||||
|
repo: libjpeg-turbo/libjpeg-turbo
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE.md]
|
||||||
|
license: IJG
|
||||||
|
static-libs@unix:
|
||||||
|
- libjpeg.a
|
||||||
|
- libturbojpeg.a
|
||||||
16
config/pkg/lib/libpng.yml
Normal file
16
config/pkg/lib/libpng.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
libpng:
|
||||||
|
type: library
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghtagtar
|
||||||
|
repo: pnggroup/libpng
|
||||||
|
match: v1\.6\.\d+
|
||||||
|
query: '?per_page=150'
|
||||||
|
binary: hosted
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE]
|
||||||
|
license: PNG
|
||||||
|
depends:
|
||||||
|
- zlib
|
||||||
|
static-libs@unix:
|
||||||
|
- libpng16.a
|
||||||
28
src/Package/Library/libjpeg.php
Normal file
28
src/Package/Library/libjpeg.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Library;
|
||||||
|
|
||||||
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
|
use StaticPHP\Attribute\Package\Library;
|
||||||
|
use StaticPHP\Package\LibraryPackage;
|
||||||
|
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||||
|
|
||||||
|
#[Library('libjpeg')]
|
||||||
|
class libjpeg
|
||||||
|
{
|
||||||
|
#[BuildFor('Darwin')]
|
||||||
|
#[BuildFor('Linux')]
|
||||||
|
public function buildUnix(LibraryPackage $lib): void
|
||||||
|
{
|
||||||
|
UnixCMakeExecutor::create($lib)
|
||||||
|
->addConfigureArgs(
|
||||||
|
'-DENABLE_STATIC=ON',
|
||||||
|
'-DENABLE_SHARED=OFF',
|
||||||
|
)
|
||||||
|
->build();
|
||||||
|
// patch pkgconfig
|
||||||
|
$lib->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/Package/Library/libpng.php
Normal file
47
src/Package/Library/libpng.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Library;
|
||||||
|
|
||||||
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
|
use StaticPHP\Attribute\Package\Library;
|
||||||
|
use StaticPHP\Package\LibraryPackage;
|
||||||
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
|
#[Library('libpng')]
|
||||||
|
class libpng
|
||||||
|
{
|
||||||
|
#[BuildFor('Darwin')]
|
||||||
|
#[BuildFor('Linux')]
|
||||||
|
public function buildUnix(LibraryPackage $lib): void
|
||||||
|
{
|
||||||
|
$args = [
|
||||||
|
'--enable-hardware-optimizations',
|
||||||
|
"--with-zlib-prefix={$lib->getBuildRootPath()}",
|
||||||
|
];
|
||||||
|
|
||||||
|
// Enable architecture-specific optimizations
|
||||||
|
match (getenv('SPC_ARCH')) {
|
||||||
|
'x86_64' => $args[] = '--enable-intel-sse',
|
||||||
|
'aarch64' => $args[] = '--enable-arm-neon',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
UnixAutoconfExecutor::create($lib)
|
||||||
|
->exec('chmod +x ./configure')
|
||||||
|
->exec('chmod +x ./install-sh')
|
||||||
|
->appendEnv(['LDFLAGS' => "-L{$lib->getLibDir()}"])
|
||||||
|
->addConfigureArgs(...$args)
|
||||||
|
->configure()
|
||||||
|
->make(
|
||||||
|
'libpng16.la',
|
||||||
|
'install-libLTLIBRARIES install-data-am',
|
||||||
|
after_env_vars: ['DEFAULT_INCLUDES' => "-I{$lib->getSourceDir()} -I{$lib->getIncludeDir()}"]
|
||||||
|
);
|
||||||
|
|
||||||
|
// patch pkgconfig
|
||||||
|
$lib->patchPkgconfPrefix(['libpng16.pc']);
|
||||||
|
$lib->patchLaDependencyPrefix();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user