mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Compare commits
2 Commits
85ac553ded
...
1c2343f740
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c2343f740 | ||
|
|
280284e4c2 |
@ -37,6 +37,12 @@ Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`
|
||||
|
||||
Please first select the extension you want to compile based on the extension list below.
|
||||
|
||||
### Direct Download
|
||||
|
||||
If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.zhamao.xin/static-php-cli/)
|
||||
|
||||
> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
||||
|
||||
### Supported Extensions
|
||||
|
||||
[Supported Extension List](/ext-support.md)
|
||||
|
||||
@ -37,6 +37,12 @@ If you are using English, see [English README](README-en.md).
|
||||
|
||||
请先根据下方扩展列表选择你要编译的扩展。
|
||||
|
||||
### 自托管直接下载
|
||||
|
||||
如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.zhamao.xin/static-php-cli/)
|
||||
|
||||
> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
|
||||
|
||||
### 支持的扩展情况
|
||||
|
||||
[扩展支持列表](/ext-support.md)
|
||||
|
||||
@ -221,7 +221,7 @@
|
||||
"type": "git",
|
||||
"path": "php-src/sapi/micro",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/dixyes/phpmicro",
|
||||
"url": "https://github.com/crazywhalecc/phpmicro",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
|
||||
@ -218,7 +218,7 @@ class LinuxBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
if ($this->phar_patched) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 -R < sapi/micro/patches/phar.patch');
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,12 +255,7 @@ class LinuxBuilder extends BuilderBase
|
||||
}
|
||||
if ($this->getExt('phar')) {
|
||||
$this->phar_patched = true;
|
||||
try {
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 < sapi/micro/patches/phar.patch');
|
||||
} catch (RuntimeException $e) {
|
||||
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
||||
$this->phar_patched = false;
|
||||
}
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
|
||||
@ -187,7 +187,7 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
|
||||
if ($this->phar_patched) {
|
||||
f_passthru('cd ' . SOURCE_PATH . '/php-src && patch -p1 -R < sapi/micro/patches/phar.patch');
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,13 +218,7 @@ class MacOSBuilder extends BuilderBase
|
||||
}
|
||||
if ($this->getExt('phar')) {
|
||||
$this->phar_patched = true;
|
||||
try {
|
||||
// TODO: 未来改进一下 patch,让除了这种 patch 类型的文件以外可以恢复原文件
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('patch -p1 < sapi/micro/patches/phar.patch');
|
||||
} catch (RuntimeException $e) {
|
||||
logger()->error('failed to patch phat due to patch exit with code ' . $e->getCode());
|
||||
$this->phar_patched = false;
|
||||
}
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
|
||||
@ -442,7 +442,7 @@ class FileSystem
|
||||
private static function emitSourceExtractHook(string $name)
|
||||
{
|
||||
foreach ((self::$_extract_hook[$name] ?? []) as $hook) {
|
||||
if ($hook($name) === true) {
|
||||
if ($hook() === true) {
|
||||
logger()->info('Patched source [' . $name . '] after extracted');
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ class SourcePatcher
|
||||
);
|
||||
}
|
||||
|
||||
public static function patchMicro(): bool
|
||||
public static function patchMicro(?array $list = null, bool $reverse = false): bool
|
||||
{
|
||||
if (!file_exists(SOURCE_PATH . '/php-src/sapi/micro/php_micro.c')) {
|
||||
return false;
|
||||
@ -137,7 +137,7 @@ class SourcePatcher
|
||||
$check = !defined('DEBUG_MODE') ? ' -q' : '';
|
||||
// f_passthru('cd ' . SOURCE_PATH . '/php-src && git checkout' . $check . ' HEAD');
|
||||
|
||||
$patch_list = [
|
||||
$default = [
|
||||
'static_opcache',
|
||||
'static_extensions_win32',
|
||||
'cli_checks',
|
||||
@ -146,15 +146,13 @@ class SourcePatcher
|
||||
'win32',
|
||||
'zend_stream',
|
||||
];
|
||||
$patch_list = array_merge($patch_list, match (PHP_OS_FAMILY) {
|
||||
'Windows' => [
|
||||
'cli_static',
|
||||
],
|
||||
'Darwin' => [
|
||||
'macos_iconv',
|
||||
],
|
||||
default => [],
|
||||
});
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
$default[] = 'cli_static';
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
$default[] = 'macos_iconv';
|
||||
}
|
||||
$patch_list = $list ?? $default;
|
||||
$patches = [];
|
||||
$serial = ['80', '81', '82'];
|
||||
foreach ($patch_list as $patchName) {
|
||||
@ -177,8 +175,9 @@ class SourcePatcher
|
||||
|
||||
f_passthru(
|
||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
||||
(PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1'
|
||||
(PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1 ' . ($reverse ? '-R' : '')
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user