mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-13 20:05:35 +08:00
Merge remote-tracking branch 'origin' into fix/frankenphp-readline
This commit is contained in:
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@@ -1,13 +1,9 @@
|
|||||||
name: Tests
|
name: Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'src/globals/test-extensions.php'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
types: [ opened, synchronize, reopened ]
|
||||||
paths:
|
paths:
|
||||||
- 'src/**'
|
- 'src/**'
|
||||||
- 'config/**'
|
- 'config/**'
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
|
|||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
||||||
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
|
||||||
if [ -f "$(pwd)/craft.yml" ]; then
|
if [ -f "$(pwd)/craft.yml" ]; then
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
|
|||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
|
||||||
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
|
||||||
if [ -f "$(pwd)/craft.yml" ]; then
|
if [ -f "$(pwd)/craft.yml" ]; then
|
||||||
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
|
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1001,7 +1001,7 @@
|
|||||||
"spx": {
|
"spx": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"rev": "master",
|
"rev": "master",
|
||||||
"url": "https://github.com/static-php/php-spx.git",
|
"url": "https://github.com/NoiseByNorthwest/php-spx.git",
|
||||||
"path": "php-src/ext/spx",
|
"path": "php-src/ext/spx",
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class spx extends Extension
|
|||||||
{
|
{
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
{
|
{
|
||||||
$arg = '--enable-spx' . ($shared ? '=shared' : '');
|
$arg = '--enable-SPX' . ($shared ? '=shared' : '');
|
||||||
if ($this->builder->getLib('zlib') !== null) {
|
if ($this->builder->getLib('zlib') !== null) {
|
||||||
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
|
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
|
||||||
}
|
}
|
||||||
@@ -29,4 +29,20 @@ class spx extends Extension
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
$this->source_dir . '/config.m4',
|
||||||
|
'CFLAGS="$CFLAGS -Werror -Wall -O3 -pthread -std=gnu90"',
|
||||||
|
'CFLAGS="$CFLAGS -pthread"'
|
||||||
|
);
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
$this->source_dir . '/src/php_spx.h',
|
||||||
|
"extern zend_module_entry spx_module_entry;\n",
|
||||||
|
"extern zend_module_entry spx_module_entry;;\n#define phpext_spx_ptr &spx_module_entry\n"
|
||||||
|
);
|
||||||
|
FileSystem::copy($this->source_dir . '/src/php_spx.h', $this->source_dir . '/php_spx.h');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,11 +222,9 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
|
|
||||||
// ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ----------
|
// ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ----------
|
||||||
$build_root_path = BUILD_ROOT_PATH;
|
$build_root_path = BUILD_ROOT_PATH;
|
||||||
$cwd = getcwd();
|
|
||||||
$fixed = '';
|
$fixed = '';
|
||||||
|
$build_root_path = get_display_path($build_root_path);
|
||||||
if (!empty(getenv('SPC_FIX_DEPLOY_ROOT'))) {
|
if (!empty(getenv('SPC_FIX_DEPLOY_ROOT'))) {
|
||||||
str_replace($cwd, '', $build_root_path);
|
|
||||||
$build_root_path = getenv('SPC_FIX_DEPLOY_ROOT') . '/' . basename($build_root_path);
|
|
||||||
$fixed = ' (host system)';
|
$fixed = ' (host system)';
|
||||||
}
|
}
|
||||||
if (($rule & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
if (($rule & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
||||||
|
|||||||
@@ -137,13 +137,18 @@ class ExceptionHandler
|
|||||||
|
|
||||||
self::logError("\n----------------------------------------\n");
|
self::logError("\n----------------------------------------\n");
|
||||||
|
|
||||||
self::logError('⚠ The ' . ConsoleColor::cyan('console output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none(SPC_OUTPUT_LOG));
|
// convert log file path if in docker
|
||||||
|
$spc_log_convert = get_display_path(SPC_OUTPUT_LOG);
|
||||||
|
$shell_log_convert = get_display_path(SPC_SHELL_LOG);
|
||||||
|
$spc_logs_dir_convert = get_display_path(SPC_LOGS_DIR);
|
||||||
|
|
||||||
|
self::logError('⚠ The ' . ConsoleColor::cyan('console output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none($spc_log_convert));
|
||||||
if (file_exists(SPC_SHELL_LOG)) {
|
if (file_exists(SPC_SHELL_LOG)) {
|
||||||
self::logError('⚠ The ' . ConsoleColor::cyan('shell output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none(SPC_SHELL_LOG));
|
self::logError('⚠ The ' . ConsoleColor::cyan('shell output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none($shell_log_convert));
|
||||||
}
|
}
|
||||||
if ($e->getExtraLogFiles() !== []) {
|
if ($e->getExtraLogFiles() !== []) {
|
||||||
foreach ($e->getExtraLogFiles() as $key => $file) {
|
foreach ($e->getExtraLogFiles() as $key => $file) {
|
||||||
self::logError("⚠ Log file [{$key}] is saved in: " . ConsoleColor::none(SPC_LOGS_DIR . "/{$file}"));
|
self::logError("⚠ Log file [{$key}] is saved in: " . ConsoleColor::none("{$spc_logs_dir_convert}/{$file}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!defined('DEBUG_MODE')) {
|
if (!defined('DEBUG_MODE')) {
|
||||||
|
|||||||
@@ -300,3 +300,20 @@ function strip_ansi_colors(string $text): string
|
|||||||
// Including color codes, cursor control, clear screen and other control sequences
|
// Including color codes, cursor control, clear screen and other control sequences
|
||||||
return preg_replace('/\e\[[0-9;]*[a-zA-Z]/', '', $text);
|
return preg_replace('/\e\[[0-9;]*[a-zA-Z]/', '', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert to a real path for display purposes, used in docker volumes.
|
||||||
|
*/
|
||||||
|
function get_display_path(string $path): string
|
||||||
|
{
|
||||||
|
$deploy_root = getenv('SPC_FIX_DEPLOY_ROOT');
|
||||||
|
if ($deploy_root === false) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
$cwd = WORKING_DIR;
|
||||||
|
// replace build root with deploy root, only if path starts with build root
|
||||||
|
if (str_starts_with($path, $cwd)) {
|
||||||
|
return $deploy_root . substr($path, strlen($cwd));
|
||||||
|
}
|
||||||
|
throw new WrongUsageException("Cannot convert path: {$path}");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user