Skip to content

Commit e281d26

Browse files
committed
Merge remote-tracking branch 'origin' into fix/frankenphp-readline
2 parents 8ed68f4 + 15638ce commit e281d26

File tree

8 files changed

+47
-13
lines changed

8 files changed

+47
-13
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
name: Tests
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- 'src/globals/test-extensions.php'
94
pull_request:
105
branches: [ "main" ]
6+
types: [ opened, synchronize, reopened ]
117
paths:
128
- 'src/**'
139
- 'config/**'

bin/spc-alpine-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
150150
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
151151
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
152152
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
153+
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
153154
if [ -f "$(pwd)/craft.yml" ]; then
154155
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
155156
fi

bin/spc-gnu-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
158158
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
159159
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
160160
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
161+
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
161162
if [ -f "$(pwd)/craft.yml" ]; then
162163
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
163164
fi

config/source.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@
10011001
"spx": {
10021002
"type": "git",
10031003
"rev": "master",
1004-
"url": "https://github.com/static-php/php-spx.git",
1004+
"url": "https://github.com/NoiseByNorthwest/php-spx.git",
10051005
"path": "php-src/ext/spx",
10061006
"license": {
10071007
"type": "file",

src/SPC/builder/extension/spx.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class spx extends Extension
1313
{
1414
public function getUnixConfigureArg(bool $shared = false): string
1515
{
16-
$arg = '--enable-spx' . ($shared ? '=shared' : '');
16+
$arg = '--enable-SPX' . ($shared ? '=shared' : '');
1717
if ($this->builder->getLib('zlib') !== null) {
1818
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
1919
}
@@ -29,4 +29,20 @@ public function patchBeforeConfigure(): bool
2929
);
3030
return true;
3131
}
32+
33+
public function patchBeforeBuildconf(): bool
34+
{
35+
FileSystem::replaceFileStr(
36+
$this->source_dir . '/config.m4',
37+
'CFLAGS="$CFLAGS -Werror -Wall -O3 -pthread -std=gnu90"',
38+
'CFLAGS="$CFLAGS -pthread"'
39+
);
40+
FileSystem::replaceFileStr(
41+
$this->source_dir . '/src/php_spx.h',
42+
"extern zend_module_entry spx_module_entry;\n",
43+
"extern zend_module_entry spx_module_entry;;\n#define phpext_spx_ptr &spx_module_entry\n"
44+
);
45+
FileSystem::copy($this->source_dir . '/src/php_spx.h', $this->source_dir . '/php_spx.h');
46+
return true;
47+
}
3248
}

src/SPC/command/BuildPHPCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,9 @@ public function handle(): int
222222

223223
// ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ----------
224224
$build_root_path = BUILD_ROOT_PATH;
225-
$cwd = getcwd();
226225
$fixed = '';
226+
$build_root_path = get_display_path($build_root_path);
227227
if (!empty(getenv('SPC_FIX_DEPLOY_ROOT'))) {
228-
str_replace($cwd, '', $build_root_path);
229-
$build_root_path = getenv('SPC_FIX_DEPLOY_ROOT') . '/' . basename($build_root_path);
230228
$fixed = ' (host system)';
231229
}
232230
if (($rule & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {

src/SPC/exception/ExceptionHandler.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,18 @@ public static function handleSPCException(SPCException $e): void
137137

138138
self::logError("\n----------------------------------------\n");
139139

140-
self::logError('⚠ The ' . ConsoleColor::cyan('console output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none(SPC_OUTPUT_LOG));
140+
// convert log file path if in docker
141+
$spc_log_convert = get_display_path(SPC_OUTPUT_LOG);
142+
$shell_log_convert = get_display_path(SPC_SHELL_LOG);
143+
$spc_logs_dir_convert = get_display_path(SPC_LOGS_DIR);
144+
145+
self::logError('⚠ The ' . ConsoleColor::cyan('console output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none($spc_log_convert));
141146
if (file_exists(SPC_SHELL_LOG)) {
142-
self::logError('⚠ The ' . ConsoleColor::cyan('shell output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none(SPC_SHELL_LOG));
147+
self::logError('⚠ The ' . ConsoleColor::cyan('shell output log') . ConsoleColor::red(' is saved in ') . ConsoleColor::none($shell_log_convert));
143148
}
144149
if ($e->getExtraLogFiles() !== []) {
145150
foreach ($e->getExtraLogFiles() as $key => $file) {
146-
self::logError("⚠ Log file [{$key}] is saved in: " . ConsoleColor::none(SPC_LOGS_DIR . "/{$file}"));
151+
self::logError("⚠ Log file [{$key}] is saved in: " . ConsoleColor::none("{$spc_logs_dir_convert}/{$file}"));
147152
}
148153
}
149154
if (!defined('DEBUG_MODE')) {

src/globals/functions.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,20 @@ function strip_ansi_colors(string $text): string
300300
// Including color codes, cursor control, clear screen and other control sequences
301301
return preg_replace('/\e\[[0-9;]*[a-zA-Z]/', '', $text);
302302
}
303+
304+
/**
305+
* Convert to a real path for display purposes, used in docker volumes.
306+
*/
307+
function get_display_path(string $path): string
308+
{
309+
$deploy_root = getenv('SPC_FIX_DEPLOY_ROOT');
310+
if ($deploy_root === false) {
311+
return $path;
312+
}
313+
$cwd = WORKING_DIR;
314+
// replace build root with deploy root, only if path starts with build root
315+
if (str_starts_with($path, $cwd)) {
316+
return $deploy_root . substr($path, strlen($cwd));
317+
}
318+
throw new WrongUsageException("Cannot convert path: {$path}");
319+
}

0 commit comments

Comments
 (0)