Merge remote-tracking branch 'origin/main' into zig

This commit is contained in:
DubbleClick 2025-06-26 12:30:50 +07:00
commit d30ccb810c
13 changed files with 145 additions and 55 deletions

View File

@ -190,7 +190,7 @@ jobs:
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV
- name: "Run Build Tests (download)" - name: "Run Build Tests (download)"
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }} run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Run Build Tests (build)" - name: "Run Build Tests (build)"
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }} run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}

View File

@ -304,12 +304,14 @@
}, },
"intl": { "intl": {
"support": { "support": {
"Windows": "no",
"BSD": "wip" "BSD": "wip"
}, },
"type": "builtin", "type": "builtin",
"lib-depends": [ "lib-depends-unix": [
"icu" "icu"
],
"lib-depends-windows": [
"icu-static-win"
] ]
}, },
"ldap": { "ldap": {
@ -336,6 +338,9 @@
}, },
"type": "builtin", "type": "builtin",
"arg-type": "none", "arg-type": "none",
"ext-depends": [
"xml"
],
"target": [ "target": [
"static" "static"
] ]

View File

@ -207,6 +207,18 @@
"libicudata.a" "libicudata.a"
] ]
}, },
"icu-static-win": {
"source": "icu-static-win",
"static-libs-windows": [
"icudt.lib",
"icuin.lib",
"icuio.lib",
"icuuc.lib"
],
"headers-windows": [
"unicode"
]
},
"imagemagick": { "imagemagick": {
"source": "imagemagick", "source": "imagemagick",
"static-libs-unix": [ "static-libs-unix": [

View File

@ -342,6 +342,14 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"icu-static-win": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip",
"license": {
"type": "text",
"text": "none"
}
},
"igbinary": { "igbinary": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/igbinary", "url": "https://pecl.php.net/get/igbinary",

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\windows\WindowsBuilder;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@ -13,13 +14,15 @@ class intl extends Extension
{ {
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
// TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released if ($this->builder instanceof WindowsBuilder) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17'); FileSystem::replaceFileStr(
// Also need to use clang++ -std=c++17 to force override the default C++ standard SOURCE_PATH . '/php-src/ext/intl/config.w32',
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) { 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,',
f_putenv('CXX=' . $env . ' -std=c++17'); 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", PHP_INTL_SHARED,'
);
return true;
} }
return true; return false;
} }
public function patchBeforeSharedPhpize(): bool public function patchBeforeSharedPhpize(): bool

View File

@ -28,7 +28,7 @@ class LinuxBuilder extends UnixBuilderBase
// check musl-cross make installed if we use musl-cross-make // check musl-cross make installed if we use musl-cross-make
$arch = arch2gnu(php_uname('m')); $arch = arch2gnu(php_uname('m'));
GlobalEnvManager::init($this); GlobalEnvManager::init();
if (getenv('SPC_LIBC') === 'musl' && !SystemUtil::isMuslDist()) { if (getenv('SPC_LIBC') === 'musl' && !SystemUtil::isMuslDist()) {
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\""); $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");

View File

@ -28,7 +28,7 @@ class MacOSBuilder extends UnixBuilderBase
$this->options = $options; $this->options = $options;
// apply global environment variables // apply global environment variables
GlobalEnvManager::init($this); GlobalEnvManager::init();
// ---------- set necessary compile vars ---------- // ---------- set necessary compile vars ----------
// concurrency // concurrency

View File

@ -33,7 +33,7 @@ class WindowsBuilder extends BuilderBase
{ {
$this->options = $options; $this->options = $options;
GlobalEnvManager::init($this); GlobalEnvManager::init();
// ---------- set necessary options ---------- // ---------- set necessary options ----------
// set sdk (require visual studio 16 or 17) // set sdk (require visual studio 16 or 17)

View File

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class icu_static_win extends WindowsLibraryBase
{
public const NAME = 'icu-static-win';
protected function build(): void
{
copy("{$this->source_dir}\\x64-windows-static\\lib\\icudt.lib", "{$this->getLibDir()}\\icudt.lib");
copy("{$this->source_dir}\\x64-windows-static\\lib\\icuin.lib", "{$this->getLibDir()}\\icuin.lib");
copy("{$this->source_dir}\\x64-windows-static\\lib\\icuio.lib", "{$this->getLibDir()}\\icuio.lib");
copy("{$this->source_dir}\\x64-windows-static\\lib\\icuuc.lib", "{$this->getLibDir()}\\icuuc.lib");
// create libpq folder in buildroot/includes/libpq
if (!file_exists("{$this->getIncludeDir()}\\unicode")) {
mkdir("{$this->getIncludeDir()}\\unicode");
}
FileSystem::copyDir("{$this->source_dir}\\x64-windows-static\\include\\unicode", "{$this->getIncludeDir()}\\unicode");
}
}

View File

@ -22,6 +22,8 @@ class DeleteDownloadCommand extends BaseCommand
{ {
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources/packages will be deleted, comma separated'); $this->addArgument('sources', InputArgument::REQUIRED, 'The sources/packages will be deleted, comma separated');
$this->addOption('all', 'A', null, 'Delete all downloaded and locked sources/packages'); $this->addOption('all', 'A', null, 'Delete all downloaded and locked sources/packages');
$this->addOption('pre-built-only', 'W', null, 'Delete only pre-built sources/packages, not the original ones');
$this->addOption('source-only', 'S', null, 'Delete only sources, not the pre-built packages');
} }
public function initialize(InputInterface $input, OutputInterface $output): void public function initialize(InputInterface $input, OutputInterface $output): void
@ -51,10 +53,11 @@ class DeleteDownloadCommand extends BaseCommand
$deleted_sources = []; $deleted_sources = [];
foreach ($chosen_sources as $source) { foreach ($chosen_sources as $source) {
$source = trim($source); $source = trim($source);
foreach ([$source, Downloader::getPreBuiltLockName($source)] as $name) { if (LockFile::get($source) && !$this->getOption('pre-built-only')) {
if (LockFile::get($name)) { $deleted_sources[] = $source;
$deleted_sources[] = $name; }
} if (LockFile::get(Downloader::getPreBuiltLockName($source)) && !$this->getOption('source-only')) {
$deleted_sources[] = Downloader::getPreBuiltLockName($source);
} }
} }

View File

@ -99,9 +99,6 @@ class SourcePatcher
} }
// patch capstone // patch capstone
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"');
if ($builder instanceof LinuxBuilder && getenv('SPC_LIBC') === 'glibc') {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Zend/zend_operators.h', '# define ZEND_USE_ASM_ARITHMETIC 1', '# define ZEND_USE_ASM_ARITHMETIC 0');
}
} }
/** /**

View File

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\util; namespace SPC\util;
use SPC\builder\BuilderBase;
use SPC\builder\linux\SystemUtil; use SPC\builder\linux\SystemUtil;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
@ -24,11 +23,10 @@ class GlobalEnvManager
/** /**
* Initialize the environment variables * Initialize the environment variables
* *
* @param null|BuilderBase $builder Builder
* @throws RuntimeException * @throws RuntimeException
* @throws WrongUsageException * @throws WrongUsageException
*/ */
public static function init(?BuilderBase $builder = null): void public static function init(): void
{ {
// Check pre-defined env vars exists // Check pre-defined env vars exists
if (getenv('BUILD_ROOT_PATH') === false) { if (getenv('BUILD_ROOT_PATH') === false) {
@ -37,7 +35,7 @@ class GlobalEnvManager
// Define env vars for unix // Define env vars for unix
if (is_unix()) { if (is_unix()) {
self::putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); self::addPathIfNotExists(BUILD_BIN_PATH);
self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config'); self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config');
self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig'); self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig');
} }
@ -55,10 +53,73 @@ class GlobalEnvManager
self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++"); self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar"); self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar");
self::putenv("SPC_LINUX_DEFAULT_LD={$arch}-linux-musl-ld"); self::putenv("SPC_LINUX_DEFAULT_LD={$arch}-linux-musl-ld");
GlobalEnvManager::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); self::addPathIfNotExists('/usr/local/musl/bin');
self::addPathIfNotExists("/usr/local/musl/{$arch}-linux-musl/bin");
} }
} }
$ini = self::readIniFile();
$default_put_list = [];
foreach ($ini['global'] as $k => $v) {
if (getenv($k) === false) {
$default_put_list[$k] = $v;
self::putenv("{$k}={$v}");
}
}
$os_ini = match (PHP_OS_FAMILY) {
'Windows' => $ini['windows'] ?? [],
'Darwin' => $ini['macos'] ?? [],
'Linux' => $ini['linux'] ?? [],
'BSD' => $ini['freebsd'] ?? [],
default => [],
};
foreach ($os_ini as $k => $v) {
if (getenv($k) === false) {
$default_put_list[$k] = $v;
self::putenv("{$k}={$v}");
}
}
// apply second time
$ini2 = self::readIniFile();
foreach ($ini2['global'] as $k => $v) {
if (isset($default_put_list[$k]) && $default_put_list[$k] !== $v) {
self::putenv("{$k}={$v}");
}
}
$os_ini2 = match (PHP_OS_FAMILY) {
'Windows' => $ini2['windows'] ?? [],
'Darwin' => $ini2['macos'] ?? [],
'Linux' => $ini2['linux'] ?? [],
'BSD' => $ini2['freebsd'] ?? [],
default => [],
};
foreach ($os_ini2 as $k => $v) {
if (isset($default_put_list[$k]) && $default_put_list[$k] !== $v) {
self::putenv("{$k}={$v}");
}
}
}
public static function putenv(string $val): void
{
f_putenv($val);
self::$env_cache[] = $val;
}
private static function addPathIfNotExists(string $path): void
{
if (is_unix() && !str_contains(getenv('PATH'), $path)) {
self::putenv("PATH={$path}:" . getenv('PATH'));
}
}
/**
* @throws WrongUsageException
*/
private static function readIniFile(): array
{
// Init env.ini file, read order: // Init env.ini file, read order:
// WORKING_DIR/config/env.ini // WORKING_DIR/config/env.ini
// ROOT_DIR/config/env.ini // ROOT_DIR/config/env.ini
@ -100,32 +161,6 @@ class GlobalEnvManager
break; break;
} }
} }
self::applyConfig($ini['global']); return $ini;
match (PHP_OS_FAMILY) {
'Windows' => self::applyConfig($ini['windows']),
'Darwin' => self::applyConfig($ini['macos']),
'Linux' => self::applyConfig($ini['linux']),
'BSD' => self::applyConfig($ini['freebsd']),
default => null,
};
if (str_contains(getenv('CC'), 'zig')) {
// add to path
}
}
public static function putenv(string $val): void
{
f_putenv($val);
self::$env_cache[] = $val;
}
private static function applyConfig(array $ini): void
{
foreach ($ini as $k => $v) {
if (getenv($k) === false) {
self::putenv($k . '=' . $v);
}
}
} }
} }

View File

@ -27,9 +27,9 @@ $test_os = [
// 'ubuntu-latest', // 'ubuntu-latest',
// 'ubuntu-22.04', // 'ubuntu-22.04',
// 'ubuntu-24.04', // 'ubuntu-24.04',
'ubuntu-22.04-arm', // 'ubuntu-22.04-arm',
// 'ubuntu-24.04-arm', // 'ubuntu-24.04-arm',
// 'windows-latest', 'windows-latest',
]; ];
// whether enable thread safe // whether enable thread safe
@ -48,8 +48,8 @@ $prefer_pre_built = true;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,opcache,openssl,pcntl,phar,posix,readline,session,simplexml,sockets,sodium,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Linux', 'Darwin' => 'curl',
'Windows' => 'xlswriter,openssl', 'Windows' => 'intl',
}; };
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).