mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 15:25:41 +08:00
Merge branch 'main' into grpc
# Conflicts: # src/globals/test-extensions.php
This commit is contained in:
@@ -10,7 +10,6 @@ use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class Extension
|
||||
{
|
||||
@@ -516,8 +515,7 @@ class Extension
|
||||
$sharedLibString = '';
|
||||
$staticLibString = '';
|
||||
$staticLibs = $this->getLibFilesString();
|
||||
$staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs);
|
||||
$staticLibs = str_replace('.a', '', $staticLibs);
|
||||
$staticLibs = str_replace([BUILD_LIB_PATH . '/lib', '.a'], ['-l', ''], $staticLibs);
|
||||
$staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']);
|
||||
foreach ($staticLibs as $lib) {
|
||||
$lib = trim($lib);
|
||||
@@ -533,8 +531,8 @@ class Extension
|
||||
$sharedLibString .= '-l' . $lib . ' ';
|
||||
}
|
||||
}
|
||||
// move static libstdc++ to shared if we are on non-full-static build target
|
||||
if (!SPCTarget::isStatic() && in_array(SPCTarget::getLibc(), SPCTarget::LIBC_LIST)) {
|
||||
// move -lstdc++ to static libraries because centos 7 the shared libstdc++ is incomplete
|
||||
if (str_contains((string) getenv('PATH'), 'rh/devtoolset-10')) {
|
||||
$staticLibString .= ' -lstdc++';
|
||||
$sharedLibString = str_replace('-lstdc++', '', $sharedLibString);
|
||||
}
|
||||
|
||||
12
src/SPC/builder/linux/library/jbig.php
Normal file
12
src/SPC/builder/linux/library/jbig.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class jbig extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\jbig;
|
||||
|
||||
public const NAME = 'jbig';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/lerc.php
Normal file
12
src/SPC/builder/linux/library/lerc.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class lerc extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\lerc;
|
||||
|
||||
public const NAME = 'lerc';
|
||||
}
|
||||
12
src/SPC/builder/linux/library/libjxl.php
Normal file
12
src/SPC/builder/linux/library/libjxl.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class libjxl extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libjxl;
|
||||
|
||||
public const NAME = 'libjxl';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/jbig.php
Normal file
12
src/SPC/builder/macos/library/jbig.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class jbig extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\jbig;
|
||||
|
||||
public const NAME = 'jbig';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/lerc.php
Normal file
12
src/SPC/builder/macos/library/lerc.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class lerc extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\lerc;
|
||||
|
||||
public const NAME = 'lerc';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/libjxl.php
Normal file
12
src/SPC/builder/macos/library/libjxl.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libjxl extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libjxl;
|
||||
|
||||
public const NAME = 'libjxl';
|
||||
}
|
||||
@@ -32,9 +32,9 @@ trait imagemagick
|
||||
->optionalLib('zstd', ...ac_with_args('zstd'))
|
||||
->optionalLib('freetype', ...ac_with_args('freetype'))
|
||||
->optionalLib('bzip2', ...ac_with_args('bzlib'))
|
||||
->optionalLib('libjxl', ...ac_with_args('jxl'))
|
||||
->addConfigureArgs(
|
||||
'--disable-openmp',
|
||||
'--without-jxl',
|
||||
'--without-x',
|
||||
);
|
||||
|
||||
|
||||
35
src/SPC/builder/unix/library/jbig.php
Normal file
35
src/SPC/builder/unix/library/jbig.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait jbig
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} lib")
|
||||
->exec('cp libjbig/libjbig.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libjbig/libjbig85.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libjbig/jbig.h ' . BUILD_INCLUDE_PATH)
|
||||
->exec('cp libjbig/jbig85.h ' . BUILD_INCLUDE_PATH)
|
||||
->exec('cp libjbig/jbig_ar.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
22
src/SPC/builder/unix/library/lerc.php
Normal file
22
src/SPC/builder/unix/library/lerc.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait lerc
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
->build();
|
||||
}
|
||||
}
|
||||
28
src/SPC/builder/unix/library/libjxl.php
Normal file
28
src/SPC/builder/unix/library/libjxl.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait libjxl
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_TOOLS=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_EXAMPLES=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_MANPAGES=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_BENCHMARK=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_SJPOEG=ON')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_JNI=OFF')
|
||||
->addConfigureArgs('-DJPEGXL_ENABLE_TRANSCODE_JPEG=ON')
|
||||
->addConfigureArgs('-DJPEGXL_STATIC=' . (SPCTarget::isStatic() ? 'ON' : 'OFF'))
|
||||
->addConfigureArgs('-DJPEGXL_FORCE_SYSTEM_BROTLI=ON')
|
||||
->addConfigureArgs('-DBUILD_TESTING=OFF')
|
||||
->build();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait libtiff
|
||||
{
|
||||
@@ -16,7 +18,15 @@ trait libtiff
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$libcpp = SPCTarget::getTargetOS() === 'Linux' ? '-lstdc++' : '-lc++';
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv');
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', '-l"$lerc_lib_name"', '-l"$lerc_lib_name" ' . $libcpp);
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->optionalLib('lerc', '--enable-lerc', '--disable-lerc')
|
||||
->optionalLib('zstd', '--enable-zstd', '--disable-zstd')
|
||||
->optionalLib('libwebp', '--enable-webp', '--disable-webp')
|
||||
->optionalLib('xz', '--enable-lzma', '--disable-lzma')
|
||||
->optionalLib('jbig', '--enable-jbig', '--disable-jbig')
|
||||
->configure(
|
||||
// zlib deps
|
||||
'--enable-zlib',
|
||||
@@ -24,16 +34,15 @@ trait libtiff
|
||||
"--with-zlib-lib-dir={$this->getLibDir()}",
|
||||
// libjpeg deps
|
||||
'--enable-jpeg',
|
||||
'--disable-old-jpeg',
|
||||
'--disable-jpeg12',
|
||||
"--with-jpeg-include-dir={$this->getIncludeDir()}",
|
||||
"--with-jpeg-lib-dir={$this->getLibDir()}",
|
||||
// We disabled lzma, zstd, webp, libdeflate by default to reduce the size of the binary
|
||||
'--disable-lzma',
|
||||
'--disable-zstd',
|
||||
'--disable-webp',
|
||||
'--disable-old-jpeg',
|
||||
'--disable-jpeg12',
|
||||
'--disable-libdeflate',
|
||||
'--disable-tools',
|
||||
'--disable-contrib',
|
||||
'--disable-cxx',
|
||||
'--without-x',
|
||||
)
|
||||
->make();
|
||||
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
||||
|
||||
@@ -10,3 +10,4 @@ assert(Imagick::queryFormats('WEBP') !== []);
|
||||
assert(Imagick::queryFormats('JPEG') !== []);
|
||||
assert(Imagick::queryFormats('PNG') !== []);
|
||||
assert(Imagick::queryFormats('TIFF') !== []);
|
||||
assert(Imagick::queryFormats('JXL') !== []);
|
||||
|
||||
Reference in New Issue
Block a user