Add ext-xhprof

This commit is contained in:
crazywhalecc 2026-03-17 13:27:37 +08:00
parent 20b693d1fa
commit ca15ccd4d1
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,18 @@
ext-xhprof:
type: php-extension
artifact:
source:
type: pecl
name: xhprof
extract: php-src/ext/xhprof-src
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- ext-ctype
php-extension:
support:
Windows: wip
BSD: wip
arg-type: enable
build-with-php: true

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('xhprof')]
class xhprof extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-xhprof')]
public function patchBeforeBuildconf(PackageInstaller $installer): bool
{
$php_src = $installer->getTargetPackage('php')->getSourceDir();
$link = "{$php_src}/ext/xhprof";
if (!is_link($link)) {
shell()->cd("{$php_src}/ext")->exec('ln -s xhprof-src/extension xhprof');
// patch config.m4
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/extension/config.m4",
'if test -f $phpincludedir/ext/pcre/php_pcre.h; then',
'if test -f $abs_srcdir/ext/pcre/php_pcre.h; then'
);
return true;
}
return false;
}
}