mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
Add SPC_MICRO_PATCHES env var
This commit is contained in:
parent
d5832c22e3
commit
0665af2537
@ -45,14 +45,15 @@ These environment variables are system-specific and will only take effect on a s
|
|||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
| var name | default value | comment |
|
| var name | default value | comment |
|
||||||
|----------------|------------------------------|---------------------------|
|
|---------------------|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
|
||||||
| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK tools path |
|
| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK tools path |
|
||||||
| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX compression tool path |
|
| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX compression tool path |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
| var name | default value | comment |
|
| var name | default value | comment |
|
||||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
|
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
|
||||||
| `CC` | `clang` | C Compiler |
|
| `CC` | `clang` | C Compiler |
|
||||||
| `CXX` | `clang++` | C++ Compiler |
|
| `CXX` | `clang++` | C++ Compiler |
|
||||||
| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` or `--target=x86_64-apple-darwin` | Default C flags (not the same as `CFLAGS`) |
|
| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` or `--target=x86_64-apple-darwin` | Default C flags (not the same as `CFLAGS`) |
|
||||||
@ -65,6 +66,7 @@ These environment variables are system-specific and will only take effect on a s
|
|||||||
| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | `LDFLAGS` variable of PHP `configure` command |
|
| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | `LDFLAGS` variable of PHP `configure` command |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` or `-g -O0` (the latter when using `--no-strip`) | `EXTRA_CFLAGS` variable of PHP `make` command |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` or `-g -O0` (the latter when using `--no-strip`) | `EXTRA_CFLAGS` variable of PHP `make` command |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | Extra `EXTRA_LIBS` variables for PHP `make` command |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | Extra `EXTRA_LIBS` variables for PHP `make` command |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
@ -90,6 +92,7 @@ These environment variables are system-specific and will only take effect on a s
|
|||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | Extra `EXTRA_LIBS` variables for PHP `make` command |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | Extra `EXTRA_LIBS` variables for PHP `make` command |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static` (when using `clang`: `-Xcompiler -fuse-ld=lld -all-static`) | Additional `LDFLAGS` variable for `make` command |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static` (when using `clang`: `-Xcompiler -fuse-ld=lld -all-static`) | Additional `LDFLAGS` variable for `make` command |
|
||||||
| `SPC_NO_MUSL_PATH` | empty | Whether to not insert the PATH of the musl toolchain (not inserted when the value is `yes`) |
|
| `SPC_NO_MUSL_PATH` | empty | Whether to not insert the PATH of the musl toolchain (not inserted when the value is `yes`) |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
> `{ld_lib_path}` value is `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。
|
> `{ld_lib_path}` value is `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。
|
||||||
|
|
||||||
### FreeBSD
|
### FreeBSD
|
||||||
|
|||||||
@ -43,14 +43,15 @@ SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli
|
|||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
| var name | default value | comment |
|
| var name | default value | comment |
|
||||||
|----------------|------------------------------|-----------------|
|
|---------------------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
|
||||||
| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK 工具的安装目录 |
|
| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK 工具的安装目录 |
|
||||||
| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX 压缩工具的路径 |
|
| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX 压缩工具的路径 |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
| var name | default value | comment |
|
| var name | default value | comment |
|
||||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
|
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
|
||||||
| `CC` | `clang` | C 编译器 |
|
| `CC` | `clang` | C 编译器 |
|
||||||
| `CXX` | `clang++` | C++ 编译器 |
|
| `CXX` | `clang++` | C++ 编译器 |
|
||||||
| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` 或 `--target=x86_64-apple-darwin` | 默认 C 编译标志(与 `CFLAGS` 不同) |
|
| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` 或 `--target=x86_64-apple-darwin` | 默认 C 编译标志(与 `CFLAGS` 不同) |
|
||||||
@ -63,11 +64,12 @@ SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli
|
|||||||
| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | PHP `configure` 命令的 `LDFLAGS` 变量 |
|
| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | PHP `configure` 命令的 `LDFLAGS` 变量 |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` 或 `-g -O0`(当使用 `--no-strip` 时为后者) | PHP `make` 命令的 `EXTRA_CFLAGS` 变量 |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` 或 `-g -O0`(当使用 `--no-strip` 时为后者) | PHP `make` 命令的 `EXTRA_CFLAGS` 变量 |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
| var name | default value | comment |
|
| var name | default value | comment |
|
||||||
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
|
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
|
||||||
| `UPX_EXEC` | `$PKG_ROOT_PATH/bin/upx` | UPX 压缩工具的路径 |
|
| `UPX_EXEC` | `$PKG_ROOT_PATH/bin/upx` | UPX 压缩工具的路径 |
|
||||||
| `GNU_ARCH` | `x86_64` 或 `aarch64` | 当前环境的 CPU 架构 |
|
| `GNU_ARCH` | `x86_64` 或 `aarch64` | 当前环境的 CPU 架构 |
|
||||||
| `CC` | Alpine: `gcc`, Other: `$GNU_ARCH-linux-musl-gcc` | C 编译器 |
|
| `CC` | Alpine: `gcc`, Other: `$GNU_ARCH-linux-musl-gcc` | C 编译器 |
|
||||||
@ -88,6 +90,8 @@ SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli
|
|||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 |
|
||||||
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static`(当使用 `clang` 时:`-Xcompiler -fuse-ld=lld -all-static`) | `make` 命令的额外 `LDFLAGS` 变量(用于编译程序) |
|
| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static`(当使用 `clang` 时:`-Xcompiler -fuse-ld=lld -all-static`) | `make` 命令的额外 `LDFLAGS` 变量(用于编译程序) |
|
||||||
| `SPC_NO_MUSL_PATH` | empty | 是否不插入 musl 工具链的 PATH(值为 `yes` 时不插入) |
|
| `SPC_NO_MUSL_PATH` | empty | 是否不插入 musl 工具链的 PATH(值为 `yes` 时不插入) |
|
||||||
|
| `SPC_MICRO_PATCHES` | `static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) |
|
||||||
|
|
||||||
> `{ld_lib_path}` 值为 `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。
|
> `{ld_lib_path}` 值为 `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。
|
||||||
|
|
||||||
### FreeBSD
|
### FreeBSD
|
||||||
|
|||||||
@ -28,7 +28,7 @@ use Symfony\Component\Console\Application;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION = '2.3.2';
|
public const VERSION = '2.3.3';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -108,22 +108,9 @@ class SourcePatcher
|
|||||||
// $check = !defined('DEBUG_MODE') ? ' -q' : '';
|
// $check = !defined('DEBUG_MODE') ? ' -q' : '';
|
||||||
// f_passthru('cd ' . SOURCE_PATH . '/php-src && git checkout' . $check . ' HEAD');
|
// f_passthru('cd ' . SOURCE_PATH . '/php-src && git checkout' . $check . ' HEAD');
|
||||||
|
|
||||||
$default = [
|
$spc_micro_patches = getenv('SPC_MICRO_PATCHES');
|
||||||
'static_opcache',
|
$spc_micro_patches = $spc_micro_patches === false ? [] : explode(',', $spc_micro_patches);
|
||||||
'static_extensions_win32',
|
$patch_list = $spc_micro_patches;
|
||||||
'cli_checks',
|
|
||||||
'disable_huge_page',
|
|
||||||
'vcruntime140',
|
|
||||||
'win32',
|
|
||||||
'zend_stream',
|
|
||||||
];
|
|
||||||
if (PHP_OS_FAMILY === 'Windows') {
|
|
||||||
$default[] = 'cli_static';
|
|
||||||
}
|
|
||||||
if (PHP_OS_FAMILY === 'Darwin') {
|
|
||||||
$default[] = 'macos_iconv';
|
|
||||||
}
|
|
||||||
$patch_list = $default;
|
|
||||||
$patches = [];
|
$patches = [];
|
||||||
$serial = ['80', '81', '82', '83', '84'];
|
$serial = ['80', '81', '82', '83', '84'];
|
||||||
foreach ($patch_list as $patchName) {
|
foreach ($patch_list as $patchName) {
|
||||||
@ -142,12 +129,14 @@ class SourcePatcher
|
|||||||
throw new RuntimeException("failed finding patch {$patchName}");
|
throw new RuntimeException("failed finding patch {$patchName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
$patchesStr = str_replace('/', DIRECTORY_SEPARATOR, implode(' ', $patches));
|
foreach ($patches as $patch) {
|
||||||
|
logger()->info("Patching micro with {$patch}");
|
||||||
|
$patchesStr = str_replace('/', DIRECTORY_SEPARATOR, $patch);
|
||||||
f_passthru(
|
f_passthru(
|
||||||
'cd ' . SOURCE_PATH . '/php-src && ' .
|
'cd ' . SOURCE_PATH . '/php-src && ' .
|
||||||
(PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1 '
|
(PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1 '
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,7 @@ class GlobalEnvManager
|
|||||||
// Windows need php-sdk binary tools
|
// Windows need php-sdk binary tools
|
||||||
self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools');
|
self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools');
|
||||||
self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'upx.exe');
|
self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'upx.exe');
|
||||||
|
self::initIfNotExists('SPC_MICRO_PATCHES', 'static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function initLinuxEnv(BuilderBase $builder): void
|
private static function initLinuxEnv(BuilderBase $builder): void
|
||||||
@ -90,6 +91,9 @@ class GlobalEnvManager
|
|||||||
self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', '');
|
self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', '');
|
||||||
self::initIfNotExists('SPC_EXTRA_LIBS', '');
|
self::initIfNotExists('SPC_EXTRA_LIBS', '');
|
||||||
|
|
||||||
|
// SPC_MICRO_PATCHES for linux
|
||||||
|
self::initIfNotExists('SPC_MICRO_PATCHES', 'static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream');
|
||||||
|
|
||||||
// Init linux-only env
|
// Init linux-only env
|
||||||
self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . '/bin/upx');
|
self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . '/bin/upx');
|
||||||
self::initIfNotExists('GNU_ARCH', arch2gnu(php_uname('m')));
|
self::initIfNotExists('GNU_ARCH', arch2gnu(php_uname('m')));
|
||||||
@ -140,6 +144,9 @@ class GlobalEnvManager
|
|||||||
// Init extra libs (will be appended before `before-php-buildconf` event point)
|
// Init extra libs (will be appended before `before-php-buildconf` event point)
|
||||||
self::initIfNotExists('SPC_EXTRA_LIBS', '');
|
self::initIfNotExists('SPC_EXTRA_LIBS', '');
|
||||||
|
|
||||||
|
// SPC_MICRO_PATCHES for macOS
|
||||||
|
self::initIfNotExists('SPC_MICRO_PATCHES', 'static_opcache,static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv');
|
||||||
|
|
||||||
$init_spc_cmd_maps = [
|
$init_spc_cmd_maps = [
|
||||||
// Init default build command prefix
|
// Init default build command prefix
|
||||||
'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force',
|
'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user