Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/SPC/builder/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function patchBeforeMake(): bool
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeSharedBuild(): bool
public function patchBeforeSharedPhpize(): bool
{
return false;
}
Expand All @@ -208,6 +208,16 @@ public function patchBeforeSharedConfigure(): bool
return false;
}

/**
* Patch code before shared extension make
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeSharedMake(): bool
{
return false;
}

/**
* @return string
* returns a command line string with all required shared extensions to load
Expand Down Expand Up @@ -384,13 +394,17 @@ public function buildUnixShared(): void
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];

if ($this->patchBeforeSharedPhpize()) {
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
}

// prepare configure args
shell()->cd($this->source_dir)
->setEnv($env)
->exec(BUILD_BIN_PATH . '/phpize');

if ($this->patchBeforeSharedConfigure()) {
logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure');
logger()->info("Extension [{$this->getName()}] patched before shared configure");
}

shell()->cd($this->source_dir)
Expand All @@ -408,6 +422,10 @@ public function buildUnixShared(): void
'$1 ' . $staticLibString
);

if ($this->patchBeforeSharedMake()) {
logger()->info("Extension [{$this->getName()}] patched before shared make");
}

shell()->cd($this->source_dir)
->setEnv($env)
->exec('make clean')
Expand Down
2 changes: 1 addition & 1 deletion src/SPC/builder/extension/intl.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function patchBeforeBuildconf(): bool
return true;
}

public function patchBeforeSharedBuild(): bool
public function patchBeforeSharedPhpize(): bool
{
return $this->patchBeforeBuildconf();
}
Expand Down
10 changes: 10 additions & 0 deletions src/SPC/builder/extension/uv.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;

#[CustomExt('uv')]
Expand All @@ -16,4 +17,13 @@ public function validate(): void
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
}
}

public function patchBeforeSharedMake(): bool
{
if (PHP_OS_FAMILY !== 'Linux' || arch2gnu(php_uname('m')) !== 'aarch64') {
return false;
}
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread');
return true;
}
}
2 changes: 0 additions & 2 deletions src/SPC/command/BuildPHPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ public function handle(): int
// start to build
$builder->buildPHP($rule);

SourcePatcher::patchBeforeSharedBuild($builder);

// build dynamic extensions if needed
if (!empty($shared_extensions)) {
logger()->info('Building shared extensions ...');
Expand Down
3 changes: 1 addition & 2 deletions src/SPC/doctor/item/LinuxToolCheckList.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function checkCliTools(): ?CheckResult

$required = match ($distro['dist']) {
'alpine' => self::TOOLS_ALPINE,
'redhat' => self::TOOLS_RHEL,
'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd']),
'redhat', 'centos' => self::TOOLS_RHEL,
'arch' => self::TOOLS_ARCH,
default => self::TOOLS_DEBIAN,
};
Expand Down
21 changes: 6 additions & 15 deletions src/SPC/store/SourcePatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void
{
foreach ($builder->getExts() as $ext) {
if ($ext->patchBeforeBuildconf() === true) {
logger()->info('Extension [' . $ext->getName() . '] patched before buildconf');
logger()->info("Extension [{$ext->getName()}] patched before buildconf");
}
}
foreach ($builder->getLibs() as $lib) {
if ($lib->patchBeforeBuildconf() === true) {
logger()->info('Library [' . $lib->getName() . '] patched before buildconf');
logger()->info("Library [{$lib->getName()}]patched before buildconf");
}
}
// patch windows php 8.1 bug
Expand Down Expand Up @@ -79,15 +79,6 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void
}
}

public static function patchBeforeSharedBuild(BuilderBase $builder): void
{
foreach ($builder->getExts() as $ext) {
if ($ext->patchBeforeSharedBuild() === true) {
logger()->info('Extension [' . $ext->getName() . '] patched before shared build');
}
}
}

/**
* Source patcher runner before configure
*
Expand All @@ -98,12 +89,12 @@ public static function patchBeforeConfigure(BuilderBase $builder): void
{
foreach ($builder->getExts() as $ext) {
if ($ext->patchBeforeConfigure() === true) {
logger()->info('Extension [' . $ext->getName() . '] patched before configure');
logger()->info("Extension [{$ext->getName()}] patched before configure");
}
}
foreach ($builder->getLibs() as $lib) {
if ($lib->patchBeforeConfigure() === true) {
logger()->info('Library [' . $lib->getName() . '] patched before configure');
logger()->info("Library [{$lib->getName()}] patched before configure");
}
}
// patch capstone
Expand Down Expand Up @@ -279,12 +270,12 @@ public static function patchBeforeMake(BuilderBase $builder): void
// call extension patch before make
foreach ($builder->getExts(false) as $ext) {
if ($ext->patchBeforeMake() === true) {
logger()->info('Extension [' . $ext->getName() . '] patched before make');
logger()->info("Extension [{$ext->getName()}] patched before make");
}
}
foreach ($builder->getLibs() as $lib) {
if ($lib->patchBeforeMake() === true) {
logger()->info('Library [' . $lib->getName() . '] patched before make');
logger()->info("Library [{$lib->getName()}] patched before make");
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
$test_os = [
'macos-13',
// 'macos-13',
// 'macos-14',
'macos-15',
// 'macos-15',
// 'ubuntu-latest',
// 'ubuntu-22.04',
// 'ubuntu-24.04',
// 'ubuntu-22.04-arm',
'ubuntu-22.04-arm',
// 'ubuntu-24.04-arm',
// 'windows-latest',
];

// whether enable thread safe
$zts = false;
$zts = true;

$no_strip = false;

Expand All @@ -54,13 +54,13 @@

// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
$shared_extensions = match (PHP_OS_FAMILY) {
'Linux' => '',
'Linux' => 'uv',
'Darwin' => '',
'Windows' => '',
};

// If you want to test lib-suggests for all extensions and libraries, set it to true.
$with_suggested_libs = 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) {
Expand Down