mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 16:25:39 +08:00
Add getLibVersion and getExtVersion method for extensions and libs
This commit is contained in:
@@ -161,7 +161,7 @@ abstract class BuilderBase
|
||||
* @throws WrongUsageException
|
||||
* @internal
|
||||
*/
|
||||
public function proveExts(array $extensions): void
|
||||
public function proveExts(array $extensions, bool $skip_check_deps = false): void
|
||||
{
|
||||
CustomExt::loadCustomExt();
|
||||
$this->emitPatchPoint('before-php-extract');
|
||||
@@ -181,6 +181,10 @@ abstract class BuilderBase
|
||||
$this->addExt($ext);
|
||||
}
|
||||
|
||||
if ($skip_check_deps) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->exts as $ext) {
|
||||
$ext->checkDependency();
|
||||
}
|
||||
|
||||
@@ -228,6 +228,16 @@ class Extension
|
||||
// do nothing, just throw wrong usage exception if not valid
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current extension version
|
||||
*
|
||||
* @return null|string Version string or null
|
||||
*/
|
||||
public function getExtVersion(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
|
||||
@@ -182,6 +182,16 @@ abstract class LibraryBase
|
||||
// do nothing, just throw wrong usage exception if not valid
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current lib version
|
||||
*
|
||||
* @return null|string Version string or null
|
||||
*/
|
||||
public function getLibVersion(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current builder object.
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,18 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('swoole')]
|
||||
class swoole extends Extension
|
||||
{
|
||||
public function getExtVersion(): ?string
|
||||
{
|
||||
// Get version from source directory
|
||||
$file = SOURCE_PATH . '/php-src/ext/swoole/include/swoole_version.h';
|
||||
// Match #define SWOOLE_VERSION "5.1.3"
|
||||
$pattern = '/#define SWOOLE_VERSION "(.+)"/';
|
||||
if (preg_match($pattern, file_get_contents($file), $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
// enable swoole
|
||||
|
||||
Reference in New Issue
Block a user