Compare commits

...

9 Commits

Author SHA1 Message Date
crazywhalecc
65c3263b25
Add ext-spx 2026-03-16 16:59:27 +08:00
crazywhalecc
d79128cdbf
Add ext-sodium 2026-03-16 16:57:51 +08:00
crazywhalecc
ba253ea2a5
Add ext-soap 2026-03-16 16:57:43 +08:00
crazywhalecc
21e2a0194c
Add ext-snmp 2026-03-16 16:48:50 +08:00
crazywhalecc
3f812fe5fc
Fix filename generation for GitHub tarballs to handle missing tag names 2026-03-16 16:48:26 +08:00
crazywhalecc
1670b61ed7
Add ext-snappy 2026-03-16 16:26:53 +08:00
crazywhalecc
15e7678615
Add missing xml-related patches for windows 2026-03-16 16:17:53 +08:00
crazywhalecc
fe302bf8b9
Add ext-simplexml 2026-03-16 16:17:15 +08:00
crazywhalecc
e30a10f60f
Add ext-simdjson, add SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS env var 2026-03-16 16:04:35 +08:00
11 changed files with 242 additions and 1 deletions

View File

@ -121,6 +121,8 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_CXXFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_CXX_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
@ -155,5 +157,9 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_CXXFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS="-g -fstack-protector-strong -fno-ident -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_CXX_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.dylib
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; minimum compatible macOS version (LLVM vars, availability not guaranteed)
MACOSX_DEPLOYMENT_TARGET=12.0

View File

@ -233,8 +233,37 @@ ext-shmop:
type: php-extension
php-extension:
build-with-php: true
ext-simplexml:
type: php-extension
depends:
- ext-xml
php-extension:
arg-type@unix: '--enable-simplexml@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
build-with-php: true
ext-snmp:
type: php-extension
depends:
- net-snmp
php-extension:
arg-type: with
ext-soap:
type: php-extension
depends:
- ext-xml
- ext-session
php-extension:
arg-type@unix: '--enable-soap@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
build-with-php: true
ext-sockets:
type: php-extension
ext-sodium:
type: php-extension
depends:
- libsodium
php-extension:
arg-type: with
ext-sqlite3:
type: php-extension
depends:

View File

@ -0,0 +1,10 @@
ext-simdjson:
type: php-extension
artifact:
source:
type: pecl
name: simdjson
metadata:
license-files: [LICENSE]
license: Apache-2.0
lang: cpp

View File

@ -0,0 +1,18 @@
ext-snappy:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/kjdev/php-ext-snappy'
rev: master
extract: php-src/ext/snappy
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- snappy
suggests:
- ext-apcu
lang: cpp
php-extension:
arg-type@unix: '--enable-snappy --with-snappy-includedir=@build_root_path@'

View File

@ -0,0 +1,14 @@
ext-spx:
type: php-extension
artifact:
source:
type: pie
repo: noisebynorthwest/php-spx
extract: php-src/ext/spx
metadata:
license-files: [LICENSE]
license: GPL-3.0-or-later
depends:
- ext-zlib
php-extension:
arg-type: '--enable-SPX@shared_suffix@'

View File

