mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-20 05:44:52 +08:00
Merge branch 'main' into feat/xdebug-dynamic
This commit is contained in:
commit
8b07b15f6c
@ -49,7 +49,7 @@ SPC_SKIP_DOCTOR_CHECK_ITEMS=""
|
||||
; RHEL: /usr/lib64/php/modules
|
||||
; Alpine: /usr/lib/php{PHP_VERSION}/modules
|
||||
; where {PHP_VERSION} is 84 for php 8.4
|
||||
EXTENSION_DIR=
|
||||
; EXTENSION_DIR=
|
||||
|
||||
[windows]
|
||||
; php-sdk-binary-tools path
|
||||
|
||||
@ -257,6 +257,7 @@
|
||||
"Windows": "wip",
|
||||
"BSD": "wip"
|
||||
},
|
||||
"notes": true,
|
||||
"type": "external",
|
||||
"source": "ext-imagick",
|
||||
"arg-type": "custom",
|
||||
|
||||
@ -210,12 +210,12 @@
|
||||
"libwebp",
|
||||
"freetype",
|
||||
"libtiff",
|
||||
"libheif"
|
||||
"libheif",
|
||||
"bzip2"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd",
|
||||
"xz",
|
||||
"bzip2",
|
||||
"libzip",
|
||||
"libxml2"
|
||||
]
|
||||
|
||||
@ -639,7 +639,7 @@
|
||||
"mimalloc": {
|
||||
"type": "ghtagtar",
|
||||
"repo": "microsoft/mimalloc",
|
||||
"match": "v2.+",
|
||||
"match": "v2.2.[^3].*",
|
||||
"provide-pre-built": false,
|
||||
"license": {
|
||||
"type": "file",
|
||||
|
||||
@ -48,6 +48,10 @@ This extension contains an implementation of the coroutine environment for `pdo_
|
||||
|
||||
1. Only PHP 8.0 ~ 8.4 is supported.
|
||||
|
||||
## imagick
|
||||
|
||||
1. The imagick extension currently only has openmp support on musl libc. This means that multithreading is disabled on glibc or other operating systems. The extension is still fully functional.
|
||||
|
||||
## imap
|
||||
|
||||
1. Kerberos is not supported
|
||||
|
||||
@ -45,6 +45,10 @@ swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_
|
||||
|
||||
1. swow 仅支持 PHP 8.0 ~ 8.4 版本。
|
||||
|
||||
## imagick
|
||||
|
||||
imagick 扩展目前仅在 musl libc 上支持 OpenMP(libgomp)。使用 glibc 方式构建的 imagick 扩展无法支持多线程特性。
|
||||
|
||||
## imap
|
||||
|
||||
1. 该扩展目前不支持 Kerberos。
|
||||
@ -141,4 +145,4 @@ parallel 扩展只支持 PHP 8.0 及以上版本,并只支持 ZTS 构建(`--
|
||||
|
||||
1. 从技术上讲,这不是扩展,而是一个库。
|
||||
2. 在 Linux 或 macOS 上使用 `--with-libs="mimalloc"` 进行构建将覆盖默认分配器。
|
||||
3. 目前,这还处于实验阶段,但建议在线程环境中使用。
|
||||
3. 目前,这还处于实验阶段,但建议在线程环境中使用。
|
||||
|
||||
@ -190,11 +190,11 @@ abstract class BuilderBase
|
||||
}
|
||||
}
|
||||
$this->emitPatchPoint('before-php-extract');
|
||||
SourceManager::initSource(sources: ['php-src']);
|
||||
SourceManager::initSource(sources: ['php-src'], source_only: true);
|
||||
$this->emitPatchPoint('after-php-extract');
|
||||
if ($this->getPHPVersionID() >= 80000) {
|
||||
$this->emitPatchPoint('before-micro-extract');
|
||||
SourceManager::initSource(sources: ['micro']);
|
||||
SourceManager::initSource(sources: ['micro'], source_only: true);
|
||||
$this->emitPatchPoint('after-micro-extract');
|
||||
}
|
||||
$this->emitPatchPoint('before-exts-extract');
|
||||
|
||||
@ -222,7 +222,7 @@ abstract class LibraryBase
|
||||
// extract first if not exists
|
||||
if (!is_dir($this->source_dir)) {
|
||||
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-extract');
|
||||
SourceManager::initSource(libs: [static::NAME]);
|
||||
SourceManager::initSource(libs: [static::NAME], source_only: true);
|
||||
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-extract');
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
@ -13,17 +12,18 @@ class imagick extends Extension
|
||||
{
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// imagick may call omp_pause_all which requires -lgomp
|
||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||
if ($this->builder instanceof LinuxBuilder) {
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp ';
|
||||
if (getenv('SPC_LIBC') !== 'musl') {
|
||||
return false;
|
||||
}
|
||||
// imagick with calls omp_pause_all which requires -lgomp, on non-musl we build imagick without openmp
|
||||
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
return '--with-imagick=' . BUILD_ROOT_PATH;
|
||||
$disable_omp = getenv('SPC_LIBC') === 'musl' ? '' : ' ac_cv_func_omp_pause_resource_all=no';
|
||||
return '--with-imagick=' . BUILD_ROOT_PATH . $disable_omp;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +18,9 @@ trait imagemagick
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
// TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future
|
||||
$extra = '--without-jxl --without-x --enable-openmp --without-bzlib ';
|
||||
// TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC -fPIE so we can't use openmp without depending on libgomp.so
|
||||
$openmp = getenv('SPC_LIBC') === 'musl' ? '--enable-openmp' : '--disable-openmp';
|
||||
$extra = "--without-jxl --without-x {$openmp} ";
|
||||
$required_libs = '';
|
||||
$optional_libs = [
|
||||
'libzip' => 'zip',
|
||||
@ -27,10 +28,12 @@ trait imagemagick
|
||||
'libpng' => 'png',
|
||||
'libwebp' => 'webp',
|
||||
'libxml2' => 'xml',
|
||||
'libheif' => 'heic',
|
||||
'zlib' => 'zlib',
|
||||
'xz' => 'lzma',
|
||||
'zstd' => 'zstd',
|
||||
'freetype' => 'freetype',
|
||||
'bzip2' => 'bzlib',
|
||||
];
|
||||
foreach ($optional_libs as $lib => $option) {
|
||||
$extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} ";
|
||||
|
||||
@ -20,6 +20,7 @@ class ExtractCommand extends BaseCommand
|
||||
public function configure(): void
|
||||
{
|
||||
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated');
|
||||
$this->addOption('source-only', null, null, 'Only check the source exist, do not check the lib and ext');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +35,7 @@ class ExtractCommand extends BaseCommand
|
||||
$this->output->writeln('<error>sources cannot be empty, at least contain one !</error>');
|
||||
return static::FAILURE;
|
||||
}
|
||||
SourceManager::initSource(sources: $sources);
|
||||
SourceManager::initSource(sources: $sources, source_only: $this->getOption('source-only'));
|
||||
logger()->info('Extract done !');
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
@ -461,6 +461,23 @@ class FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function replaceFileLineContainsString(string $file, string $find, string $line): false|int
|
||||
{
|
||||
$lines = file($file);
|
||||
if ($lines === false) {
|
||||
throw new FileSystemException('Cannot read file: ' . $file);
|
||||
}
|
||||
foreach ($lines as $key => $value) {
|
||||
if (str_contains($value, $find)) {
|
||||
$lines[$key] = $line . PHP_EOL;
|
||||
}
|
||||
}
|
||||
return file_put_contents($file, implode('', $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
|
||||
@ -15,7 +15,7 @@ class SourceManager
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void
|
||||
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null, bool $source_only = false): void
|
||||
{
|
||||
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
|
||||
throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?');
|
||||
@ -56,7 +56,7 @@ class SourceManager
|
||||
}
|
||||
// check source downloaded
|
||||
$pre_built_name = Downloader::getPreBuiltLockName($source);
|
||||
if (!isset($lock[$pre_built_name])) {
|
||||
if ($source_only || !isset($lock[$pre_built_name])) {
|
||||
if (!isset($lock[$source])) {
|
||||
throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !");
|
||||
}
|
||||
|
||||
@ -94,8 +94,8 @@ class SPCConfigUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
// patch: imagick (imagemagick wrapper) for linux needs -lgomp
|
||||
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') {
|
||||
// patch: imagick (imagemagick wrapper) for linux needs libgomp
|
||||
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
|
||||
$short_name[] = '-lgomp';
|
||||
}
|
||||
return implode(' ', $short_name);
|
||||
|
||||
@ -21,8 +21,8 @@ $test_php_version = [
|
||||
|
||||
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
|
||||
$test_os = [
|
||||
// 'macos-13',
|
||||
// 'macos-14',
|
||||
'macos-13',
|
||||
'macos-14',
|
||||
'ubuntu-latest',
|
||||
'ubuntu-22.04',
|
||||
'ubuntu-22.04-arm',
|
||||
@ -35,10 +35,10 @@ $zts = false;
|
||||
$no_strip = false;
|
||||
|
||||
// compress with upx
|
||||
$upx = true;
|
||||
$upx = false;
|
||||
|
||||
// prefer downloading pre-built packages to speed up the build process
|
||||
$prefer_pre_built = true;
|
||||
$prefer_pre_built = false;
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user