mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
add xdebug dynamic extension
This commit is contained in:
parent
e850df505c
commit
1791b443bc
@ -888,13 +888,16 @@
|
||||
]
|
||||
},
|
||||
"xdebug": {
|
||||
"type": "builtin",
|
||||
"type": "external",
|
||||
"support": {
|
||||
"Windows": "wip",
|
||||
"BSD": "no",
|
||||
"Darwin": "no",
|
||||
"Linux": "no"
|
||||
"Linux": "wip"
|
||||
},
|
||||
"lib-depends": [
|
||||
"xdebug"
|
||||
],
|
||||
"notes": true
|
||||
},
|
||||
"xhprof": {
|
||||
|
||||
@ -738,6 +738,12 @@
|
||||
"libiconv"
|
||||
]
|
||||
},
|
||||
"xdebug": {
|
||||
"source": "xdebug",
|
||||
"static-libs-unix": [
|
||||
"xdebug.so"
|
||||
]
|
||||
},
|
||||
"xz": {
|
||||
"source": "xz",
|
||||
"static-libs-unix": [
|
||||
|
||||
@ -895,6 +895,17 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"xdebug": {
|
||||
"type": "ghrel",
|
||||
"repo": "xdebug/xdebug",
|
||||
"match": "Source code",
|
||||
"prefer-stable": true,
|
||||
"provide-pre-built": false,
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"xhprof": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/xhprof",
|
||||
|
||||
11
src/SPC/builder/extension/xdebug.php
Normal file
11
src/SPC/builder/extension/xdebug.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\DynamicExt;
|
||||
|
||||
#[DynamicExt]
|
||||
class xdebug extends Extension {}
|
||||
15
src/SPC/builder/linux/library/xdebug.php
Normal file
15
src/SPC/builder/linux/library/xdebug.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\util\DynamicExt;
|
||||
|
||||
#[DynamicExt]
|
||||
class xdebug extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\xdebug;
|
||||
|
||||
public const NAME = 'xdebug';
|
||||
}
|
||||
26
src/SPC/builder/unix/library/xdebug.php
Normal file
26
src/SPC/builder/unix/library/xdebug.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
trait xdebug
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(BUILD_BIN_PATH . '/phpize')
|
||||
->exec('./configure --with-php-config=' . BUILD_BIN_PATH . '/php-config')
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}");
|
||||
copy($this->source_dir . '/modules/xdebug.so', BUILD_LIB_PATH . '/xdebug.so');
|
||||
copy($this->source_dir . '/modules/xdebug.la', BUILD_LIB_PATH . '/xdebug.la');
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\DependencyUtil;
|
||||
use SPC\util\DynamicExt;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\LicenseDumper;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
@ -109,6 +110,18 @@ class BuildPHPCommand extends BuildCommand
|
||||
$include_suggest_lib = $this->getOption('with-suggested-libs');
|
||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||
$display_libs = array_filter($libraries, fn ($lib) => in_array(Config::getLib($lib, 'type', 'lib'), ['lib', 'package']));
|
||||
$dynamic_libs = $dynamic_exts = array_filter($extensions, function (string $ext) {
|
||||
$classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\builder\extension');
|
||||
$extension = array_find($classes, function (string $class) use ($ext) {
|
||||
$a = explode('\\', $class);
|
||||
return end($a) === $ext;
|
||||
});
|
||||
$reflector = new \ReflectionClass($extension);
|
||||
$attributes = $reflector->getAttributes();
|
||||
return array_find($attributes, fn ($attr) => $attr->getName() === DynamicExt::class) !== null;
|
||||
});
|
||||
$extensions = array_diff($extensions, $dynamic_exts);
|
||||
$libraries = array_diff($libraries, $dynamic_libs);
|
||||
|
||||
// print info
|
||||
$indent_texts = [
|
||||
@ -153,7 +166,7 @@ class BuildPHPCommand extends BuildCommand
|
||||
$builder->proveLibs($libraries);
|
||||
// check extensions
|
||||
$builder->proveExts($extensions);
|
||||
// validate libs and exts
|
||||
// validate libs and extensions
|
||||
$builder->validateLibsAndExts();
|
||||
|
||||
// clean builds and sources
|
||||
@ -183,6 +196,13 @@ class BuildPHPCommand extends BuildCommand
|
||||
// start to build
|
||||
$builder->buildPHP($rule);
|
||||
|
||||
if ($rule & BUILD_TARGET_EMBED) {
|
||||
// build dynamic extensions
|
||||
$builder->proveLibs($dynamic_libs);
|
||||
// build or install libraries
|
||||
$builder->setupLibs();
|
||||
}
|
||||
|
||||
// compile stopwatch :P
|
||||
$time = round(microtime(true) - START_TIME, 3);
|
||||
logger()->info('');
|
||||
@ -217,7 +237,7 @@ class BuildPHPCommand extends BuildCommand
|
||||
file_put_contents(BUILD_ROOT_PATH . '/build-libraries.json', json_encode($libraries, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
// export licenses
|
||||
$dumper = new LicenseDumper();
|
||||
$dumper->addExts($extensions)->addLibs($libraries)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license');
|
||||
$dumper->addExts($extensions)->addLibs($libraries)->addLibs($dynamic_libs)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license');
|
||||
$path = FileSystem::convertPath("{$build_root_path}/license/");
|
||||
logger()->info("License path{$fixed}: {$path}");
|
||||
return static::SUCCESS;
|
||||
|
||||
@ -73,7 +73,7 @@ class Downloader
|
||||
$url = $data[0]['tarball_url'];
|
||||
} else {
|
||||
$id = 0;
|
||||
while ($data[$id]['prerelease'] === true) {
|
||||
while (($data[$id]['prerelease'] ?? false) === true) {
|
||||
++$id;
|
||||
}
|
||||
$url = $data[$id]['tarball_url'] ?? null;
|
||||
@ -122,6 +122,10 @@ class Downloader
|
||||
if (!$match_result) {
|
||||
return $release['assets'];
|
||||
}
|
||||
if ($source['match'] === 'Source code') {
|
||||
$url = $release['tarball_url'];
|
||||
break;
|
||||
}
|
||||
foreach ($release['assets'] as $asset) {
|
||||
if (preg_match('|' . $source['match'] . '|', $asset['name'])) {
|
||||
$url = $asset['browser_download_url'];
|
||||
@ -134,6 +138,9 @@ class Downloader
|
||||
throw new DownloaderException("failed to find {$name} release metadata");
|
||||
}
|
||||
$filename = basename($url);
|
||||
if ($source['match'] === 'Source code') {
|
||||
$filename = $name . $filename . '.tar.gz';
|
||||
}
|
||||
|
||||
return [$url, $filename];
|
||||
}
|
||||
|
||||
8
src/SPC/util/DynamicExt.php
Normal file
8
src/SPC/util/DynamicExt.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\util;
|
||||
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS)]
|
||||
class DynamicExt {}
|
||||
Loading…
x
Reference in New Issue
Block a user