@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\DI\ApplicationContext;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Toolchain\Interface\ToolchainInterface;
use StaticPHP\Toolchain\ZigToolchain;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\GlobalEnvManager;
#[Extension('simdjson')]
class simdjson extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-simdjson')]
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-simdjson')]
public function patchBeforeBuildconf(PackageInstaller $installer): bool
{
$php = $installer->getTargetPackage('php');
$php_ver = php::getPHPVersionID();
FileSystem::replaceFileRegex(
"{$this->getSourceDir()}/config.m4",
'/php_version=(`.*`)$/m',
"php_version={$php_ver}"
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.m4",
'if test -z "$PHP_CONFIG"; then',
'if false; then'
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.w32",
"'yes',",
'PHP_SIMDJSON_SHARED,'
);
return true;
}
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
if (ApplicationContext::get(ToolchainInterface::class) instanceof ZigToolchain) {
$extra = getenv('SPC_COMPILER_EXTRA');
if (!str_contains((string) $extra, '-lstdc++')) {
f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++'));
}
$env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
$env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
}
return $env;
}
#[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-simdjson')]
public function patchBeforeMake(): void
{
if (!ApplicationContext::get(ToolchainInterface::class) instanceof ZigToolchain) {
return;
}
$extra_cflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') ?: '';
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . trim($extra_cflags . ' -Xclang -target-feature -Xclang +evex512'));
$extra_cxxflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS') ?: '';
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS=' . trim($extra_cxxflags . ' -Xclang -target-feature -Xclang +evex512'));
}
}

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\PkgConfigUtil;
#[Extension('snmp')]
class snmp extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-snmp')]
#[PatchDescription('Fix snmp extension compile error when building with older PHP version and newer net-snmp library')]
public function patchBeforeBuildconf(): bool
{
// Overwrite m4 config using newer PHP version
if (php::getPHPVersionID() < 80400) {
FileSystem::copy(ROOT_DIR . '/src/globals/extra/snmp-ext-config-old.m4', "{$this->getSourceDir()}/config.m4");
}
$libs = implode(' ', PkgConfigUtil::getLibsArray('netsnmp'));
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.m4",
'PHP_EVAL_LIBLINE([$SNMP_LIBS], [SNMP_SHARED_LIBADD])',
"SNMP_LIBS=\"{$libs}\"\nPHP_EVAL_LIBLINE([\$SNMP_LIBS], [SNMP_SHARED_LIBADD])"
);
return true;
}
}

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('spx')]
class spx extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-spx')]
#[PatchDescription('Fix spx extension compile error when building as static')]
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.m4",
'CFLAGS="$CFLAGS -Werror -Wall -O3 -pthread -std=gnu90"',
'CFLAGS="$CFLAGS -pthread"'
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/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->getSourceDir()}/src/php_spx.h", "{$this->getSourceDir()}/php_spx.h");
return true;
}
#[BeforeStage('php', [php::class, 'configureForUnix'], 'ext-spx')]
#[PatchDescription('Fix spx extension compile error when configuring')]
public function patchBeforeConfigure(): void
{
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/Makefile.frag",
'@cp -r assets/web-ui/*',
"@cp -r {$this->getSourceDir()}/assets/web-ui/*",
);
}
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
$env['SPX_SHARED_LIBADD'] = $env['LIBS'];
return $env;
}
}

View File

@ -766,6 +766,7 @@ trait unix
return array_filter([
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'EXTRA_CXXFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS'),
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') . "{$config['ldflags']} {$static} {$pie}",
'EXTRA_LDFLAGS' => $config['ldflags'],
'EXTRA_LIBS' => $libs,

View File

@ -22,6 +22,13 @@ use ZM\Logger\ConsoleColor;
trait windows
{
#[BeforeStage('php', [self::class, 'buildconfForWindows'])]
#[PatchDescription('Patch for fixing win32 xml related extensions builds')]
public function beforeBuildconfWin(TargetPackage $package): void
{
FileSystem::replaceFileStr("{$package->getSourceDir()}/win32/build/config.w32", 'dllmain.c ', '');
}
#[Stage]
public function buildconfForWindows(TargetPackage $package): void
{

View File

@ -61,7 +61,7 @@ class GitHubTarball implements DownloadTypeInterface, CheckUpdateInterface
$filename = $matches['filename'];
} else {
$basename = $basename ?? basename($repo);
$filename = "{$basename}-" . ($rel_type === 'releases' ? $data['tag_name'] : $data['name']) . '.tar.gz';
$filename = "{$basename}-" . ($rel_type === 'releases' ? ($data['tag_name'] ?? $data['name']) : $data['name']) . '.tar.gz';
}
return [$url, $filename];
}