Merge branch 'main' into feat/intl-win

This commit is contained in:
Marc
2025-06-25 10:28:45 +07:00
committed by GitHub
164 changed files with 3374 additions and 1744 deletions

View File

@@ -40,7 +40,7 @@ const SPC_EXTENSION_ALIAS = [
'zendopcache' => 'opcache',
];
// spc lock type
// spc download lock type
const SPC_DOWNLOAD_SOURCE = 1; // lock source
const SPC_DOWNLOAD_PRE_BUILT = 2; // lock pre-built
const SPC_DOWNLOAD_PACKAGE = 3; // lock as package
@@ -62,7 +62,8 @@ const BUILD_TARGET_CLI = 1; // build cli
const BUILD_TARGET_MICRO = 2; // build micro
const BUILD_TARGET_FPM = 4; // build fpm
const BUILD_TARGET_EMBED = 8; // build embed
const BUILD_TARGET_ALL = 15; // build all
const BUILD_TARGET_FRANKENPHP = 16; // build frankenphp
const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all
// doctor error fix policy
const FIX_POLICY_DIE = 1; // die directly
@@ -84,5 +85,10 @@ const AUTOCONF_CPPFLAGS = 4;
const AUTOCONF_LDFLAGS = 8;
const AUTOCONF_ALL = 15;
// spc download source type
const SPC_SOURCE_ARCHIVE = 'archive'; // download as archive
const SPC_SOURCE_GIT = 'git'; // download as git repository
const SPC_SOURCE_LOCAL = 'local'; // download as local directory
ConsoleLogger::$date_format = 'H:i:s';
ConsoleLogger::$format = '[%date%] [%level_short%] %body%';

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
assert(function_exists('brotli_compress'));
assert(function_exists('brotli_uncompress'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = brotli_compress($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = brotli_uncompress($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@@ -2,7 +2,14 @@
declare(strict_types=1);
$str = 'This is bz2 extension test';
assert(function_exists('bzdecompress'));
assert(function_exists('bzcompress'));
assert(bzdecompress(bzcompress($str, 9)) === $str);
assert(function_exists('bzdecompress'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = bzcompress($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = bzdecompress($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
assert(function_exists('xzencode'));
assert(function_exists('xzdecode'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = xzencode($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = xzdecode($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@@ -2,5 +2,14 @@
declare(strict_types=1);
assert(function_exists('gzcompress'));
assert(gzdecode(gzencode('aaa')) === 'aaa');
assert(function_exists('gzencode'));
assert(function_exists('gzdecode'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = gzencode($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = gzdecode($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
assert(function_exists('zstd_compress'));
assert(function_exists('zstd_uncompress'));
$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10);
$compressed = zstd_compress($input);
assert(is_string($compressed));
assert(strlen($compressed) < strlen($input));
$uncompressed = zstd_uncompress($compressed);
assert(is_string($uncompressed));
assert($uncompressed === $input);

View File

@@ -102,6 +102,17 @@ function osfamily2dir(): string
};
}
function osfamily2shortname(): string
{
return match (PHP_OS_FAMILY) {
'Windows' => 'win',
'Darwin' => 'macos',
'Linux' => 'linux',
'BSD' => 'bsd',
default => throw new WrongUsageException('Not support os: ' . PHP_OS_FAMILY),
};
}
function shell(?bool $debug = null): UnixShell
{
/* @noinspection PhpUnhandledExceptionInspection */
@@ -216,3 +227,8 @@ function cmake_boolean_args(string $arg_name, bool $negative = false): array
$res = ["-D{$arg_name}=ON", "-D{$arg_name}=OFF"];
return $negative ? array_reverse($res) : $res;
}
function ac_with_args(string $arg_name, bool $use_value = false): array
{
return $use_value ? ["--with-{$arg_name}=yes", "--with-{$arg_name}=no"] : ["--with-{$arg_name}", "--without-{$arg_name}"];
}

View File

@@ -9,10 +9,17 @@ use SPC\builder\windows\SystemUtil as WindowsSystemUtil;
use SPC\store\FileSystem;
use SPC\util\GlobalEnvManager;
// output path for everything, other paths are defined relative to this by default
define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot')));
// output path for header files for development
define('BUILD_INCLUDE_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include')));
// output path for libraries and for libphp.so, if building shared embed
define('BUILD_LIB_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib')));
// output path for binaries
define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin')));
// output path for shared extensions
define('BUILD_MODULES_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_MODULES_PATH')) ? $a : (BUILD_ROOT_PATH . '/modules')));
define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . '/pkgroot')));
define('SOURCE_PATH', FileSystem::convertPath(is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')));
define('DOWNLOAD_PATH', FileSystem::convertPath(is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')));

View File

@@ -0,0 +1,31 @@
--- a/ext/ffi/ffi.c 2025-01-17 10:37:37
+++ a/ext/ffi/ffi.c 2025-01-17 10:39:17
@@ -57,6 +57,8 @@
/* XXX need something better, perhaps with regard to SIMD, etc. */
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
#endif
+
+#define ZEND_STRNCMP(s,str) strncmp((s),(str),(sizeof(str)-1))
ZEND_DECLARE_MODULE_GLOBALS(ffi)
@@ -5046,16 +5048,16 @@ static char *zend_ffi_parse_directives(const char *fil
*scope_name = NULL;
*lib = NULL;
while (*code_pos == '#') {
- if (strncmp(code_pos, ZEND_STRL("#define")) == 0) {
+ if (ZEND_STRNCMP(code_pos, "#define") == 0) {
p = zend_ffi_skip_ws_and_comments(code_pos + sizeof("#define") - 1, false);
char **target = NULL;
const char *target_name = NULL;
- if (strncmp(p, ZEND_STRL("FFI_SCOPE")) == 0) {
+ if (ZEND_STRNCMP(p, "FFI_SCOPE") == 0) {
p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_SCOPE") - 1, false);
target = scope_name;
target_name = "FFI_SCOPE";
- } else if (strncmp(p, ZEND_STRL("FFI_LIB")) == 0) {
+ } else if (ZEND_STRNCMP(p, "FFI_LIB") == 0) {
p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_LIB") - 1, false);
target = lib;
target_name = "FFI_LIB";

View File

@@ -33,15 +33,18 @@ $test_os = [
];
// whether enable thread safe
$zts = false;
$zts = true;
$no_strip = false;
// compress with upx
$upx = false;
// whether to test frankenphp build, only available for macos and linux
$frankenphp = false;
// prefer downloading pre-built packages to speed up the build process
$prefer_pre_built = false;
$prefer_pre_built = true;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
@@ -51,11 +54,15 @@ $extensions = match (PHP_OS_FAMILY) {
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
$shared_extensions = match (PHP_OS_FAMILY) {
'Linux' => '',
'Windows', 'Darwin' => '',
'Linux' => 'uv',
'Darwin' => '',
'Windows' => '',
};
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
// If you want to test lib-suggests for all extensions and libraries, set it to true.
$with_suggested_libs = false;
// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true.
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '',
'Windows' => '',
@@ -168,6 +175,7 @@ if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') {
$build_cmd = 'build ';
$build_cmd .= quote2($final_extensions) . ' ';
$build_cmd .= $shared_cmd;
$build_cmd .= $with_suggested_libs ? '--with-suggested-libs ' : '';
$build_cmd .= $zts ? '--enable-zts ' : '';
$build_cmd .= $no_strip ? '--no-strip ' : '';
$build_cmd .= $upx ? '--with-upx-pack ' : '';
@@ -203,7 +211,13 @@ switch ($argv[1] ?? null) {
passthru($prefix . $build_cmd . ' --build-cli --build-micro', $retcode);
break;
case 'build_embed_cmd':
passthru($prefix . $build_cmd . (str_starts_with($argv[2], 'windows-') ? ' --build-cli' : ' --build-embed'), $retcode);
if ($frankenphp) {
passthru("{$prefix}install-pkg go-xcaddy --debug", $retcode);
if ($retcode !== 0) {
break;
}
}
passthru($prefix . $build_cmd . (str_starts_with($argv[2], 'windows-') ? ' --build-cli' : (' --build-embed' . ($frankenphp ? ' --build-frankenphp' : ''))), $retcode);
break;
case 'doctor_cmd':
passthru($prefix . $doctor_cmd, $retcode);