mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Merge branch 'main' into libargon2-support
This commit is contained in:
commit
52d61365b7
@ -169,14 +169,14 @@
|
|||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"mbstring"
|
"mbstring"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"onig"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mbstring": {
|
"mbstring": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom"
|
||||||
"lib-depends": [
|
|
||||||
"onig"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"memcache": {
|
"memcache": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
|
|||||||
@ -163,6 +163,35 @@ class Extension
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run compile check if build target is cli
|
||||||
|
* If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
|
||||||
|
* If check failed, throw RuntimeException
|
||||||
|
*
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function runCliCheck(): void
|
||||||
|
{
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')) {
|
||||||
|
// Trim additional content & escape special characters to allow inline usage
|
||||||
|
$test = str_replace(
|
||||||
|
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
||||||
|
['', '', '', '\"', '\$'],
|
||||||
|
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')
|
||||||
|
);
|
||||||
|
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,18 +5,25 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('mbregex')]
|
#[CustomExt('mbregex')]
|
||||||
class mbregex extends Extension
|
class mbregex extends Extension
|
||||||
{
|
{
|
||||||
public function getDistName(): string
|
|
||||||
{
|
|
||||||
return 'mbstring';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getConfigureArg(): string
|
public function getConfigureArg(): string
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbregex is not an extension, we need to overwrite the default check.
|
||||||
|
*/
|
||||||
|
public function runCliCheck(): void
|
||||||
|
{
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false);
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,24 +66,7 @@ trait UnixBuilderTrait
|
|||||||
|
|
||||||
foreach ($this->exts as $ext) {
|
foreach ($this->exts as $ext) {
|
||||||
logger()->debug('testing ext: ' . $ext->getName());
|
logger()->debug('testing ext: ' . $ext->getName());
|
||||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $ext->getDistName() . '"', false);
|
$ext->runCliCheck();
|
||||||
if ($ret !== 0) {
|
|
||||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) {
|
|
||||||
// Trim additional content & escape special characters to allow inline usage
|
|
||||||
$test = str_replace(
|
|
||||||
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
|
||||||
['', '', '', '\"', '\$'],
|
|
||||||
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')
|
|
||||||
);
|
|
||||||
|
|
||||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
|
|
||||||
if ($ret !== 0) {
|
|
||||||
throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user