add micro php version limit

This commit is contained in:
crazywhalecc 2023-03-18 20:08:54 +08:00
parent 4edd05f4df
commit 9ce92e39d5
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
5 changed files with 15 additions and 5 deletions

View File

@ -46,7 +46,7 @@ chmod +x spc
- [X] macOS support
- [X] Exception handler
- [ ] Windows support
- [ ] PHP 7.4 support
- [X] PHP 7.4 support
## Supported Extensions (WIP)

View File

@ -49,7 +49,7 @@ chmod +x spc
- [X] macOS 支持
- [ ] Windows 支持
- [ ] Linux 支持
- [ ] PHP 7.4 支持
- [X] PHP 7.4 支持
## 支持的扩展情况WIP

View File

@ -66,4 +66,4 @@
## Bugs
See #32.
See [#32](https://github.com/crazywhalecc/static-php-cli/issues/32).

View File

@ -219,6 +219,9 @@ class MacOSBuilder extends BuilderBase
*/
public function buildMicro(string $extra_libs): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
try {
@ -260,4 +263,11 @@ class MacOSBuilder extends BuilderBase
'strip sapi/cli/php'
);
}
public function getPHPVersionID(): int
{
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
preg_match('/PHP_VERSION_ID (\d+)/', $file, $match);
return intval($match[1]);
}
}

View File

@ -77,8 +77,8 @@ class BuildCliCommand extends BuildCommand
if ($input->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
} else {
logger()->emergency('Build failed, please check terminal output, or build with --debug option to see more details.');
logger()->emergency($e->getMessage());
logger()->critical('Build failed, please check terminal output, or build with --debug option to see more details.');
logger()->critical($e->getMessage());
}
return 1;
}