mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-13 20:05:35 +08:00
Compare commits
6 Commits
9ee7d7769a
...
2.1.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73035067e3 | ||
|
|
421b3830b6 | ||
|
|
59dcb905fe | ||
|
|
d222190fc7 | ||
|
|
06e9864d19 | ||
|
|
0b1a321615 |
@@ -369,8 +369,10 @@ abstract class BuilderBase
|
|||||||
|
|
||||||
foreach ($this->getExts() as $ext) {
|
foreach ($this->getExts() as $ext) {
|
||||||
$ext_name = $ext->getDistName();
|
$ext_name = $ext->getDistName();
|
||||||
$php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n";
|
if (!empty($ext_name)) {
|
||||||
$php .= "assert(extension_loaded('{$ext_name}'));\n\n";
|
$php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n";
|
||||||
|
$php .= "assert(extension_loaded('{$ext_name}'));\n\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$php .= "echo '[micro-test-end]';\n";
|
$php .= "echo '[micro-test-end]';\n";
|
||||||
return $php;
|
return $php;
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ 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 '';
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ use SPC\util\CustomExt;
|
|||||||
#[CustomExt('swoole-hook-mysql')]
|
#[CustomExt('swoole-hook-mysql')]
|
||||||
class swoole_hook_mysql extends Extension
|
class swoole_hook_mysql extends Extension
|
||||||
{
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
// pdo_mysql doesn't need to be disabled
|
// pdo_mysql doesn't need to be disabled
|
||||||
@@ -18,7 +23,7 @@ class swoole_hook_mysql extends Extension
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runCliCheck(): void
|
public function runCliCheckUnix(): void
|
||||||
{
|
{
|
||||||
// skip if not enable swoole
|
// skip if not enable swoole
|
||||||
if ($this->builder->getExt('swoole') === null) {
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ use SPC\util\CustomExt;
|
|||||||
#[CustomExt('swoole-hook-pgsql')]
|
#[CustomExt('swoole-hook-pgsql')]
|
||||||
class swoole_hook_pgsql extends Extension
|
class swoole_hook_pgsql extends Extension
|
||||||
{
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
// pdo_pgsql need to be disabled
|
// pdo_pgsql need to be disabled
|
||||||
@@ -22,7 +27,7 @@ class swoole_hook_pgsql extends Extension
|
|||||||
return '--enable-swoole-pgsql';
|
return '--enable-swoole-pgsql';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runCliCheck(): void
|
public function runCliCheckUnix(): void
|
||||||
{
|
{
|
||||||
// skip if not enable swoole
|
// skip if not enable swoole
|
||||||
if ($this->builder->getExt('swoole') === null) {
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ use SPC\util\CustomExt;
|
|||||||
#[CustomExt('swoole-hook-sqlite')]
|
#[CustomExt('swoole-hook-sqlite')]
|
||||||
class swoole_hook_sqlite extends Extension
|
class swoole_hook_sqlite extends Extension
|
||||||
{
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
// pdo_pgsql need to be disabled
|
// pdo_pgsql need to be disabled
|
||||||
@@ -22,7 +27,7 @@ class swoole_hook_sqlite extends Extension
|
|||||||
return '--enable-swoole-sqlite';
|
return '--enable-swoole-sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runCliCheck(): void
|
public function runCliCheckUnix(): void
|
||||||
{
|
{
|
||||||
// skip if not enable swoole
|
// skip if not enable swoole
|
||||||
if ($this->builder->getExt('swoole') === null) {
|
if ($this->builder->getExt('swoole') === null) {
|
||||||
|
|||||||
@@ -178,12 +178,17 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
file_put_contents(
|
file_put_contents(
|
||||||
SOURCE_PATH . '/hello.exe',
|
SOURCE_PATH . '/hello.exe',
|
||||||
file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') .
|
file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') .
|
||||||
'<?php echo "hello";'
|
($this->getOption('without-micro-ext-test') ? '<?php echo "[micro-test-start][micro-test-end]";' : $this->generateMicroExtTests())
|
||||||
);
|
);
|
||||||
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
chmod(SOURCE_PATH . '/hello.exe', 0755);
|
||||||
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
[$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe');
|
||||||
if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') {
|
$raw_out = trim(implode('', $output2));
|
||||||
throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']');
|
$condition[0] = $ret === 0;
|
||||||
|
$condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]');
|
||||||
|
foreach ($condition as $k => $v) {
|
||||||
|
if (!$v) {
|
||||||
|
throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ trait curl
|
|||||||
// compile!
|
// compile!
|
||||||
shell()->cd($this->source_dir . '/build')
|
shell()->cd($this->source_dir . '/build')
|
||||||
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
||||||
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..")
|
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
||||||
->exec("make -j{$this->builder->concurrency}")
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
// patch pkgconf
|
// patch pkgconf
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class WindowsBuilder extends BuilderBase
|
|||||||
file_put_contents(
|
file_put_contents(
|
||||||
SOURCE_PATH . '\hello.exe',
|
SOURCE_PATH . '\hello.exe',
|
||||||
file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') .
|
file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') .
|
||||||
($this->getOption('with-micro-ext-test') ? $this->generateMicroExtTests() : '<?php echo "[micro-test-start][micro-test-end]";')
|
($this->getOption('without-micro-ext-test') ? '<?php echo "[micro-test-start][micro-test-end]";' : $this->generateMicroExtTests())
|
||||||
);
|
);
|
||||||
chmod(SOURCE_PATH . '\hello.exe', 0755);
|
chmod(SOURCE_PATH . '\hello.exe', 0755);
|
||||||
[$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe');
|
[$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe');
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class BuildCliCommand extends BuildCommand
|
|||||||
$this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs');
|
$this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs');
|
||||||
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
|
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
|
||||||
$this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside');
|
$this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside');
|
||||||
$this->addOption('with-micro-ext-test', null, null, 'Enable phpmicro with extension test code');
|
$this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class DownloadCommand extends BaseCommand
|
|||||||
// get source list that will be downloaded
|
// get source list that will be downloaded
|
||||||
$sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources'))));
|
$sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources'))));
|
||||||
if (empty($sources)) {
|
if (empty($sources)) {
|
||||||
logger()->warning('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !');
|
logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !');
|
||||||
$sources = array_keys(Config::getSources());
|
$sources = array_keys(Config::getSources());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => '',
|
'Linux', 'Darwin' => 'calendar,ctype,curl,dom,fileinfo,filter,gd,iconv,imagick,mbregex,mbstring,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,rar,redis,session,simplexml,soap,sockets,sqlite3,swoole,swoole-hook-mysql,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib',
|
||||||
'Windows' => 'mbstring,openssl',
|
'Windows' => 'mbstring,openssl',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) {
|
|||||||
// You can use `common`, `bulk`, `minimal` or `none`.
|
// You can use `common`, `bulk`, `minimal` or `none`.
|
||||||
// note: combination is only available for *nix platform. Windows must use `none` combination
|
// note: combination is only available for *nix platform. Windows must use `none` combination
|
||||||
$base_combination = match (PHP_OS_FAMILY) {
|
$base_combination = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'minimal',
|
'Linux', 'Darwin' => 'none',
|
||||||
'Windows' => 'none',
|
'Windows' => 'none',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user